* [PATCH V5 0/1] livepatch: Add "stack_order" sysfs attribute
@ 2024-10-08 1:47 Wardenjohn
0 siblings, 0 replies; 7+ messages in thread
From: Wardenjohn @ 2024-10-08 1:47 UTC (permalink / raw)
To: jpoimboe, mbenes, jikos, pmladek, joe.lawrence
Cc: live-patching, linux-kernel
As previous discussion, maintainers think that patch-level sysfs interface is the
only acceptable way to maintain the information of the order that klp_patch is
applied to the system.
However, the previous patch introduce klp_ops into klp_func is a optimization
methods of the patch introducing 'using' feature to klp_func.
But now, we don't support 'using' feature to klp_func and make 'klp_ops' patch
not necessary.
Therefore, this new version is only introduce the sysfs feature of klp_patch
'stack_order'.
V1 -> V2:
1. According to the suggestion from Petr, to make the meaning more clear, rename
'order' to 'stack_order'.
2. According to the suggestion from Petr and Miroslav, this patch now move the
calculating process to stack_order_show function. Adding klp_mutex lock protection.
V2 -> V3:
1. Squash 2 patches into 1. Update description of stack_order in ABI Document.
(Suggested by Miroslav)
2. Update subject and commit log. (Suggested by Miroslav)
3. Update code format for some line of the patch. (Suggested by Miroslav)
V3 -> V4:
1. Rebase the patch of to branch linux-master.
2. Update the description of ABI Document Description. (Suggested by Petr & Josh)
V4 -> V5:
1. Fix the typos from 'module' to 'modules' (found by Josh)
Regards.
Wardenjohn.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V5 0/1] livepatch: Add "stack_order" sysfs attribute
@ 2024-10-08 1:48 Wardenjohn
2024-10-08 1:48 ` [PATCH V5 1/1] livepatch: Add stack_order " Wardenjohn
0 siblings, 1 reply; 7+ messages in thread
From: Wardenjohn @ 2024-10-08 1:48 UTC (permalink / raw)
To: jpoimboe, mbenes, jikos, pmladek, joe.lawrence
Cc: live-patching, linux-kernel
As previous discussion, maintainers think that patch-level sysfs interface is the
only acceptable way to maintain the information of the order that klp_patch is
applied to the system.
However, the previous patch introduce klp_ops into klp_func is a optimization
methods of the patch introducing 'using' feature to klp_func.
But now, we don't support 'using' feature to klp_func and make 'klp_ops' patch
not necessary.
Therefore, this new version is only introduce the sysfs feature of klp_patch
'stack_order'.
V1 -> V2:
1. According to the suggestion from Petr, to make the meaning more clear, rename
'order' to 'stack_order'.
2. According to the suggestion from Petr and Miroslav, this patch now move the
calculating process to stack_order_show function. Adding klp_mutex lock protection.
V2 -> V3:
1. Squash 2 patches into 1. Update description of stack_order in ABI Document.
(Suggested by Miroslav)
2. Update subject and commit log. (Suggested by Miroslav)
3. Update code format for some line of the patch. (Suggested by Miroslav)
V3 -> V4:
1. Rebase the patch of to branch linux-master.
2. Update the description of ABI Document Description. (Suggested by Petr & Josh)
V4 -> V5:
1. Fix the typos from 'module' to 'modules' (found by Josh)
Regards.
Wardenjohn.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V5 1/1] livepatch: Add stack_order sysfs attribute
2024-10-08 1:48 [PATCH V5 0/1] livepatch: Add "stack_order" sysfs attribute Wardenjohn
@ 2024-10-08 1:48 ` Wardenjohn
2024-10-08 17:17 ` Josh Poimboeuf
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Wardenjohn @ 2024-10-08 1:48 UTC (permalink / raw)
To: jpoimboe, mbenes, jikos, pmladek, joe.lawrence
Cc: live-patching, linux-kernel, Wardenjohn
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>
---
.../ABI/testing/sysfs-kernel-livepatch | 9 +++++++
kernel/livepatch/core.c | 24 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-kernel-livepatch b/Documentation/ABI/testing/sysfs-kernel-livepatch
index 3735d868013d..73e40d02345e 100644
--- a/Documentation/ABI/testing/sysfs-kernel-livepatch
+++ b/Documentation/ABI/testing/sysfs-kernel-livepatch
@@ -55,6 +55,15 @@ Description:
An attribute which indicates whether the patch supports
atomic-replace.
+What: /sys/kernel/livepatch/<patch>/stack_order
+Date: Oct 2024
+KernelVersion: 6.13.0
+Description:
+ This attribute specifies the sequence in which live patch modules
+ are applied to the system. If multiple live patches modify the same
+ function, the implementation with the biggest 'stack_order' number
+ is used, unless a transition is currently in progress.
+
What: /sys/kernel/livepatch/<patch>/<object>
Date: Nov 2014
KernelVersion: 3.19.0
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 3c21c31796db..0cd39954d5a1 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -347,6 +347,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,
* /sys/kernel/livepatch/<patch>/transition
* /sys/kernel/livepatch/<patch>/force
* /sys/kernel/livepatch/<patch>/replace
+ * /sys/kernel/livepatch/<patch>/stack_order
* /sys/kernel/livepatch/<patch>/<object>
* /sys/kernel/livepatch/<patch>/<object>/patched
* /sys/kernel/livepatch/<patch>/<object>/<function,sympos>
@@ -452,15 +453,38 @@ static ssize_t replace_show(struct kobject *kobj,
return sysfs_emit(buf, "%d\n", patch->replace);
}
+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);
+
+ mutex_lock(&klp_mutex);
+
+ klp_for_each_patch(patch) {
+ stack_order++;
+ if (patch == this_patch)
+ break;
+ }
+
+ mutex_unlock(&klp_mutex);
+
+ return sysfs_emit(buf, "%d\n", stack_order);
+}
+
static struct kobj_attribute enabled_kobj_attr = __ATTR_RW(enabled);
static struct kobj_attribute transition_kobj_attr = __ATTR_RO(transition);
static struct kobj_attribute force_kobj_attr = __ATTR_WO(force);
static struct kobj_attribute replace_kobj_attr = __ATTR_RO(replace);
+static struct kobj_attribute stack_order_kobj_attr = __ATTR_RO(stack_order);
static struct attribute *klp_patch_attrs[] = {
&enabled_kobj_attr.attr,
&transition_kobj_attr.attr,
&force_kobj_attr.attr,
&replace_kobj_attr.attr,
+ &stack_order_kobj_attr.attr,
NULL
};
ATTRIBUTE_GROUPS(klp_patch);
--
2.18.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V5 1/1] livepatch: Add stack_order sysfs attribute
2024-10-08 1:48 ` [PATCH V5 1/1] livepatch: Add stack_order " Wardenjohn
@ 2024-10-08 17:17 ` Josh Poimboeuf
2024-10-11 8:55 ` Petr Mladek
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Josh Poimboeuf @ 2024-10-08 17:17 UTC (permalink / raw)
To: Wardenjohn
Cc: mbenes, jikos, pmladek, joe.lawrence, live-patching, linux-kernel
On Tue, Oct 08, 2024 at 09:48:56AM +0800, Wardenjohn wrote:
> 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>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
--
Josh
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5 1/1] livepatch: Add stack_order sysfs attribute
2024-10-08 1:48 ` [PATCH V5 1/1] livepatch: Add stack_order " Wardenjohn
2024-10-08 17:17 ` Josh Poimboeuf
@ 2024-10-11 8:55 ` Petr Mladek
2024-10-11 11:20 ` Miroslav Benes
2024-12-09 12:28 ` Petr Mladek
3 siblings, 0 replies; 7+ messages in thread
From: Petr Mladek @ 2024-10-11 8:55 UTC (permalink / raw)
To: Wardenjohn
Cc: jpoimboe, mbenes, jikos, joe.lawrence, live-patching,
linux-kernel
On Tue 2024-10-08 09:48:56, Wardenjohn wrote:
> 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>
Looks and works fine:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
PS: I'll wait for the selftest before pushing this change.
It would be nice to send both patches together in a single
thread.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5 1/1] livepatch: Add stack_order sysfs attribute
2024-10-08 1:48 ` [PATCH V5 1/1] livepatch: Add stack_order " Wardenjohn
2024-10-08 17:17 ` Josh Poimboeuf
2024-10-11 8:55 ` Petr Mladek
@ 2024-10-11 11:20 ` Miroslav Benes
2024-12-09 12:28 ` Petr Mladek
3 siblings, 0 replies; 7+ messages in thread
From: Miroslav Benes @ 2024-10-11 11:20 UTC (permalink / raw)
To: Wardenjohn
Cc: jpoimboe, jikos, pmladek, joe.lawrence, live-patching,
linux-kernel
On Tue, 8 Oct 2024, Wardenjohn wrote:
> 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>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
M
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5 1/1] livepatch: Add stack_order sysfs attribute
2024-10-08 1:48 ` [PATCH V5 1/1] livepatch: Add stack_order " Wardenjohn
` (2 preceding siblings ...)
2024-10-11 11:20 ` Miroslav Benes
@ 2024-12-09 12:28 ` Petr Mladek
3 siblings, 0 replies; 7+ messages in thread
From: Petr Mladek @ 2024-12-09 12:28 UTC (permalink / raw)
To: Wardenjohn
Cc: jpoimboe, mbenes, jikos, joe.lawrence, live-patching,
linux-kernel
On Tue 2024-10-08 09:48:56, Wardenjohn wrote:
> 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>
JFYI, the patch has been comitted into livepatching.git,
branch for-6.14/stack-order.
Note that I have updated the version in the ABI
documentation to 6.14.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-12-09 12:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 1:48 [PATCH V5 0/1] livepatch: Add "stack_order" sysfs attribute Wardenjohn
2024-10-08 1:48 ` [PATCH V5 1/1] livepatch: Add stack_order " Wardenjohn
2024-10-08 17:17 ` Josh Poimboeuf
2024-10-11 8:55 ` Petr Mladek
2024-10-11 11:20 ` Miroslav Benes
2024-12-09 12:28 ` Petr Mladek
-- strict thread matches above, loose matches on Subject: below --
2024-10-08 1:47 [PATCH V5 0/1] livepatch: Add "stack_order" " Wardenjohn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).