fixed dump_backtrace() when task running on another cpu
cover fixed dump_backtrace() when task running on another cpu
We cannot get FP and PC when the task is running on another CPU, task->thread.cpu_context is the last time the task was switched out, it's better to give a reminder than to provide wrong information.
We have no interface whether the task is running, so we need to add an interface and distinguish CONFIG_SMP.
Wang Qing (2):
[V2 1/2]sched:add task_running_oncpu
[V2 2/2]ARM64:fixed dump_backtrace() when task running on another cpu
arch/arm64/kernel/traps.c | 7 +++++++ include/linux/sched.h | 10 ++++++++++ 2 files changed, 17 insertions(+)
Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/2 sched:add task_running_oncpu
We have no interface whether the task is running, so we need to add an interface and distinguish CONFIG_SMP.
--- include/linux/sched.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/sched.h +10 -0
@@ -1843,6 +1843,11 @@ static inline unsigned int task_cpu(const struct task_struct *p)extern void set_task_cpu (struct task_struct *p,unsigned int cpu); +static inline int task_running_oncpu (const struct task_struct *p) +{ +return p->on_cpu; +} +#else static inline unsigned int task_cpu (const struct task_struct *p)
@@ -1854,6 +1859,11 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) { } +static inline int task_running_oncpu (const struct task_struct *p) +{ +return p == current; +} +#endif /* CONFIG_SMP */ /*
Signature · 1 line
2.7.4
Vincent Guittot
maintainerRe: [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
Quoted 14 lines · Wang Qing
We have no interface whether the task is running, so we need to add an interface and distinguish
CONFIG_SMP.Signed-off-by Wang Qing <[email protected]>--- include/linux/sched.h | 10 ++++++++++ 1 file changed, 10 insertions(+)include/linux/sched.h +0
-0
include/linux/sched.h static inline unsigned int task_cpu(const struct task_struct *p) · line 1846
Quoted 4 lines
include/linux/sched.h +1
-0@@ -1843,6 +1843,11 @@ static inline unsigned int task_cpu(const struct task_struct *p)extern void set_task_cpu (struct task_struct *p,unsigned int cpu); +static inline int task_running_oncpu (const struct task_struct *p)
This function name is too close from task_running_on_cpu() and can be misleading as the difference is only "_"
Also, how task_running_oncpu() is different from task_running() ?
Quoted 22 lines
include/linux/sched.h +9
-1+{ +return p->on_cpu; +} +#else static inline unsigned int task_cpu (const struct task_struct *p)@@ -1854,6 +1859,11 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) { } +static inline int task_running_oncpu (const struct task_struct *p) +{ +return p == current; +} +#endif /* CONFIG_SMP */ /* -- 2.7.4
Peter Zijlstra
maintainerRe: [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
Quoted 16 lines · Vincent Guittot
Quoted 15 lines · Wang Qing
We have no interface whether the task is running, so we need to add an interface and distinguish
CONFIG_SMP.Signed-off-by Wang Qing <[email protected]>--- include/linux/sched.h | 10 ++++++++++ 1 file changed, 10 insertions(+)include/linux/sched.h +0
-0@@ -1843,6 +1843,11 @@ static inline unsigned int task_cpu(const struct task_struct *p)
Quoted 7 lines
include/linux/sched.h static inline unsigned int task_cpu(const struct task_struct *p) · line 1846
Quoted 3 lines
include/linux/sched.h +1
-0extern void set_task_cpu (struct task_struct *p,unsigned int cpu); +static inline int task_running_oncpu (const struct task_struct *p)This function name is too close from
task_running_on_cpu()and can be misleading as the difference is only "_"
Also, howtask_running_oncpu()is different fromtask_running()?
It doesn't have the (arguably superfluous) rq argument. But yes, agreed, if anything lift that thing (without the argument).
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
In reply to Wang QingQuoted 16 lines · Wang Qing
Quoted 15 lines
We have no interface whether the task is running, so we need to add an interface and distinguish
CONFIG_SMP.Signed-off-by Wang Qing <[email protected]>--- include/linux/sched.h | 10 ++++++++++ 1 file changed, 10 insertions(+)include/linux/sched.h +0
-0@@ -1843,6 +1843,11 @@ static inline unsigned int task_cpu(const struct task_struct *p)
Quoted 7 lines
include/linux/sched.h static inline unsigned int task_cpu(const struct task_struct *p) · line 1846
Quoted 3 lines
include/linux/sched.h +1
-0extern void set_task_cpu (struct task_struct *p,unsigned int cpu); +static inline int task_running_oncpu (const struct task_struct *p)This function name is too close from
task_running_on_cpu()and can be misleading as the difference is only "_"
Also, howtask_running_oncpu()is different fromtask_running()?
I think task_running() should be renamed to task_running_on_rq(), this is what it originally mean. And the task_running_oncpu I added should be called task_running(). This solves the confusing naming problem that already exists.
Thanks,
Wang Qing.
Quoted 23 lines
Quoted 23 lines
include/linux/sched.h +9
-1+{ +return p->on_cpu; +} +#else static inline unsigned int task_cpu (const struct task_struct *p)@@ -1854,6 +1859,11 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) { } +static inline int task_running_oncpu (const struct task_struct *p) +{ +return p == current; +} +#endif /* CONFIG_SMP */ /* -- 2.7.4
Re: [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
In reply to Wang QingQuoted 19 lines · Vincent Guittot
Quoted 18 lines · Wang Qing
Quoted 17 lines
We have no interface whether the task is running, so we need to add an interface and distinguish
CONFIG_SMP.Signed-off-by Wang Qing <[email protected]>--- include/linux/sched.h | 10 ++++++++++ 1 file changed, 10 insertions(+)include/linux/sched.h +0
-0@@ -1843,6 +1843,11 @@ static inline unsigned int task_cpu(const struct task_struct *p)extern void set_task_cpu (struct task_struct *p,unsigned int cpu);
Quoted 8 lines
Quoted 5 lines
include/linux/sched.h static inline unsigned int task_cpu(const struct task_struct *p) · line 1846
Quoted 1 line
include/linux/sched.h +1
-0+static inline int task_running_oncpu (const struct task_struct *p)This function name is too close from
task_running_on_cpu()and can be misleading as the difference is only "_"
Also, howtask_running_oncpu()is different fromtask_running()?It doesn't have the (arguably superfluous) rq argument. But yes, agreed, if anything lift that thing (without the argument).
I think task_running() should be renamed to task_running_on_rq() like the naming of task_running_on_cpu(), this is what it originally mean, and add task_running() (with the task argument only).
I updated the patch for that.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/2 ARM64:fixed dump_backtrace() when task running on another cpu
In reply to Wang QingWe cannot get FP and PC when the task is running on another CPU, task->thread.cpu_context is the last time the task was switched out, it's better to give a reminder than to provide wrong information.
--- arch/arm64/kernel/traps.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/kernel/traps.c +7 -0
@@ -106,6 +106,13 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)start_backtrace (&frame, (unsigned long )__builtin_frame_address (0 ), (unsigned long )dump_backtrace); + }else if (task_running_oncpu (tsk)) { +/* +* The task is running in another cpu, we cannot get it. +*/ +pr_warn ("tsk: %s is running in CPU%d, Don't call trace!\n" , + tsk->comm,task_cpu (tsk)); +return ; }else {/* * task blocked in __switch_to
Signature · 1 line
2.7.4