linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/debug: use symbolic names for task state constants
@ 2018-09-05  9:36 Uwe Kleine-König
  2018-09-05 11:25 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2018-09-05  9:36 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Sebastian Andrzej Siewior, Thomas Gleixner
  Cc: linux-kernel, kernel

include/trace/events/sched.h includes <linux/sched.h> (via
<linux/sched/numa_balancing.h>) and so knows about the TASK_* constants
used to interpret .prev_state. So instead of duplicating the magic
numbers make use of the defined macros to ease understanding the
mapping from state bits to letters which isn't completely intuitive for
an outsider.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 include/trace/events/sched.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 0be866c91f62..f07b270d4fc4 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -159,9 +159,14 @@ TRACE_EVENT(sched_switch,
 
 		(__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
 		  __print_flags(__entry->prev_state & (TASK_REPORT_MAX - 1), "|",
-				{ 0x01, "S" }, { 0x02, "D" }, { 0x04, "T" },
-				{ 0x08, "t" }, { 0x10, "X" }, { 0x20, "Z" },
-				{ 0x40, "P" }, { 0x80, "I" }) :
+				{ TASK_INTERRUPTIBLE, "S" },
+				{ TASK_UNINTERRUPTIBLE, "D" },
+				{ __TASK_STOPPED, "T" },
+				{ __TASK_TRACED, "t" },
+				{ EXIT_DEAD, "X" },
+				{ EXIT_ZOMBIE, "Z" },
+				{ TASK_PARKED, "P" },
+				{ TASK_DEAD, "I" }) :
 		  "R",
 
 		__entry->prev_state & TASK_REPORT_MAX ? "+" : "",
-- 
2.18.0


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

* Re: [PATCH] sched/debug: use symbolic names for task state constants
  2018-09-05  9:36 [PATCH] sched/debug: use symbolic names for task state constants Uwe Kleine-König
@ 2018-09-05 11:25 ` Peter Zijlstra
  2018-09-05 12:23   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2018-09-05 11:25 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Ingo Molnar, Sebastian Andrzej Siewior, Thomas Gleixner,
	linux-kernel, kernel, Steven Rostedt

On Wed, Sep 05, 2018 at 11:36:36AM +0200, Uwe Kleine-König wrote:
> include/trace/events/sched.h includes <linux/sched.h> (via
> <linux/sched/numa_balancing.h>) and so knows about the TASK_* constants
> used to interpret .prev_state. So instead of duplicating the magic
> numbers make use of the defined macros to ease understanding the
> mapping from state bits to letters which isn't completely intuitive for
> an outsider.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  include/trace/events/sched.h | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
> index 0be866c91f62..f07b270d4fc4 100644
> --- a/include/trace/events/sched.h
> +++ b/include/trace/events/sched.h
> @@ -159,9 +159,14 @@ TRACE_EVENT(sched_switch,
>  
>  		(__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
>  		  __print_flags(__entry->prev_state & (TASK_REPORT_MAX - 1), "|",
> -				{ 0x01, "S" }, { 0x02, "D" }, { 0x04, "T" },
> -				{ 0x08, "t" }, { 0x10, "X" }, { 0x20, "Z" },
> -				{ 0x40, "P" }, { 0x80, "I" }) :
> +				{ TASK_INTERRUPTIBLE, "S" },
> +				{ TASK_UNINTERRUPTIBLE, "D" },
> +				{ __TASK_STOPPED, "T" },
> +				{ __TASK_TRACED, "t" },
> +				{ EXIT_DEAD, "X" },
> +				{ EXIT_ZOMBIE, "Z" },
> +				{ TASK_PARKED, "P" },
> +				{ TASK_DEAD, "I" }) :
>  		  "R",

Steve, does this work?

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

* Re: [PATCH] sched/debug: use symbolic names for task state constants
  2018-09-05 11:25 ` Peter Zijlstra
@ 2018-09-05 12:23   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2018-09-05 12:23 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Uwe Kleine-König, Ingo Molnar, Sebastian Andrzej Siewior,
	Thomas Gleixner, linux-kernel, kernel

On Wed, 5 Sep 2018 13:25:24 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> On Wed, Sep 05, 2018 at 11:36:36AM +0200, Uwe Kleine-König wrote:
> > include/trace/events/sched.h includes <linux/sched.h> (via
> > <linux/sched/numa_balancing.h>) and so knows about the TASK_* constants
> > used to interpret .prev_state. So instead of duplicating the magic
> > numbers make use of the defined macros to ease understanding the
> > mapping from state bits to letters which isn't completely intuitive for
> > an outsider.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> >  include/trace/events/sched.h | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
> > index 0be866c91f62..f07b270d4fc4 100644
> > --- a/include/trace/events/sched.h
> > +++ b/include/trace/events/sched.h
> > @@ -159,9 +159,14 @@ TRACE_EVENT(sched_switch,
> >  
> >  		(__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
> >  		  __print_flags(__entry->prev_state & (TASK_REPORT_MAX - 1), "|",
> > -				{ 0x01, "S" }, { 0x02, "D" }, { 0x04, "T" },
> > -				{ 0x08, "t" }, { 0x10, "X" }, { 0x20, "Z" },
> > -				{ 0x40, "P" }, { 0x80, "I" }) :
> > +				{ TASK_INTERRUPTIBLE, "S" },
> > +				{ TASK_UNINTERRUPTIBLE, "D" },
> > +				{ __TASK_STOPPED, "T" },
> > +				{ __TASK_TRACED, "t" },
> > +				{ EXIT_DEAD, "X" },
> > +				{ EXIT_ZOMBIE, "Z" },
> > +				{ TASK_PARKED, "P" },
> > +				{ TASK_DEAD, "I" }) :
> >  		  "R",  
> 
> Steve, does this work?

As long as the text is preprocessor macros (which they appear to be),
then yeah, this shouldn't cause any harm. If they were enums, then it
would require a little more work.

-- Steve


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

end of thread, other threads:[~2018-09-05 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-05  9:36 [PATCH] sched/debug: use symbolic names for task state constants Uwe Kleine-König
2018-09-05 11:25 ` Peter Zijlstra
2018-09-05 12:23   ` Steven Rostedt

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