public inbox for live-patching@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Lawrence <joe.lawrence@redhat.com>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: live-patching@vger.kernel.org, Song Liu <song@kernel.org>,
	Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
	Petr Mladek <pmladek@suse.com>
Subject: Re: [PATCH v2 3/5] livepatch/klp-build: switch to GNU patch and recountdiff
Date: Thu, 5 Feb 2026 12:27:25 -0500	[thread overview]
Message-ID: <aYTS_ZtgcnZP3UCm@redhat.com> (raw)
In-Reply-To: <2j5d3dwa6jymmnte4gcykbm5pfzc36x7onn2ojgjliwkxnlcik@34hti52xld5m>

On Wed, Feb 04, 2026 at 10:35:07AM -0800, Josh Poimboeuf wrote:
> On Tue, Feb 03, 2026 at 09:51:38PM -0500, Joe Lawrence wrote:
> > I think this does simplify things, but:
> > 
> >   - introduces a dependency on patchutil's recountdiff
> 
> I was wondering if we could instead just update fix-patch-lines to fix
> the line numbers/counts, but I get the feeling that would require
> rewriting the whole script and may not be worth the complexity.  That
> script is nice and simple and robust at the moment.
> 

Ok, I'll take a look at fix-patch-lines and see how complicated it might
turn out to incorporate a recount.

> >   - requires goofy epoch timestamp filtering as `diff -N` doesn't use
> >     the `git diff` /dev/null, but a localized beginining of time epoch
> >     that may be 1969 or 1970 depending on the local timezone
> >   - can be *really* chatty, for example:
> > 
> >   Validating patch(es)
> >   patching file fs/proc/cmdline.c
> >   Hunk #1 succeeded at 7 (offset 1 line).
> >   Fixing patch(es)
> >   patching file fs/proc/cmdline.c
> >   Hunk #1 succeeded at 7 (offset 1 line).
> >   patching file fs/proc/cmdline.c
> >   patching file fs/proc/cmdline.c
> >   Building patched kernel
> >   Copying patched object files
> >   Diffing objects
> >   vmlinux.o: changed function: override_release
> >   vmlinux.o: changed function: cmdline_proc_show
> >   Building patch module: livepatch-cmdline-string.ko
> >   SUCCESS
> > 
> >   My initial thought was that I'd only be interested in knowing about
> >   patch offset/fuzz during the validation phase.  And in the interest of
> >   clarifying some of the output messages, it would be nice to know the
> >   patch it was referring to, so how about a follow up patch
> >   pretty-formatting with some indentation like:
> > 
> >   Validating patch(es)
> >     cmdline-string.patch
> >       patching file fs/proc/cmdline.c
> >       Hunk #1 succeeded at 7 (offset 1 line).
> >   Fixing patch(es)
> >   Building patched kernel
> >   Copying patched object files
> >   Diffing objects
> >   vmlinux.o: changed function: override_release
> >   vmlinux.o: changed function: cmdline_proc_show
> >   Building patch module: livepatch-cmdline-string.ko
> >   SUCCESS
> > 
> >   That said, Song suggested using --silent across the board, so maybe
> >   tie that into the existing --verbose option?
> 
> Hm.  Currently we go to considerable effort to make klp-build's output
> as concise as possible, which is good.  On the other hand, it might be
> important to know the patch has fuzz.
> 

To keep it succinct, the script could check for offset/fuzz and only
report it, including the "patching file ..." part, if there is any.

> I'm thinking I would agree that maybe it should be verbose when
> validating patches and silent elsewhere.  And the pretty formatting is a
> nice upgrade to that.
> 

In the past I've used a little function like:

  indent() {
      local num="${1:-0}"
      sed "s/^/$(printf '%*s' "$num" '')/"
  }

so I could just pipe in echo or command output like: `./cmd | indent 2`.
Good enough or maybe you have one?

> We might also consider indenting the outputs of the other steps.  For
> example:
> 
>   Building patched kernel
>     vmlinux.o: some warning
>   Copying patched object files
>   Diffing objects
>     vmlinux.o: changed function: override_release
>     vmlinux.o: changed function: cmdline_proc_show
> 
> Or alternatively, print the step names in ASCII bold or something.
> 

While I do kinda like the recent color coded output from the compilers,
I don't know if I'm ready for a full-color livepatch build experience :D

I wouldn't be against it, but my vote leans towards the indentation
since it leaves prettier log files, even if the color codes are filtered
out.  Then again, the color scheme bikeshedding we could look forward
to!

> >  apply_patch() {
> >  	local patch="$1"
> > -	shift
> > -	local extra_args=("$@")
> >  
> >  	[[ ! -f "$patch" ]] && die "$patch doesn't exist"
> >  
> >  	(
> >  		cd "$SRC"
> > -
> > -		# The sed strips the version signature from 'git format-patch',
> > -		# otherwise 'git apply --recount' warns.
> > -		sed -n '/^-- /q;p' "$patch" |
> > -			git apply "${extra_args[@]}"
> > +		# The sed strips the version signature from 'git format-patch'.
> > +		sed -n '/^-- /q;p' "$patch" | \
> > +			patch -p1 --no-backup-if-mismatch -r /dev/null
> 
> Is this still needed now that we don't use git apply --recount?
> 

I'll double check.  I recall having difficulties with recountdiff when
taking these out, but can't reproduce that by hand at the moment.

> > @@ -490,7 +468,7 @@ fix_patches() {
> >  
> >  		cp -f "$old_patch" "$tmp_patch"
> >  		refresh_patch "$tmp_patch"
> > -		"$FIX_PATCH_LINES" "$tmp_patch" > "$new_patch"
> > +		"$FIX_PATCH_LINES" "$tmp_patch" | recountdiff > "$new_patch"
> >  		refresh_patch "$new_patch"
> 
> Do we still need to refresh after the recountdiff?
> 

Yeah I think it's redundant as long as recountdiff doesn't emit
something weird, but if it did, it's probably already screwed up the
patch.

--
Joe


  reply	other threads:[~2026-02-05 17:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04  2:51 [PATCH v2 0/5] livepatch-klp-build: small fixups and enhancements Joe Lawrence
2026-02-04  2:51 ` [PATCH v2 1/5] objtool/klp: Fix mkstemp() failure with long paths Joe Lawrence
2026-02-04 16:47   ` Josh Poimboeuf
2026-02-05 15:53     ` Joe Lawrence
2026-02-04  2:51 ` [PATCH v2 2/5] livepatch/klp-build: handle patches that add/remove files Joe Lawrence
2026-02-04 18:02   ` Josh Poimboeuf
2026-02-05 16:35     ` Joe Lawrence
2026-02-05 16:53       ` Josh Poimboeuf
2026-02-10 19:54         ` Joe Lawrence
2026-02-10 20:57           ` Josh Poimboeuf
2026-02-04  2:51 ` [PATCH v2 3/5] livepatch/klp-build: switch to GNU patch and recountdiff Joe Lawrence
2026-02-04  2:58   ` Joe Lawrence
2026-02-04 18:35   ` Josh Poimboeuf
2026-02-05 17:27     ` Joe Lawrence [this message]
2026-02-05 17:49       ` Josh Poimboeuf
2026-02-04  2:51 ` [PATCH v2 4/5] livepatch/klp-build: minor short-circuiting tweaks Joe Lawrence
2026-02-04 18:40   ` Josh Poimboeuf
2026-02-05 17:47     ` Joe Lawrence
2026-02-04  2:51 ` [PATCH v2 5/5] livepatch/klp-build: provide friendlier error messages Joe Lawrence

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=aYTS_ZtgcnZP3UCm@redhat.com \
    --to=joe.lawrence@redhat.com \
    --cc=jikos@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    --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