[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YG3GBhvVt2cQkZVz@hirez.programming.kicks-ass.net>
Date: Wed, 7 Apr 2021 16:47:34 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Michel Lespinasse <michel@...pinasse.org>
Cc: Linux-MM <linux-mm@...ck.org>,
Laurent Dufour <ldufour@...ux.ibm.com>,
Michal Hocko <mhocko@...e.com>,
Matthew Wilcox <willy@...radead.org>,
Rik van Riel <riel@...riel.com>,
Paul McKenney <paulmck@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Suren Baghdasaryan <surenb@...gle.com>,
Joel Fernandes <joelaf@...gle.com>,
Rom Lemarchand <romlem@...gle.com>,
Linux-Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH 09/37] mm: add per-mm mmap sequence counter for
speculative page fault handling.
On Tue, Apr 06, 2021 at 06:44:34PM -0700, Michel Lespinasse wrote:
> The counter's write side is hooked into the existing mmap locking API:
> mmap_write_lock() increments the counter to the next (odd) value, and
> mmap_write_unlock() increments it again to the next (even) value.
>
> The counter's speculative read side is supposed to be used as follows:
>
> seq = mmap_seq_read_start(mm);
> if (seq & 1)
> goto fail;
> .... speculative handling here ....
> if (!mmap_seq_read_check(mm, seq)
> goto fail;
>
> This API guarantees that, if none of the "fail" tests abort
> speculative execution, the speculative code section did not run
> concurrently with any mmap writer.
So this is obviously safe, but it's also super excessive. Any change,
anywhere, will invalidate and abort a SPF.
Since you make a complete copy of the vma, you could memcmp it in its
entirety instead of this.
Powered by blists - more mailing lists