Re: [RFC][PATCH 0/2] Add is_user_thread() and is_kernel_thread() helper functions

Steven Rostedt
2025-04-26T12:43:23Z

On Fri, 25 Apr 2025 16:14:49 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> Seems sensible. Please consider renaming PF_KTHREAD in order to break
> missed conversion sites.

It's not wrong to use the thread. I just find using these helper
functions a bit easier to review code. There's also some places that
have special tests where it can't use the flag:

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() ?

Note, for coccinelle patches, I would wait till the end of the merge
window, run the scripts on what's in Linus's tree, run my tests, and
then submit. This way it catches most of the conversions with the least
amount of conflicts.

-- Steve