From: Steven Rostedt <rostedt@goodmis.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@redhat.com>,
x86@kernel.org, Kees Cook <kees@kernel.org>,
bpf@vger.kernel.org, Tejun Heo <tj@kernel.org>,
Julia Lawall <Julia.Lawall@inria.fr>,
Nicolas Palix <nicolas.palix@imag.fr>,
cocci@inria.fr, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] sched/core: Introduce task_*() helpers for PF_ flags
Date: Sat, 26 Apr 2025 16:06:30 -0400 [thread overview]
Message-ID: <20250426160630.46108366@gandalf.local.home> (raw)
In-Reply-To: <aA0pDUDQViCA1hwi@gmail.com>
On Sat, 26 Apr 2025 20:42:21 +0200
Ingo Molnar <mingo@kernel.org> wrote:
> > kernel/sched/core.c: if (!curr->mm || (curr->flags & (PF_EXITING | PF_KTHREAD)) ||
> > kernel/sched/fair.c: if (!curr->mm || (curr->flags & (PF_EXITING | PF_KTHREAD)) || work->next != work)
> > kernel/trace/bpf_trace.c: current->flags & (PF_KTHREAD | PF_EXITING)))
> > kernel/trace/bpf_trace.c: if (unlikely(task->flags & (PF_KTHREAD | PF_EXITING)))
> >
> > Maybe we can have a: is_user_exiting_or_kthread() ?
>
> No, we don't need is_user_exiting_or_kthread(). At all. Ever. In this
> universe. Or in any alternative universes. We don't even need
> is_user_exiting_or_kthread() in horror fiction novels written for
> kernel developers: there's really a limit to the level of horror that
> people are able to accept. Sheesh ...
Ingo,
A simple "No we do not need that" would suffice. This isn't 2005 anymore,
where we come up with creative ways to insult each other. We're better now.
> And no, we don't need separate helpers for !task_kthread() et al: the C
> logical negation unary operator is perfectly readable when placed
> before a function call or a macro invocation, and a competent Linux
> kernel developer is expected to recognize it on sight:
>
> if (!task_kthread(task))
> ...
Not really. I originally tried just having a single "is_kernel_thread()"
where I would use the "!is_kernel_thread()" for user thread, but honestly,
it wasn't much better than the "!(task->flags & PF_KTHREAD)".
And just because it's not a kernel thread, does it mean it will always be a
user space thread? Could it one day also be a guest thread (if we decide to
have such a thing)?
Wanting to know if something is a user space thread, "if (!task_kthread(task))"
seems short sighted. As it assumes that we only have two types of threads.
It may be true today, but may not be the case in the future.
if (!task_kthread(task))
Still takes a second more to understand that's a user space thread than:
if (task_user(task))
would.
-- Steve
next prev parent reply other threads:[~2025-04-26 20:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-25 20:41 [RFC][PATCH 0/2] Add is_user_thread() and is_kernel_thread() helper functions Steven Rostedt
2025-04-25 20:41 ` [RFC][PATCH 1/2] kthread: " Steven Rostedt
2025-04-25 23:03 ` Kees Cook
2025-04-26 12:36 ` Steven Rostedt
2025-04-26 11:08 ` Borislav Petkov
2025-04-26 12:37 ` Steven Rostedt
2025-04-25 20:41 ` [RFC][PATCH 2/2] treewide: Have the task->flags & PF_KTHREAD check use the " Steven Rostedt
2025-04-25 23:09 ` Kees Cook
2025-04-26 3:22 ` Alexei Starovoitov
2025-04-28 18:34 ` Tejun Heo
2025-04-25 23:14 ` [RFC][PATCH 0/2] Add is_user_thread() and is_kernel_thread() " Andrew Morton
2025-04-26 10:41 ` Julia Lawall
2025-04-26 12:43 ` Steven Rostedt
2025-04-26 18:42 ` [PATCH] sched/core: Introduce task_*() helpers for PF_ flags Ingo Molnar
2025-04-26 18:51 ` Ingo Molnar
2025-04-26 20:06 ` Steven Rostedt [this message]
2025-04-28 12:12 ` Steven Rostedt
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=20250426160630.46108366@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=Julia.Lawall@inria.fr \
--cc=akpm@linux-foundation.org \
--cc=bpf@vger.kernel.org \
--cc=cocci@inria.fr \
--cc=hpa@zytor.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=nicolas.palix@imag.fr \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.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