[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wg6TWSvb8Lk5uEu=QKQRFj7vewMsqLhuah4_7r2S=dXWA@mail.gmail.com>
Date: Tue, 16 May 2023 13:38:51 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Dave Hansen <dave.hansen@...el.com>
Cc: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"keescook@...omium.org" <keescook@...omium.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [GIT PULL] x86/shstk for 6.4
On Mon, May 15, 2023 at 3:40 PM Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> So I *think* fork() could do something like this:
>
> struct fork_cookie; // dummy type purely for type checking
> static struct fork_cookie *is_singe_threaded(void)
> {
> struct mm_struct *mm = current->mm;
> mutex_lock(&mm->fork_lock);
Actually, let's not even bother with a new fork_lock.
I for some reason thought that fork only took the mmap_lock for
reading (because it kind of does just read the old VM data), but when
I actually look at dup_mmap() I notice that what it does is actually
just
if (mmap_write_lock_killable(oldmm)) ..
and so I think we can just use that as the lock.
So then all we'd need is to use mmap_read_lock(mm) in kthread_use_mm()
around the mmgrab.
I don't think we even need it in kthread_unuse_mm(), because
*decrementing* the mm counters isn't even something we need to worry
about.
How does that sound?
Linus
Powered by blists - more mailing lists