Skip to content

Commit

Permalink
PRODKERNEL: optimize diff processing
Browse files Browse the repository at this point in the history
During kpatch-build's orig-vs-patched comparison pass:

- ignore unchanged objfiles, which may have been rebuilt, but built
  identically. Perhaps whitespace change, or an included file changed,
  but in ways that do not affect the code generated in _this_ object

- when $SYMTAB is still current, do not recreate

- create symtabs in kpatch temp dirs, not kernel tree
  As they're not .gitignore'd, they would create worrysome clutter

- allow symtab creation in missing directories, with mkdir -p

These avoid needless kpatch failures & slowdowns, where a change has
implications outside diff footprint, like *.h that cause many files
to rebuild, without change to objects, and in parts of the tree far
removed from the source files actually patched

Tested: by t314, which changes ipv6.h, causing hundreds of modules to
	rebuild, with no actual code change

Upstream-Plan: 190514358
Signed-off-by: Pete Swain <[email protected]>
  • Loading branch information
swine committed Sep 20, 2022
1 parent 6a7200d commit b99d393
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions kpatch-build/kpatch-build
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,10 @@ for i in $FILES; do
find_kobj "$i"
cd "$TEMPDIR" || die
if [[ -e "orig/$i" ]]; then
if [[ "$(basename "$KOBJFILE")" = vmlinux ]]; then
if cmp -s "orig/$i" "patched/$i"; then
: $i unchanged
continue
elif [[ "$(basename "$KOBJFILE")" = vmlinux ]]; then
KOBJFILE_NAME=vmlinux
KOBJFILE_PATH="$VMLINUX"
SYMTAB="${TEMPDIR}/${KOBJFILE_NAME}.symtab"
Expand All @@ -1149,14 +1152,17 @@ for i in $FILES; do
else
KOBJFILE_NAME=$(basename "${KOBJFILE%.ko}")
KOBJFILE_NAME="${KOBJFILE_NAME//-/_}"
KOBJFILE_PATH="${TEMPDIR}/module/$KOBJFILE"
SYMTAB="${KOBJFILE_PATH}.symtab"
KOBJFILE_PATH="${BUILDDIR}/$KOBJFILE"
SYMTAB="${TEMPDIR}/module/$KOBJFILE".symtab
SYMVERS_FILE="$BUILDDIR/Module.symvers"
fi

"$READELF" -s --wide "$KOBJFILE_PATH" > "$SYMTAB"
if [[ "$ARCH" = "ppc64le" ]]; then
sed -ri 's/\s+\[<localentry>: 8\]//' "$SYMTAB"
if ! [[ "$SYMTAB" -nt "$KOBJFILE_PATH" ]]; then
mkdir -p "${SYMTAB%/*}"
"$READELF" -s --wide "$KOBJFILE_PATH" > "$SYMTAB"
if [[ "$ARCH" = "ppc64le" ]]; then
sed -ri 's/\s+\[<localentry>: 8\]//' "$SYMTAB"
fi
fi

# create-diff-object orig.o patched.o parent-name parent-symtab
Expand Down

0 comments on commit b99d393

Please sign in to comment.