public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Carsten Emde <C.Emde@osadl.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH 1/1] fix-task-states-in-sched_switch-event.patch
Date: Mon, 17 May 2010 14:22:53 +0200	[thread overview]
Message-ID: <1274098973.5605.4695.camel@twins> (raw)
In-Reply-To: <20100516222207.541520625@osadl.org>

On Mon, 2010-05-17 at 00:18 +0200, Carsten Emde wrote:
>  #define TASK_RUNNING           0
> +#define TASK_STATE_0           "R"
> +#define TASK_STATE_NAME_0      "running"
> +
>  #define TASK_INTERRUPTIBLE     1
> +#define TASK_STATE_1           "S"
> +#define TASK_STATE_NAME_1      "sleeping"
> +
>  #define TASK_UNINTERRUPTIBLE   2
> +#define TASK_STATE_2           "D"
> +#define TASK_STATE_NAME_2      "disk sleep"
> +
>  #define __TASK_STOPPED         4
> +#define TASK_STATE_4           "T"
> +#define TASK_STATE_NAME_4      "stopped"
> +
>  #define __TASK_TRACED          8
> +#define TASK_STATE_8           "t"
> +#define TASK_STATE_NAME_8      "tracing stop"
> +
>  /* in tsk->exit_state */
>  #define EXIT_ZOMBIE            16
> +#define TASK_STATE_16          "Z"
> +#define TASK_STATE_NAME_16     "zombie"
> +
>  #define EXIT_DEAD              32
> +#define TASK_STATE_32          "X"
> +#define TASK_STATE_NAME_32     "dead"
> +
>  /* in tsk->state again */
>  #define TASK_DEAD              64
> +#define TASK_STATE_64          "x"
> +#define TASK_STATE_NAME_64     "dead"
> +
>  #define TASK_WAKEKILL          128
> +#define TASK_STATE_128         "K"
> +#define TASK_STATE_NAME_128    "wakekill"
> +
>  #define TASK_WAKING            256
> +#define TASK_STATE_256         "W"
> +#define TASK_STATE_NAME_256    "waking"

Since we all love vile macro magic, is the below any better?

include/linux/task_states.h

TASK_STATE(RUNNING, "R", "running")
TASK_STATE(INTERRUPTIBLE, "S", "sleeping")
...

include/linux/sched.h

enum {
#define TASK_STATE(tstate, tstate_c, tstate_s) __TASK_##tstate,
#include <linux/task_states.h>
#undef TASK_STATE
};

enum {
#define TASK_STATE(tstate, tstate_c, tstate_s) \
	TASK_##tstate = 1 << __TASK_##tstate,
#include <linux/task_states.h>
#undef TASK_STATE
};

const char *task_state_to_char =
#define TASK_STATE(tstate, tstate_c, tstate_s) tstate_c
#include <linux/task_states.h>
#undef TASK_STATE
;

const char *task_state_to_string[] = {
#define TASK_STATE(tstate, tstate_c, tstate_s) tstate_s,
#include <linux/task_states.h>
#undef TASK_STATE
};



  reply	other threads:[~2010-05-17 12:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-16 22:18 [PATCH 0/1] tracing/sched: Fix task states in sched_switch event Carsten Emde
2010-05-16 22:18 ` [PATCH 1/1] fix-task-states-in-sched_switch-event.patch Carsten Emde
2010-05-17 12:22   ` Peter Zijlstra [this message]
2010-05-17 15:21     ` Carsten Emde
2010-05-17 16:54       ` Peter Zijlstra
2010-05-17 17:27         ` Carsten Emde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274098973.5605.4695.camel@twins \
    --to=peterz@infradead.org \
    --cc=C.Emde@osadl.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox