On Mon, 9 Mar 2026 at 08:43, Christoph Hellwig <[email protected]> wrote:
>
> Because it can't f&*^ up the state of random tasks.
Christoph, you make no sense.
"do_exit()" cannot mess up random tasks. It can only exit the
*current* task. The task that is running right now in that module.
And exiting a task is about the least effed up you can do to a task
when you are in kernel mode.
Compared to everything else you can do by mistake - like just
corrupting task state randomly - it's a very benign operation, *and*
it is obvious both in source code and in behavior. It's not like it is
some subtle operation.
I'd be *much* more worried about actual subtle bugs, not somebody
explicitly calling exit.
So what is the actual problem? No more random rants. Explain yourself
without making wild handwaving gestures.
Now, there are real exports in this area that are actually strange and
should be removed: for some historical reason we export 'free_task()'
which makes no sense to me at all (but probably did at some point).
Now *that* is a strange export that can mess up another task in major ways.
[ Ok, I was intrigued and I went and dug into history: we used to do
it in the oprofile driver many many moons ago. ]
And since I looked at the history of this all due to that odd export,
that also made it clear that historically we used to export
complete_and_exit(), which was this beauty:
NORET_TYPE void complete_and_exit(struct completion *comp, long code)
{
if (comp)
complete(comp);
do_exit(code);
}
so you could always do "do_exit()" by just doing
"complete_and_exit(NULL, code)".
And yes, that function was exported since at least 2003 (it was
exported even before that, under the name 'up_and_exit()', and that's
the point where I couldn't be bothered any more because it predates
even the old BK history).
Yes, it was indeed renamed to kthread_complete_and_exit() back in
2021, but that wasn't due to any fundamental "it has to work only on
kthreads". It was simply because nothing but kthreads used it - and
because that was also the time when kthread_exit() started doing
*extra* things over and beyond just the regular do_exit().
So it was a practical thing brought on by kthread changes, not some
kind of "exit is evil" thing.
And that "ktrhead_exit() does extra things" was the actual bug that
needed fixing and caused nasty memory corruption due to subtle lack of
cleanup when it was bypassed.
End result: we've never historically felt that exit() was somehow bad,
and when we limited it to kthreads and made it special, it caused
actual bugs.
Linus