public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	 "Michael S. Tsirkin" <mst@redhat.com>,
	 Christian Brauner <brauner@kernel.org>,
	 Oleg Nesterov <oleg@redhat.com>,
	 linux-kernel@vger.kernel.org,  kvm@vger.kernel.org
Subject: Re: [GIT PULL] KVM changes for Linux 6.14
Date: Sun, 26 Jan 2025 21:55:17 -0600	[thread overview]
Message-ID: <87plk8kj16.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <CAHk-=wj9fNzDy0dTJzKj3RiSp-puwNawxQ5+ULMvKKjMRV=eqw@mail.gmail.com> (Linus Torvalds's message of "Sat, 25 Jan 2025 10:31:49 -0800")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Sat, 25 Jan 2025 at 10:12, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>> Arguably the user space oddity is just strange and Paolo even calls it
>> a bug, but at the same time, I do think user space can and should
>> reasonably expect that it only has children that it created
>> explicitly [..]
>
> Note that I think that doing things like "io_uring" and getting IO
> helper threads that way would very much count as "explicit children",
> so I don't argue that all kernel helper threads would fall under this
> category.
>
> And I suspect that the normal vhost workers fall under that same kind
> of "it's like io_uring". If you use VHOST_NEW_WORKER to create a
> worker thread, then that's a pretty explicit "I have a child process".
>
> So it's really just that hugepage recovery thread that seems to be a
> bit "too" much of an implicit kernel helper thread that user space
> kind of gets accidentally and implicitly just because of a kernel
> implementation detail.
>
> I'm sure the kvm hack to just start it later (at KVM_RUN time?) is
> sufficient in practice, but it still feels conceptually iffy to me.

I don't think implicit vs explicit is right question.  Rather we should
be asking can userspace care?

If I read the context from the commit correctly what userspace
is asking is:  Am I single threaded so that I know nothing funny
will happen in the forked process.

The most common funny I am aware of for forked multi-threaded processes
is that if they fork with another thread holding a lock the forked
process might hang forever on the lock because the lock will never
be released.

The most interesting part of the hugepage reaper appears to be
kvm_mmu_commit_zap_page, where a page is freed after being flushed from
the tlb.

I would argue that if kvm_mmu_commit_zap_page and friends change the
page tables in a way that userspace can see after a fork, and in turn
could affect how the forked process will execute userspace is doing
something sensible in testing for it.

On the flip side if this isn't something userspace can observe in it's
own process I would argue that the proper solution is to user a regular
kthread.

In summary the conceptually clean approach is to only have threads that
when running can effect the process they are a part of in a userspace
visible way.  Assuming the hugepage reaper can effect the process it is
a part of, the only problem I see is the hugepage reaper existing when
it had nothing it could possibly do.

I don't think hiding threads is a useful solution because the threads
will effect they process they are a part of.  If the threads aren't
effecting the process they are a part of we have other solutions besides
threads.

Eric

  reply	other threads:[~2025-01-27  4:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24 16:37 [GIT PULL] KVM changes for Linux 6.14 Paolo Bonzini
2025-01-25 14:30 ` Marc Zyngier
2025-01-25 18:12 ` Linus Torvalds
2025-01-25 18:31   ` Linus Torvalds
2025-01-27  3:55     ` Eric W. Biederman [this message]
2025-01-26 14:20   ` Oleg Nesterov
2025-01-26 18:34     ` Linus Torvalds
2025-01-26 18:53       ` Oleg Nesterov
2025-01-26 19:03         ` Oleg Nesterov
2025-01-26 19:16         ` Linus Torvalds
2025-01-27 14:09           ` Oleg Nesterov
2025-01-27 15:15             ` Paolo Bonzini
2025-02-04 14:19               ` Christian Brauner
2025-02-04 16:05                 ` Paolo Bonzini
2025-02-05 11:49                   ` Christian Brauner
2025-02-05 16:12                     ` Linus Torvalds
2025-02-26 12:14                     ` Christian Brauner
2025-02-26 19:03                       ` Oleg Nesterov
2025-02-27  8:15                         ` Christian Brauner
2025-01-25 18:16 ` Linus Torvalds
2025-01-27 15:24   ` Sean Christopherson
2025-01-27 15:25   ` Paolo Bonzini
2025-01-25 18:30 ` pr-tracker-bot

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=87plk8kj16.fsf@email.froward.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=brauner@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=oleg@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=torvalds@linux-foundation.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