[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZpFGYvCAQWhldWJZ@google.com>
Date: Fri, 12 Jul 2024 08:06:42 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: James Houghton <jthoughton@...gle.com>
Cc: Yu Zhao <yuzhao@...gle.com>, Andrew Morton <akpm@...ux-foundation.org>,
Paolo Bonzini <pbonzini@...hat.com>, Ankit Agrawal <ankita@...dia.com>,
Axel Rasmussen <axelrasmussen@...gle.com>, Catalin Marinas <catalin.marinas@....com>,
David Matlack <dmatlack@...gle.com>, David Rientjes <rientjes@...gle.com>,
James Morse <james.morse@....com>, Jonathan Corbet <corbet@....net>, Marc Zyngier <maz@...nel.org>,
Oliver Upton <oliver.upton@...ux.dev>, Raghavendra Rao Ananta <rananta@...gle.com>,
Ryan Roberts <ryan.roberts@....com>, Shaoqin Huang <shahuang@...hat.com>,
Suzuki K Poulose <suzuki.poulose@....com>, Wei Xu <weixugc@...gle.com>,
Will Deacon <will@...nel.org>, Zenghui Yu <yuzenghui@...wei.com>, kvmarm@...ts.linux.dev,
kvm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v5 4/9] mm: Add test_clear_young_fast_only MMU notifier
On Wed, Jul 10, 2024, James Houghton wrote:
> On Tue, Jul 9, 2024 at 10:49 AM Sean Christopherson <seanjc@...gle.com> wrote:
> >
> > On Mon, Jul 08, 2024, James Houghton wrote:
> > > On Fri, Jun 28, 2024 at 7:38 PM James Houghton <jthoughton@...gle.com> wrote:
> > > >
> > > > On Mon, Jun 17, 2024 at 11:37 AM Sean Christopherson <seanjc@...gle.com> wrote:
> > > I still don't think we should get rid of the WAS_FAST stuff.
> >
> > I do :-)
> >
> > > The assumption that the L1 VM will almost never share pages between L2
> > > VMs is questionable. The real question becomes: do we care to have
> > > accurate age information for this case? I think so.
> >
> > I think you're conflating two different things. WAS_FAST isn't about accuracy,
> > it's about supporting lookaround in conditionally fast secondary MMUs.
> >
> > Accuracy only comes into play when we're talking about the last-minute check,
> > which, IIUC, has nothing to do with WAS_FAST because any potential lookaround has
> > already been performed.
>
> Sorry, I thought you meant: have the MMU notifier only ever be
> lockless (when tdp_mmu_enabled), and just return a potentially wrong
> result in the unlikely case that L1 is sharing pages between L2s.
>
> I think it's totally fine to just drop WAS_FAST. So then we can either
> do look-around (1) always, or (2) only when there is a secondary MMU
> with has_fast_aging. (2) is pretty simple, I'll just do that.
>
> We can add some shadow MMU lockless support later to make the
> look-around not as useless for the nested TDP case.
...
> > Adding the locking isn't actually all that difficult, with the *huge* caveat that
> > the below patch is compile-tested only. The vast majority of the churn is to make
> > it so existing code ignores the new KVM_RMAP_LOCKED bit.
>
> This is very interesting, thanks for laying out how this could be
> done. I don't want to hold this series up on getting the details of
> the shadow MMU lockless walk exactly right. :)
...
> 1. Drop the WAS_FAST complexity.
> 2. Add a function like mm_has_fast_aging_notifiers(), use that to
> determine if we should be doing look-around.
I would prefer a flag over a function. Long-term, if my pseudo-lockless rmap
idea pans out, KVM can set the flag during VM creation. Until then, KVM can set
the flag during creation and then toggle it in (un)account_shadowed(). Races
will be possible, but they should be extremely rare and quite benign, all things
considered.
Powered by blists - more mailing lists