Skip to content

Commit b99d393

Browse files
committed
PRODKERNEL: optimize diff processing
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]>
1 parent 6a7200d commit b99d393

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

kpatch-build/kpatch-build

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,10 @@ for i in $FILES; do
11351135
find_kobj "$i"
11361136
cd "$TEMPDIR" || die
11371137
if [[ -e "orig/$i" ]]; then
1138-
if [[ "$(basename "$KOBJFILE")" = vmlinux ]]; then
1138+
if cmp -s "orig/$i" "patched/$i"; then
1139+
: $i unchanged
1140+
continue
1141+
elif [[ "$(basename "$KOBJFILE")" = vmlinux ]]; then
11391142
KOBJFILE_NAME=vmlinux
11401143
KOBJFILE_PATH="$VMLINUX"
11411144
SYMTAB="${TEMPDIR}/${KOBJFILE_NAME}.symtab"
@@ -1149,14 +1152,17 @@ for i in $FILES; do
11491152
else
11501153
KOBJFILE_NAME=$(basename "${KOBJFILE%.ko}")
11511154
KOBJFILE_NAME="${KOBJFILE_NAME//-/_}"
1152-
KOBJFILE_PATH="${TEMPDIR}/module/$KOBJFILE"
1153-
SYMTAB="${KOBJFILE_PATH}.symtab"
1155+
KOBJFILE_PATH="${BUILDDIR}/$KOBJFILE"
1156+
SYMTAB="${TEMPDIR}/module/$KOBJFILE".symtab
11541157
SYMVERS_FILE="$BUILDDIR/Module.symvers"
11551158
fi
11561159

1157-
"$READELF" -s --wide "$KOBJFILE_PATH" > "$SYMTAB"
1158-
if [[ "$ARCH" = "ppc64le" ]]; then
1159-
sed -ri 's/\s+\[<localentry>: 8\]//' "$SYMTAB"
1160+
if ! [[ "$SYMTAB" -nt "$KOBJFILE_PATH" ]]; then
1161+
mkdir -p "${SYMTAB%/*}"
1162+
"$READELF" -s --wide "$KOBJFILE_PATH" > "$SYMTAB"
1163+
if [[ "$ARCH" = "ppc64le" ]]; then
1164+
sed -ri 's/\s+\[<localentry>: 8\]//' "$SYMTAB"
1165+
fi
11601166
fi
11611167

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

0 commit comments

Comments
 (0)