[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdV_hZ-uMmKdqEutLL5+XkhhcKdSaurMUS2N46AhZwDNKQ@mail.gmail.com>
Date: Wed, 14 Aug 2019 13:26:43 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Mark Rutland <mark.rutland@....com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Andi Kleen <ak@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Borislav Petkov <bp@...e.de>,
Catalin Marinas <catalin.marinas@....com>,
"David S. Miller" <davem@...emloft.net>,
Christoph Hellwig <hch@....de>, kan.liang@...el.com,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Rik van Riel <riel@...riel.com>,
Will Deacon <will@...nel.org>
Subject: Re: [PATCH 1/9] sched/core: add is_kthread() helper
Hi Mark,
On Wed, Aug 14, 2019 at 12:43 PM Mark Rutland <mark.rutland@....com> wrote:
> Code checking whether a task is a kthread isn't very consistent. Some
> code correctly tests task->flags & PF_THREAD, while other code checks
> task->mm (which can be true for a kthread which calls use_mm()).
>
> So that we can clean this up and keep the code easy to follow, let's add
> an obvious helper function to test whether a task is a kthread.
> Subsequent patches will use this as part of cleaning up and correcting
> open-coded tests.
>
> At the same time, let's fix up the kerneldoc for is_idle_task() for
> consistency with the new helper, using true/false rather than 0/1, given
> the functions return bool.
>
> Signed-off-by: Mark Rutland <mark.rutland@....com>
Thanks for your patch!
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1621,13 +1621,24 @@ extern struct task_struct *idle_task(int cpu);
> * is_idle_task - is the specified task an idle task?
> * @p: the task in question.
> *
> - * Return: 1 if @p is an idle task. 0 otherwise.
> + * Return: true if @p is an idle task, false otherwise.
> */
> static inline bool is_idle_task(const struct task_struct *p)
> {
> return !!(p->flags & PF_IDLE);
> }
>
> +/**
> + * is_kthread - is the specified task a kthread
> + * @p: the task in question.
> + *
> + * Return: true if @p is a kthread, false otherwise.
> + */
> +static inline bool is_kthread(const struct task_struct *p)
> +{
> + return !!(p->flags & PF_KTHREAD);
The !! is not really needed.
Probably you followed is_idle_task() above (where it's also not needed).
> +}
> +
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists