From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Song Liu <song@kernel.org>
Cc: live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org,
jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com,
joe.lawrence@redhat.com, shuah@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 03/12] klp-build: Move patch processing to klp-prepare-patch
Date: Tue, 10 Nov 2026 11:55:52 -0800 [thread overview]
Message-ID: <avNz-_AbTGGlsP5o@jpoimboe> (raw)
In-Reply-To: <20261028214534.1919398-4-song@kernel.org>
On Wed, Oct 28, 2026 at 02:45:25PM -0700, Song Liu wrote:
> -apply_patches() {
> - local patch
> -
> - for patch in "${PATCHES[@]}"; do
> - apply_patch "$patch"
> - done
> -}
> -
> revert_patches() {
> local patches=("${APPLIED_PATCHES[@]}")
>
I think we can remove even more cruft:
diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
index 4796b36b5cc8e..b93e1227b4c03 100755
--- a/scripts/livepatch/klp-build
+++ b/scripts/livepatch/klp-build
@@ -19,7 +19,7 @@ set -o nounset
# This helps keep execution in pipes so pipefail+ERR trap can catch errors.
shopt -s lastpipe
-unset DEBUG_CLONE DIFF_CHECKSUM SKIP_CLEANUP VERBOSE XTRACE
+unset DEBUG_CLONE DIFF_CHECKSUM PATCH_APPLIED SKIP_CLEANUP VERBOSE XTRACE
REPLACE=1
SHORT_CIRCUIT=0
@@ -110,7 +110,7 @@ restore_files() {
cleanup() {
set +o nounset
- revert_patches
+ revert_patch
restore_files
[[ "$KEEP_TMP" -eq 0 ]] && rm -rf "$TMP_DIR"
return 0
@@ -329,50 +329,14 @@ set_kernelversion() {
}
apply_patch() {
- local patch="$1"
- shift
- local extra_args=("$@")
- local drift_regex="with fuzz|offset [0-9]+ line"
- local output
- local status
-
- [[ ! -f "$patch" ]] && die "$patch doesn't exist"
- status=0
- output=$(patch -p1 --dry-run --no-backup-if-mismatch -r /dev/null "${extra_args[@]}" < "$patch" 2>&1) || status=$?
- if [[ "$status" -ne 0 ]]; then
- echo "$output" >&2
- die "$patch did not apply"
- elif [[ "$output" =~ $drift_regex ]]; then
- [[ -v VERBOSE ]] && echo "$output" >&2
- warn "${patch} applied with fuzz"
- fi
-
- APPLIED_PATCHES+=("$patch")
- patch -p1 --no-backup-if-mismatch -r /dev/null "${extra_args[@]}" --silent < "$patch"
+ PATCH_APPLIED=1
+ patch -p1 --no-backup-if-mismatch -r /dev/null --silent < "$COMBINED_PATCH"
}
revert_patch() {
- local patch="$1"
- local tmp=()
-
- patch -p1 -R --force --no-backup-if-mismatch -r /dev/null &> /dev/null < "$patch" || true
-
- for p in "${APPLIED_PATCHES[@]}"; do
- [[ "$p" == "$patch" ]] && continue
- tmp+=("$p")
- done
-
- APPLIED_PATCHES=("${tmp[@]}")
-}
-
-revert_patches() {
- local patches=("${APPLIED_PATCHES[@]}")
-
- for (( i=${#patches[@]}-1 ; i>=0 ; i-- )) ; do
- revert_patch "${patches[$i]}"
- done
-
- APPLIED_PATCHES=()
+ [[ -v PATCH_APPLIED ]] || return 0
+ patch -p1 -R --force --no-backup-if-mismatch -r /dev/null &> /dev/null < "$COMBINED_PATCH" || true
+ unset PATCH_APPLIED
}
do_init() {
@@ -397,8 +361,6 @@ do_init() {
(( SHORT_CIRCUIT <= 1 )) && rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR"
- APPLIED_PATCHES=()
-
[[ -x "$PREPARE_PATCH" ]] || die "can't find klp-prepare-patch"
validate_config
@@ -806,10 +768,10 @@ if (( SHORT_CIRCUIT <= 1 )); then
fi
if (( SHORT_CIRCUIT <= 2 )); then
- apply_patch "$COMBINED_PATCH" "--silent"
+ apply_patch
status "Building patched kernel"
build_kernel "patched"
- revert_patches
+ revert_patch
status "Copying patched object files"
copy_patched_objects
fi
next prev parent reply other threads:[~2026-11-10 19:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 21:45 [PATCH v2 00/12] klp-build: Fix dependent patches, add selftests Song Liu
2026-10-28 21:45 ` [PATCH v2 01/12] klp-build: Fix dependent patches in a series Song Liu
2026-10-28 21:45 ` [PATCH v2 02/12] klp-build: Process the patches before building the original kernel Song Liu
2026-10-28 21:45 ` [PATCH v2 03/12] klp-build: Move patch processing to klp-prepare-patch Song Liu
2026-11-10 19:55 ` Josh Poimboeuf [this message]
2026-10-28 21:45 ` [PATCH v2 04/12] selftests/livepatch: Add tests for klp-prepare-patch Song Liu
2026-10-28 21:45 ` [PATCH v2 05/12] selftests/livepatch: Test klp-prepare-patch with dependent patches Song Liu
2026-10-28 21:45 ` [PATCH v2 06/12] selftests/livepatch: Test klp-prepare-patch with independent patches Song Liu
2026-10-28 21:45 ` [PATCH v2 07/12] selftests/livepatch: Test klp-prepare-patch with patches which cancel out Song Liu
2026-10-28 21:45 ` [PATCH v2 08/12] selftests/livepatch: Test klp-prepare-patch with created and deleted files Song Liu
2026-10-28 21:45 ` [PATCH v2 09/12] selftests/livepatch: Test where klp-prepare-patch adds #line directives Song Liu
2026-10-28 21:45 ` [PATCH v2 10/12] selftests/livepatch: Test klp-prepare-patch with unsupported files Song Liu
2026-10-28 21:45 ` [PATCH v2 11/12] selftests/livepatch: Test klp-prepare-patch with patches which don't apply Song Liu
2026-10-28 21:45 ` [PATCH v2 12/12] selftests/livepatch: Test klp-prepare-patch with offset and fuzz Song Liu
2026-11-10 12:45 ` [PATCH v2 00/12] klp-build: Fix dependent patches, add selftests Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avNz-_AbTGGlsP5o@jpoimboe \
--to=jpoimboe@kernel.org \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®