Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp613489lqp; Wed, 12 Jun 2024 10:47:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwCPWvyzOhEru0Gfjp3OJyQZiy4EKKiLY58u3exbX67R1trvMoMoHY6tqZSsnTUllYX8dZ9gJAkjxAVoJtOIA3s5QNQNvGvxu1Bj+Nrw== X-Google-Smtp-Source: AGHT+IGvVIy23zat1ijyfgHXClHi+E1TZLYQFfAS2H/NT0mCTfvXVpln93sbPtS/k21sSLj0oCLq X-Received: by 2002:a05:6359:4593:b0:19f:4c4e:d3d6 with SMTP id e5c5f4694b2df-19f69d84ad4mr280974955d.29.1718214419704; Wed, 12 Jun 2024 10:46:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718214419; cv=pass; d=google.com; s=arc-20160816; b=cUe6eAa/bkXCCZhIAOfw6GJVjWgtegwDr7w+8F1feytYrGklkQ32PvVxLsTxxbdR44 RV9C72WhqrkB/qh3Z0QjbqOGpj8i3jj+i4vKQbHHpH4PLFtgORi6kY1IYoF9pTVPxgjk 2vFaeEccdxrk1uKja7KkLgGDBnGV83/o7LxEjroHm9AbLEDD8/5zYTsaEZRYoYG5sP43 BFrtJSyYKsbkHIbYR8ofvNtNoqAcgfDvImgmf6zFuhjWVrWipOUe1L466/IrF17Cnvhk a2P3HMBcmlZlYg8xiEpggFTSJ5W9PuCWAk1QRvY0LSrslDWK8NI9YG/zuWJZ4lXj/pSJ IK4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=v0uZvClGSP7b0LMzzAPVM0AhM29ZDe2y2D54OZuyJ4o=; fh=UMRwZ+xfEbSm/51amQE7ZhyFEitd+Pe2OmG77HgyWJM=; b=h2YKoE7jN6GQRXv1VH/NPnbHhXMrYeHupU1ij40EjHB1pxcHzf7HzcAky6uq5TnC49 8djMu9C5uSpMY9hPSlR5aw5d+zeM/L5+3PDQTznln/0OxnXApUvMaybfMBeRhNRm9ehN hTnRl/I2iD6fUUFumpqV5ZsLUW5oARs/Pl1PM1qy1hWT9BDTSCFDRXPCLPgO1y/OEUb1 WG7wuCP/x5uojDLNclyE0e2noPT5KkpfNs7I1n/+P37u6ogFRocsi3YKf5PWUgPS1nt9 PGnQ0H6XbMcNfBBffSn/NE+dcyC7C+Muwfa8NAzE4sIB/2Ooy9hBhyiEQ7MiARUtvfHd JwQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ED6QTUpf; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-211998-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211998-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de262c008fsi11853332a12.391.2024.06.12.10.46.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 10:46:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211998-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ED6QTUpf; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-211998-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211998-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 334B6B24705 for ; Wed, 12 Jun 2024 17:24:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 825BB183064; Wed, 12 Jun 2024 17:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ED6QTUpf" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18C7C1822D5 for ; Wed, 12 Jun 2024 17:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718213023; cv=none; b=YJy2i9kb0PvWZUCNuLjhfTMrtDHOiKQLYEEGdhYQD6taufN+5LuVqarLI8c8cW41fAGrcfYx0LeFjnpntzP6Sxbnl8dH47uPBwOxyFAQpyevb8THV/HWdczC8sD/a0MJSJy1NNwsGjiTWOVNB8Z7orbs2DF4YhQbIKxCBRLGmuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718213023; c=relaxed/simple; bh=qvzOGVZF1aFjcNNXoWdAyWZv4lQeSovWWQTrEs6pNdw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Z8sz0X2WLLDv8aORh9x0UDqc2jZ2HVuLfAePR9PjjtOm4OenNlE+6u9wZbS9dzDp7vSKosateft6Z6hvG+pr50wYwl/b31LlBfyNUTr5/4uj/v4r1sAgneZVSkTDPrYmaQTn4R5pDxQ8iza4BpodFWaW8WfERtHWTEL8bD6XKHc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ED6QTUpf; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dfe4f388d33so124057276.2 for ; Wed, 12 Jun 2024 10:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718213020; x=1718817820; darn=vger.kernel.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=v0uZvClGSP7b0LMzzAPVM0AhM29ZDe2y2D54OZuyJ4o=; b=ED6QTUpflG01XxDwADpCTuUCb3My1wmNO1KRIabL/mB6J08kl5ENGX51vmpVHsg6xR jFv33Xhk3VXxWTVvpGKAaIotK7Zksj8HAw0XHs6pGvPnVz+1x1dCCWPEFUm/SJy06FLi BpuEPZLYakQWef9qNxKBc3A3XsNZbfd6mt7/jBNk0WSx8e0xYM5diG+B74Wd60h/dixp Ae7x+VxLhJaqlumRqtc3pPayDW5jcNJHxwn3EmaYD3cAVYZ7BtagZ8ZPWqNrRQf8GGOR qUscLQNTNlkm6MS3vd2OpolLDv7GKWif+u6p98TUEVHK9IwK5SEi6mXOlkhAKEmwzS4n qyAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718213020; x=1718817820; 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=v0uZvClGSP7b0LMzzAPVM0AhM29ZDe2y2D54OZuyJ4o=; b=ZphytQPNvuDFNDvhd30zOkiLRORgWXunze1qk3y82J7N3HqBCVWF1B9f3d03LMwqfo ktcNzRPLHQ9+mdahizpUY1jGQzNNxZCjdPYlVMaSiDk3HADJMVRSeA5Omt1AkDcLXPr/ VLrSaN0E4E71MgTOeXEE6jzUFp5DWqSGIcEL3Knx30rEC0DlY2fqIiExlSw2Dxdfhh39 nQ0cSHOil8++8BWlTe6FfZXh7tH+6+7niQFdyf6uRl9kCGKhwTKCGF+WS4/7jB7N6KY3 k3JVJytqH4EcHYIDbf7hRang0wR+Y+/FB4FZoxM5P1Q/peesxVK3T8hgzrgIk2zbPsz2 gIPg== X-Forwarded-Encrypted: i=1; AJvYcCUF66Eq5ikfNgNvWkrMU5Ec5AdUcsKROvBwr3SCGE7UEg7MRItoYCvBW3y++ury4fri38maRlbu9op5Pig81YujtadrcKGoZg1NTT7R X-Gm-Message-State: AOJu0YxUCwvWBnFdhHHuHMeJQJZGTeaDCJhIFYpyjEMec5RpxfSk4R98 jx96imUr7Ct7jl+1p759p8E0PyrSE2gelto+pioTGEf0vur4tcXVkF2RM6ba4hdXb0K41jUOb6/ +NA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:729:b0:dfb:b4e:407a with SMTP id 3f1490d57ef6-dfe68035fbemr647880276.9.1718213020117; Wed, 12 Jun 2024 10:23:40 -0700 (PDT) Date: Wed, 12 Jun 2024 10:23:38 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240611002145.2078921-1-jthoughton@google.com> <20240611002145.2078921-9-jthoughton@google.com> Message-ID: Subject: Re: [PATCH v5 8/9] mm: multi-gen LRU: Have secondary MMUs participate in aging From: Sean Christopherson To: Yu Zhao Cc: James Houghton , 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 On Wed, Jun 12, 2024, Yu Zhao wrote: > On Wed, Jun 12, 2024 at 10:02=E2=80=AFAM Sean Christopherson wrote: > > > > On Tue, Jun 11, 2024, James Houghton wrote: > > > diff --git a/mm/rmap.c b/mm/rmap.c > > > index e8fc5ecb59b2..24a3ff639919 100644 > > > --- a/mm/rmap.c > > > +++ b/mm/rmap.c > > > @@ -870,13 +870,10 @@ static bool folio_referenced_one(struct folio *= folio, > > > continue; > > > } > > > > > > - if (pvmw.pte) { > > > - if (lru_gen_enabled() && > > > - pte_young(ptep_get(pvmw.pte))) { > > > - lru_gen_look_around(&pvmw); > > > + if (lru_gen_enabled() && pvmw.pte) { > > > + if (lru_gen_look_around(&pvmw)) > > > referenced++; > > > - } > > > - > > > + } else if (pvmw.pte) { > > > if (ptep_clear_flush_young_notify(vma, address, > > > pvmw.pte)) > > > referenced++; > > > > Random question not really related to KVM/secondary MMU participation. = AFAICT, > > the MGLRU approach doesn't flush TLBs after aging pages. How does MGLR= U mitigate > > false negatives on pxx_young() due to the CPU not setting Accessed bits= because > > of stale TLB entries? >=20 > I do think there can be false negatives but we have not been able to > measure their practical impacts since we disabled the flush on some > host MMUs long ago (NOT by MGLRU), e.g., on x86 and ppc, > ptep_clear_flush_young() is just ptep_test_andclear_young(). Aha! That's what I was missing, I somehow didn't see x86's ptep_clear_flus= h_young(). That begs the question, why does KVM flush TLBs on architectures that don't= need to? And since kvm_mmu_notifier_clear_young() explicitly doesn't flush, are= there even any KVM-supported architectures for which the flush is mandatory? Skipping the flush on KVM x86 seems like a complete no-brainer. Will, Marc and/or Oliver, what are arm64's requirements in this area? E.g.= I see that arm64's version of __ptep_clear_flush_young() does TLBI but not DSB. = Should KVM be doing something similar? Can KVM safely skip even the TBLI? > theoretical basis is that, given the TLB coverage trend (Figure 1 in > [1]), when a system is running out of memory, it's unlikely to have > many long-lived entries in its TLB. IOW, if that system had a stable > working set (hot memory) that can fit into its TLB, it wouldn't hit > page reclaim. Again, this is based on the theory (proposition) that > for most systems, their TLB coverages are much smaller than their > memory sizes. >=20 > If/when the above proposition doesn't hold, the next step in the page > reclaim path, which is to unmap the PTE, will cause a page fault. The > fault can be minor or major (requires IO), depending on the race > between the reclaiming and accessing threads. In this case, the > tradeoff, in a steady state, is between the PF cost of pages we > shouldn't reclaim and the flush cost of pages we scan. The PF cost is > higher than the flush cost per page. But we scan many pages and only > reclaim a few of them; pages we shouldn't reclaim are a (small) > portion of the latter. >=20 > [1] https://www.usenix.org/legacy/events/osdi02/tech/full_papers/navarro/= navarro.pdf