[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D229E2D7-31DC-4420-AC78-5146048E6ABE@gmail.com>
Date: Sun, 29 Sep 2024 09:51:12 +0800
From: zhang warden <zhangwarden@...il.com>
To: Miroslav Benes <mbenes@...e.cz>
Cc: Josh Poimboeuf <jpoimboe@...nel.org>,
Jiri Kosina <jikos@...nel.org>,
Petr Mladek <pmladek@...e.com>,
Joe Lawrence <joe.lawrence@...hat.com>,
live-patching@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] livepatch: introduce 'stack_order' sysfs interface to
klp_patch
Hi, Miroslav!
>
> 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@...e.com>
>> Suggested-by: Miroslav Benes <mbenes@...e.cz>
>> Suggested-by: Josh Poimboeuf <jpoimboe@...nel.org>
>> Signed-off-by: Wardenjohn <zhangwarden@...il.com>
>
> How do you prepare your patches?
>
> "---" delimiter is missing here.
I will commit my changes with 'git commit -m' option.
Then, I use 'git format-patch' to generate my patches.
After my patches is ready, I would use 'git send-email' to
send my directory containing my patches and cover letter.
Is there any step I missed?
>
>> 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
And the rest of the suggestions will be fix in the next version.
Regards.
Wardenjohn.
Powered by blists - more mailing lists