Re: [GIT PULL] KVM changes for Linux 6.14

Oleg Nesterov
2025-01-26T18:54:28Z

On 01/26, Linus Torvalds wrote:
>
> On Sun, 26 Jan 2025 at 06:21, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > > Should we just add some flag to say "don't show this thread in this
> > > context"?
> >
> > Not sure I understand... Looking at is_single_threaded() above I guess
> > something like below should work (incomplete, in particular we need to
> > chang first_tid() as well).
>
> So yes, I was thinking something similar, but:
>
> > But a PF_HIDDEN sub-thread will still be visible via /proc/$pid_of_PF_HIDDEN
> >
> > > We obviously still want to see it for management purposes,
> > > so it's not like the thing should be entirely invisible,
> >
> > Can you explain?
>
> I was literally thinking that instead of a "hidden" flag, it would be
> a "self-hidden" flag.
>
> So if somebody _else_ (notably the sysadmin) does "ps" they see the
> kernel thread as a subthread.
>
> But when you look at your own /proc/self/task/ listing, you only see
> your own explicit threads. So that "is_singlethreaded()" logic works.

Got it...

I don't think we even need to detect the /proc/self/ or /proc/self-thread/
case, next_tid() can just check same_thread_group,

- if (!(pos->flags & PF_HIDDEN)) {
+ if (!(pos->flags & PF_HIDDEN) || !same_thread_group(current, pos))) {

right ?

Oleg.