From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAE3EC2BD09 for ; Fri, 12 Jul 2024 15:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZWyWnNJQfLis8OltmFTp+D+i2eRVmZlaO2glliGRcpM=; b=GDZbVRvcXn+vLjG+KadrQACqJM c2x+C1dp0/m6CQWTNGnRpA8aIjpS1RvTHlFJEo9JecOMqoHsIrZb/Kb8NknMZ9XpUfv1xvDACA/33 nJlG+pXmp9SsS+L6ycJY05bLl6aZ5zOunWyLj6akQeD8JB+Ks2yAYGimmU/A12BDnkzY0FvlYLV9B mzYYviDAcNRydyEg8l2FD2rCIz+TNuA4KuYzd7LXafkCbjG2KQW9ExXKDUAvu4p5uFayhdv63YmJW 2vyot9z3Pg3dhqJz8HKvBuUgIAgrUQcXKU6vw1zHrBFAyF0JUBLYD+/GX3bxJLDQOrw5wamfLsU2y fwp4bppw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSHrV-00000000SIe-1W67; Fri, 12 Jul 2024 15:07:05 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSHrC-00000000SDH-2CB7 for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 15:06:48 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1fba2bb1ad5so12024705ad.3 for ; Fri, 12 Jul 2024 08:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720796804; x=1721401604; darn=lists.infradead.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=ZWyWnNJQfLis8OltmFTp+D+i2eRVmZlaO2glliGRcpM=; b=BnriQ91lAscnEUk1w4VfVy5M/WswGUH5TBW+wDtAfoavunkjD3in12Tc6H+wqqJuys hqGE2J7xYt5RrNwSyNTmn7QzYGE25Og3RaQxAg0zm/T8Xvrc05Xvlq1CYjFwQd1tenyI DPN2ze+1jleXHJ7jRd6moU3Fxk6ZpHfLR56FVwIux/abTVhflk8FnPVeAiCtfzc0SLXV PJAQlrw5LmTkrA9CCb2nod6ullBSduLDA3QUB24ywpbrI/fo39TNDZsqxBYGyC9d4tVa UTjceimFQVuWzQJ9zchEM8unNEoDHsdo6CZwRsgtdScDAji+mqsM8QVNfNr2GgZWixoH +35g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720796804; x=1721401604; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=ZWyWnNJQfLis8OltmFTp+D+i2eRVmZlaO2glliGRcpM=; b=iChAhTGd0jT3gMPH3rGUdvxr+WvifTZDDAenUO5HOCmHYsy3HWmI11f1B4KV2xazlG dev5wfX8eGtP413Dt7KfXo//DHhnLkzj0l1qkdsg9uR2cmeYA09qdxlsvcfjQrP4pgKu vCGpUsozemYPCOiHKS7N3Xkri3pTeNusnh8Wy0i8NxxBdk+fqa+PeLD1vsZle5/OB6KA Cgk4A3CKCAsxv0m+g+Rcs2JrPKnsoT1G9Mada+PQE7OCKx6M/XBMASjGbPTJU0KyHVLp NAOck9WrbUwuctieaGR9geYGOw8GZ6zHR9l/CMXr7XdlUCO9XQG0XZOGM+TnbT6JpTA0 ex/A== X-Forwarded-Encrypted: i=1; AJvYcCW3O+zf+BWCNF+cG1/PaQ30aBZoZG3fiE78h7RDM2DnAVH9EgX9ezzo+lZPhrZl3+3UG7Y7G5ANnZ3zHmkjlM4NMAv2pldH3jkEuhLTNgIotj3RBl4= X-Gm-Message-State: AOJu0YwBqh/5xESD/Xj+FbpkhizXvaXOE3Pn1jq1l8ccBaqZjCF1rWNR lWUuEb4tHIsT52GzT8HDuJ6+tXo0LR3pbY1kSVzTvU90ofEeNhK0U7Wfvjdo0O+ZKHCNA2G0q3i wyw== X-Google-Smtp-Source: AGHT+IGDfGxGyoOOVJXHRxv/7+Ukhncjw5VneesB3o9h2h6VbTln8g5EPSE4uE3ENM6QWIp1Ic1twbCkqos= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:ec8b:b0:1fb:415d:81c5 with SMTP id d9443c01a7336-1fbb6eb7039mr251225ad.8.1720796804378; Fri, 12 Jul 2024 08:06:44 -0700 (PDT) Date: Fri, 12 Jul 2024 08:06:42 -0700 In-Reply-To: Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH v5 4/9] mm: Add test_clear_young_fast_only MMU notifier From: Sean Christopherson To: James Houghton Cc: Yu Zhao , Andrew Morton , Paolo Bonzini , Ankit Agrawal , Axel Rasmussen , Catalin Marinas , David Matlack , David Rientjes , James Morse , Jonathan Corbet , Marc Zyngier , Oliver Upton , Raghavendra Rao Ananta , Ryan Roberts , Shaoqin Huang , Suzuki K Poulose , Wei Xu , Will Deacon , Zenghui Yu , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_080646_585344_84A25096 X-CRM114-Status: GOOD ( 30.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jul 10, 2024, James Houghton wrote: > On Tue, Jul 9, 2024 at 10:49=E2=80=AFAM Sean Christopherson wrote: > > > > On Mon, Jul 08, 2024, James Houghton wrote: > > > On Fri, Jun 28, 2024 at 7:38=E2=80=AFPM James Houghton wrote: > > > > > > > > On Mon, Jun 17, 2024 at 11:37=E2=80=AFAM Sean Christopherson 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 L= 2 > > > 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 a= ccuracy, > > 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 look= around has > > already been performed. >=20 > 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. >=20 > 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. >=20 > 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* c= aveat 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. >=20 > 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 rm= ap idea pans out, KVM can set the flag during VM creation. Until then, KVM ca= n set the flag during creation and then toggle it in (un)account_shadowed(). Rac= es will be possible, but they should be extremely rare and quite benign, all t= hings considered.