From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Matthew Wilcox <matthew@wil.cx>
Cc: linux-kernel@vger.kernel.org, Matthew Wilcox <willy@linux.intel.com>
Subject: Re: [PATCH 2/5] Use macros instead of TASK_ flags
Date: Thu, 25 Oct 2007 13:50:43 +1000 [thread overview]
Message-ID: <200710251350.43281.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <11927463622621-git-send-email-matthew@wil.cx>
On Friday 19 October 2007 08:25, Matthew Wilcox wrote:
> Abstracting away direct uses of TASK_ flags allows us to change the
> definitions of the task flags more easily.
>
> Also restructure do_wait() a little
>
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
> ---
> arch/ia64/kernel/perfmon.c | 4 +-
> fs/proc/array.c | 9 +---
> fs/proc/base.c | 2 +-
> include/linux/sched.h | 15 +++++++
> include/linux/wait.h | 11 +++--
> kernel/exit.c | 90
> +++++++++++++++++++------------------------ kernel/power/process.c |
> 7 +--
> kernel/ptrace.c | 8 ++--
> kernel/sched.c | 15 +++----
> kernel/signal.c | 6 +-
> kernel/wait.c | 2 +-
> 11 files changed, 83 insertions(+), 86 deletions(-)
>
> diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
> index f55fa07..6b0a6cf 100644
> --- a/arch/ia64/kernel/perfmon.c
> +++ b/arch/ia64/kernel/perfmon.c
> @@ -2630,7 +2630,7 @@ pfm_task_incompatible(pfm_context_t *ctx, struct
> task_struct *task) */
> if (task == current) return 0;
>
> - if ((task->state != TASK_STOPPED) && (task->state != TASK_TRACED)) {
> + if (!is_task_stopped_or_traced(task)) {
> DPRINT(("cannot attach to non-stopped task [%d] state=%ld\n", task->pid,
> task->state)); return -EBUSY;
> }
> @@ -4790,7 +4790,7 @@ recheck:
> * the task must be stopped.
> */
> if (PFM_CMD_STOPPED(cmd)) {
> - if ((task->state != TASK_STOPPED) && (task->state != TASK_TRACED)) {
> + if (!is_task_stopped_or_traced(task)) {
> DPRINT(("[%d] task not in stopped state\n", task->pid));
> return -EBUSY;
> }
> diff --git a/fs/proc/array.c b/fs/proc/array.c
> index 27b59f5..8939bf0 100644
> --- a/fs/proc/array.c
> +++ b/fs/proc/array.c
> @@ -140,13 +140,8 @@ static const char *task_state_array[] = {
>
> static inline const char *get_task_state(struct task_struct *tsk)
> {
> - unsigned int state = (tsk->state & (TASK_RUNNING |
> - TASK_INTERRUPTIBLE |
> - TASK_UNINTERRUPTIBLE |
> - TASK_STOPPED |
> - TASK_TRACED)) |
> - (tsk->exit_state & (EXIT_ZOMBIE |
> - EXIT_DEAD));
> + unsigned int state = (tsk->state & TASK_REPORT) |
> + (tsk->exit_state & (EXIT_ZOMBIE | EXIT_DEAD));
> const char **p = &task_state_array[0];
>
> while (state) {
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 4fe74d1..e7e1815 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -196,7 +196,7 @@ static int proc_root_link(struct inode *inode, struct
> dentry **dentry, struct vf (task == current || \
> (task->parent == current && \
> (task->ptrace & PT_PTRACED) && \
> - (task->state == TASK_STOPPED || task->state == TASK_TRACED) && \
> + (is_task_stopped_or_traced(task)) && \
> security_ptrace(current,task) == 0))
>
> static int proc_pid_cmdline(struct task_struct *task, char * buffer)
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index c204ab0..5ef5253 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -177,6 +177,21 @@ print_cfs_rq(struct seq_file *m, int cpu, struct
> cfs_rq *cfs_rq) /* in tsk->state again */
> #define TASK_DEAD 64
>
> +/* Convenience macros for the sake of wake_up */
> +#define TASK_NORMAL (TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE)
> +#define TASK_ALL (TASK_NORMAL | TASK_STOPPED | TASK_TRACED)
> +
> +/* get_task_state() */
> +#define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \
> + TASK_UNINTERRUPTIBLE | TASK_STOPPED | \
> + TASK_TRACED)
I think it would be nicer if you made it explicit in the name that
these are not individual flags. Maybe it doesn't matter though...
Also, TASK_NORMAL / TASK_ALL aren't very good names. TASK_SLEEP_NORMAL
TASK_SLEEP_ALL might be a bit more helpful?
next prev parent reply other threads:[~2007-10-25 3:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-18 22:25 [PATCH 0/5] TASK_KILLABLE Matthew Wilcox
2007-10-18 22:25 ` [PATCH 1/5] Use wake_up_locked() in eventpoll Matthew Wilcox
2007-10-19 3:56 ` Arjan van de Ven
2007-10-19 16:28 ` Matthew Wilcox
2007-10-18 22:25 ` [PATCH 2/5] Use macros instead of TASK_ flags Matthew Wilcox
2007-10-25 3:50 ` Nick Piggin [this message]
2007-10-18 22:26 ` [PATCH 3/5] Add TASK_WAKEKILL Matthew Wilcox
2007-10-18 22:26 ` [PATCH 4/5] Add lock_page_killable Matthew Wilcox
2007-10-18 22:26 ` [PATCH 5/5] Make wait_on_retry_sync_kiocb killable Matthew Wilcox
2007-10-25 3:53 ` Nick Piggin
2007-10-25 3:55 ` [PATCH 0/5] TASK_KILLABLE Nick Piggin
-- strict thread matches above, loose matches on Subject: below --
2007-10-24 12:24 [PATCH 1/5] Use wake_up_locked() in eventpoll Matthew Wilcox
2007-10-24 12:24 ` [PATCH 2/5] Use macros instead of TASK_ flags Matthew Wilcox
2007-10-25 3:31 ` Andrew Morton
2007-10-26 18:45 ` Andrew Morton
2007-10-26 20:39 ` Alexey Dobriyan
2007-10-27 0:33 ` Matthew Wilcox
2007-12-05 12:56 ` Ingo Molnar
2007-12-06 14:42 ` Matthew Wilcox
2007-09-02 2:43 [PATCH] TASK_KILLABLE version 2 Matthew Wilcox
2007-09-02 2:46 ` [PATCH 2/5] Use macros instead of TASK_ flags Matthew Wilcox
2007-09-02 2:54 ` Matthew Wilcox
2007-09-02 3:35 ` Daniel Walker
2007-09-02 4:05 ` Matthew Wilcox
2007-09-03 21:03 ` Matthew Wilcox
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=200710251350.43281.nickpiggin@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=willy@linux.intel.com \
/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
Powered by JetHome