Live Patching
 help / color / mirror / Atom feed
From: Miroslav Benes <mbenes@suse.cz>
To: Wardenjohn <zhangwarden@gmail.com>
Cc: jpoimboe@kernel.org, jikos@kernel.org, pmladek@suse.com,
	 joe.lawrence@redhat.com, live-patching@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH] livepatch: introduce 'stack_order' sysfs interface to klp_patch
Date: Fri, 27 Sep 2024 16:11:02 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LSU.2.21.2409271555430.15317@pobox.suse.cz> (raw)
In-Reply-To: <20240925064047.95503-2-zhangwarden@gmail.com>

Hi,

I would change the subject to something like

"livepatch: Add "stack_order" sysfs attribute"

to keep it somehow consistent with what we have there so far.

On Wed, 25 Sep 2024, Wardenjohn wrote:

> This feature can provide livepatch patch order information.
> With the order of sysfs interface of one klp_patch, we can
> use patch order to find out which function of the patch is
> now activate.
> 
> After the discussion, we decided that patch-level sysfs
> interface is the only accaptable way to introduce this
> information.
> 
> This feature is like:
> cat /sys/kernel/livepatch/livepatch_1/stack_order -> 1
> means this livepatch_1 module is the 1st klp patch applied.
> 
> cat /sys/kernel/livepatch/livepatch_module/stack_order -> N
> means this lviepatch_module is the Nth klp patch applied
> to the system.

Perhaps something like

"
Add "stack_order" sysfs attribute which holds the order in which a live 
patch module was loaded into the system. A user can then determine an 
active live patched version of a function.

 cat /sys/kernel/livepatch/livepatch_1/stack_order -> 1

 means that livepatch_1 is the first live patch applied

 cat /sys/kernel/livepatch/livepatch_module/stack_order -> N

 means that livepatch_module is the Nth live patch applied
"
?

> Suggested-by: Petr Mladek <pmladek@suse.com>
> Suggested-by: Miroslav Benes <mbenes@suse.cz>
> Suggested-by: Josh Poimboeuf <jpoimboe@kernel.org>
> Signed-off-by: Wardenjohn <zhangwarden@gmail.com>
 
How do you prepare your patches?

"---" delimiter is missing here.

> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index ecbc9b6aba3a..914b7cabf8fe 100644
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -346,6 +346,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,
>   * /sys/kernel/livepatch/<patch>/enabled
>   * /sys/kernel/livepatch/<patch>/transition
>   * /sys/kernel/livepatch/<patch>/force
> + * /sys/kernel/livepatch/<patch>/stack_order
>   * /sys/kernel/livepatch/<patch>/<object>
>   * /sys/kernel/livepatch/<patch>/<object>/patched
>   * /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
> @@ -443,13 +444,37 @@ static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr,
>  	return count;
>  }
>  
> +static ssize_t stack_order_show(struct kobject *kobj,
> +				struct kobj_attribute *attr, char *buf)
> +{
> +	struct klp_patch *patch, *this_patch;
> +	int stack_order = 0;
> +
> +	this_patch = container_of(kobj, struct klp_patch, kobj);
> +
> +	/* make sure the calculate of patch order correct */

The comment is not necessary.

> +	mutex_lock(&klp_mutex);
> +
> +	klp_for_each_patch(patch) {
> +		stack_order++;
> +		if (patch == this_patch)
> +			break;
> +	}
> +
> +	mutex_unlock(&klp_mutex);

Please add an empty line before return here.

>+       return sysfs_emit(buf, "%d\n", stack_order);
>+}

Miroslav

  reply	other threads:[~2024-09-27 14:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25  6:40 [PATCH 0/2] livepatch: introduce 'stack_order' sysfs interface to klp_patch Wardenjohn
2024-09-25  6:40 ` [PATCH] " Wardenjohn
2024-09-27 14:11   ` Miroslav Benes [this message]
2024-09-29  1:51     ` zhang warden
2024-09-29 14:47     ` zhang warden
2024-09-25  6:40 ` [PATCH] Documentation: Add description to stack_order interface Wardenjohn
2024-09-27 13:49   ` Miroslav Benes
2024-09-25 13:08 ` [PATCH 0/2] livepatch: introduce 'stack_order' sysfs interface to klp_patch Marcos Paulo de Souza
2024-09-26 11:23   ` zhang warden

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=alpine.LSU.2.21.2409271555430.15317@pobox.suse.cz \
    --to=mbenes@suse.cz \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=zhangwarden@gmail.com \
    /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