linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] fixed dump_backtrace() when task running on another cpu
@ 2020-04-13 12:04 Wang Qing
  2020-04-13 12:04 ` [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu Wang Qing
  2020-04-13 12:04 ` [PATCH 2/2] [V2 2/2]ARM64:fixed dump_backtrace() when task running on another cpu Wang Qing
  0 siblings, 2 replies; 6+ messages in thread
From: Wang Qing @ 2020-04-13 12:04 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman, James Morse, Mark Rutland,
	Eric W. Biederman, Thomas Gleixner, jinho lim, Wang Qing,
	Dave Martin, linux-arm-kernel, linux-kernel
  Cc: opensource.kernel

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(+)

-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
  2020-04-13 12:04 [PATCH 0/2] fixed dump_backtrace() when task running on another cpu Wang Qing
@ 2020-04-13 12:04 ` Wang Qing
  2020-04-14  7:20   ` Vincent Guittot
  2020-04-15  8:34   ` Wang Qing
  2020-04-13 12:04 ` [PATCH 2/2] [V2 2/2]ARM64:fixed dump_backtrace() when task running on another cpu Wang Qing
  1 sibling, 2 replies; 6+ messages in thread
From: Wang Qing @ 2020-04-13 12:04 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman, James Morse, Mark Rutland,
	Eric W. Biederman, Thomas Gleixner, jinho lim, Wang Qing,
	Dave Martin, linux-arm-kernel, linux-kernel
  Cc: opensource.kernel

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 <wangqing@vivo.com>
---
 include/linux/sched.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4418f5c..13cc8f5 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -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 */
 
 /*
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] [V2 2/2]ARM64:fixed dump_backtrace() when task running on another cpu
  2020-04-13 12:04 [PATCH 0/2] fixed dump_backtrace() when task running on another cpu Wang Qing
  2020-04-13 12:04 ` [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu Wang Qing
@ 2020-04-13 12:04 ` Wang Qing
  1 sibling, 0 replies; 6+ messages in thread
From: Wang Qing @ 2020-04-13 12:04 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman, James Morse, Mark Rutland,
	Eric W. Biederman, Thomas Gleixner, jinho lim, Wang Qing,
	Dave Martin, linux-arm-kernel, linux-kernel
  Cc: opensource.kernel

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.

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 arch/arm64/kernel/traps.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index cf402be..831b8fd 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -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
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
  2020-04-13 12:04 ` [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu Wang Qing
@ 2020-04-14  7:20   ` Vincent Guittot
  2020-04-14 10:05     ` Peter Zijlstra
  2020-04-15  8:34   ` Wang Qing
  1 sibling, 1 reply; 6+ messages in thread
From: Vincent Guittot @ 2020-04-14  7:20 UTC (permalink / raw)
  To: Wang Qing
  Cc: Juri Lelli, Mark Rutland, opensource.kernel, Peter Zijlstra,
	Catalin Marinas, linux-kernel, Steven Rostedt, Dave Martin,
	Ben Segall, jinho lim, Ingo Molnar, James Morse, Mel Gorman,
	Thomas Gleixner, Will Deacon, Dietmar Eggemann, LAK,
	Eric W. Biederman

On Mon, 13 Apr 2020 at 14:04, Wang Qing <wangqing@vivo.com> wrote:
>
> 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 <wangqing@vivo.com>
> ---
>  include/linux/sched.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 4418f5c..13cc8f5 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -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() ?

> +{
> +       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
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
  2020-04-14  7:20   ` Vincent Guittot
@ 2020-04-14 10:05     ` Peter Zijlstra
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2020-04-14 10:05 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: Juri Lelli, Ben Segall, Thomas Gleixner, opensource.kernel,
	Catalin Marinas, linux-kernel, Steven Rostedt, Dave Martin,
	Wang Qing, jinho lim, Ingo Molnar, James Morse, Mel Gorman,
	Mark Rutland, Will Deacon, Dietmar Eggemann, LAK,
	Eric W. Biederman

On Tue, Apr 14, 2020 at 09:20:57AM +0200, Vincent Guittot wrote:
> On Mon, 13 Apr 2020 at 14:04, Wang Qing <wangqing@vivo.com> wrote:
> >
> > 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 <wangqing@vivo.com>
> > ---
> >  include/linux/sched.h | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/include/linux/sched.h b/include/linux/sched.h
> > index 4418f5c..13cc8f5 100644
> > --- a/include/linux/sched.h
> > +++ b/include/linux/sched.h
> > @@ -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() ?

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
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu
  2020-04-13 12:04 ` [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu Wang Qing
  2020-04-14  7:20   ` Vincent Guittot
@ 2020-04-15  8:34   ` Wang Qing
  1 sibling, 0 replies; 6+ messages in thread
From: Wang Qing @ 2020-04-15  8:34 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel

>On Tue, Apr 14, 2020 at 09:20:57AM +0200, Vincent Guittot wrote:
>> On Mon, 13 Apr 2020 at 14:04, Wang Qing <wangqing@vivo.com> wrote:
>> >
>> > 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 <wangqing@vivo.com>
>> > ---
>> >  include/linux/sched.h | 10 ++++++++++
>> >  1 file changed, 10 insertions(+)
>> >
>> > diff --git a/include/linux/sched.h b/include/linux/sched.h
>> > index 4418f5c..13cc8f5 100644
>> > --- a/include/linux/sched.h
>> > +++ b/include/linux/sched.h
>> > @@ -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() ?
>
>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
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-15  8:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 12:04 [PATCH 0/2] fixed dump_backtrace() when task running on another cpu Wang Qing
2020-04-13 12:04 ` [PATCH 1/2] [V2 1/2]sched:add task_running_oncpu Wang Qing
2020-04-14  7:20   ` Vincent Guittot
2020-04-14 10:05     ` Peter Zijlstra
2020-04-15  8:34   ` Wang Qing
2020-04-13 12:04 ` [PATCH 2/2] [V2 2/2]ARM64:fixed dump_backtrace() when task running on another cpu Wang Qing

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).