Skip to contentSkip to conversation

kernel/events/core: check return value of task_function_call()

PATCH In review Li Zhong 3 participants 3 messages Sep 19, 2022 – Sep 21, 2022

Subsystems (2)
lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH v2 1/1 kernel/events/core: check return value of task_function_call()

From: lily <[email protected]>

Check the return value of task_function_call(), which could be error code when the execution fails. We log this on info level.

---
 kernel/events/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/events/core.c +4 -1
index 2621fd24ad26..3848631b009c 100644
@@ -13520,7 +13520,10 @@ static void perf_cgroup_attach(struct cgroup_taskset *tset)
 	struct cgroup_subsys_state *css;
 
 	cgroup_taskset_for_each(task, css, tset)
-		task_function_call(task, __perf_cgroup_move, task);
+		if (!task_function_call(task, __perf_cgroup_move, task)) {
+			printk(KERN_INFO "perf: this process isn't running!\n");
+			continue;
+		}
 }
 
 struct cgroup_subsys perf_event_cgrp_subsys = {
Signature · 1 line
2.25.1
#1 lore raw
Quoted 15 lines · Li Zhong

From: lily <[email protected]>

Check the return value of task_function_call(), which could be error code when the execution fails. We log this on info level.

---
 kernel/events/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/events/core.c +0 -0
index 2621fd24ad26..3848631b009c 100644

kernel/events/core.c static void perf_cgroup_attach(struct cgroup_taskset *tset) · line 13525

Quoted 7 lines
kernel/events/core.c +3 -1
@@ -13520,7 +13520,10 @@ static void perf_cgroup_attach(struct cgroup_taskset *tset)
 	struct cgroup_subsys_state *css;
 
 	cgroup_taskset_for_each(task, css, tset)
-		task_function_call(task, __perf_cgroup_move, task);
+		if (!task_function_call(task, __perf_cgroup_move, task)) {
+			printk(KERN_INFO "perf: this process isn't running!\n");
+			continue;

If this is a 'should never happen' condition, then this should really be WARN_ON_ONCE().

(If it can happen, then polluting the syslog is wrong.)

Thanks,

Ingo

maintainer
#2 lore raw
Quoted 29 lines · Ingo Molnar
Quoted 15 lines · Li Zhong

From: lily <[email protected]>

Check the return value of task_function_call(), which could be error code when the execution fails. We log this on info level.

---
 kernel/events/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/events/core.c +0 -0
index 2621fd24ad26..3848631b009c 100644

kernel/events/core.c static void perf_cgroup_attach(struct cgroup_taskset *tset) · line 13525

Quoted 7 lines
kernel/events/core.c +3 -1
@@ -13520,7 +13520,10 @@ static void perf_cgroup_attach(struct cgroup_taskset *tset)
 	struct cgroup_subsys_state *css;
 
 	cgroup_taskset_for_each(task, css, tset)
-		task_function_call(task, __perf_cgroup_move, task);
+		if (!task_function_call(task, __perf_cgroup_move, task)) {
+			printk(KERN_INFO "perf: this process isn't running!\n");
+			continue;

If this is a 'should never happen' condition, then this should really be WARN_ON_ONCE().

Quoted 1 line

(If it can happen, then polluting the syslog is wrong.)

It can happen and is just fine. If this task_function_call() fails, it means the context switch that made it fail ensured the new values have been picked up.