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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB029D18159 for ; Tue, 15 Oct 2024 00:07:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E2456B0085; Mon, 14 Oct 2024 20:07:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3919D6B0088; Mon, 14 Oct 2024 20:07:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2598A6B0089; Mon, 14 Oct 2024 20:07:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0368F6B0085 for ; Mon, 14 Oct 2024 20:07:56 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 84D6EA0762 for ; Tue, 15 Oct 2024 00:07:41 +0000 (UTC) X-FDA: 82673898300.27.10E5919 Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) by imf13.hostedemail.com (Postfix) with ESMTP id C9AEE2001E for ; Tue, 15 Oct 2024 00:07:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ePGkpOTR; spf=pass (imf13.hostedemail.com: domain of jthoughton@google.com designates 209.85.219.173 as permitted sender) smtp.mailfrom=jthoughton@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728950828; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0k5ziZv+luz4h4U9vFxjQyLKnmTaKDBU/6xsRlEbTbw=; b=sgSDo5FgPxz3aq+H9LjyMq0CiPlhI4FV5cLwtqKZsZ/shgelMSEH+XaoaL7cmw6qtnnhJB 24X38Fz1D8lN+oFiWAQcEU1f+M8VryyQ3dlB+OZ2EOQU3qWXAx7zMctZjxbh5S4QcLzPEs PjR9kXJL9DNFHG+degtfbZdljAJbjFc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ePGkpOTR; spf=pass (imf13.hostedemail.com: domain of jthoughton@google.com designates 209.85.219.173 as permitted sender) smtp.mailfrom=jthoughton@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728950828; a=rsa-sha256; cv=none; b=zkXoCRCBJ6KhRrYwy3z8VvvSAV15y1GASNWBWmJ2kcQnsGjXdhOqEkQVQSHgs1LYa8XggH 6ZfcCVxyqEdtTXyP8TBLr0Y9m8vJE+agZCXaaP5OWp0gz084KQrfh6K4QnWUU9WcRG0nak aRTFa9Ji6yANAb730I130brzT9gXZZI= Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-e290200a560so4227766276.1 for ; Mon, 14 Oct 2024 17:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728950874; x=1729555674; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0k5ziZv+luz4h4U9vFxjQyLKnmTaKDBU/6xsRlEbTbw=; b=ePGkpOTRMK/GK0C0Y6qgrUwn1MlxaP2IDAyGfpB5gmgljmAC5FaeqjOx0j/vcmxDiF xaC9akfxw5+5QlALzOJ73tGCR4NHK6cFvpznRggt+DB6o0G+3Cdqr1w60NoPEc9d0PE+ mUWaq7kTQp82G8v//gqXmibMRGzHiYUcdZZZGBEZoenNt14PBTUDI0jE79fFmDVq3FHr 0Gco3vi856DQGkGju/shqKZGg6NV6etCerQKVACawl9XtSAqeh7PpxtMm2EYTex3D54r FjUhqQQK5q865rnqFNjJ7IHg/7aW/R0FiBAShjq5BtDwQuN2hpo8cEMS2K9/2vQlkCnw K2+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728950874; x=1729555674; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0k5ziZv+luz4h4U9vFxjQyLKnmTaKDBU/6xsRlEbTbw=; b=cCaprAA0JhRtu5CQ6T1AKrkCZFBjAylyuMA7IT9PqPshcwjfu4oEATUmo7AOG/vPNQ eAo/MP68UhXfznWnP9KWuQsOdQAIKPNIXwB191/sGb4aViGVArcJqvjZ+3um2VEcmAXa 5L35l+i1haBCtPm+Mfba0QEDAZR52Gd7bL2WTLjjwAKjUb6Y9LUVmDehTVDWUDBOF0Q9 KYqR0Qvk6MCqgUaewqVLOUNrsChjWJM03NyIQm4Mun/tsvTAFgpS9p9wlW3dhZR6wtoz 4AbIVfwNYAodrxq/6oXpzcDzFmFauY8maT/QPqXf62Ze1SeD9gHTLX5kTwLcotJ43spI 33nQ== X-Forwarded-Encrypted: i=1; AJvYcCWzTWw71QmCjijFiPvEiKoTIjO3pJCOsT2Tr+X5G/Q14uFpOfjQcD3WJ34ytt0VRJpjeTfXeLXf2g==@kvack.org X-Gm-Message-State: AOJu0Yy+gIGPsY3S5qsJ6j79QCdWhxGJS6BbgdJJmrRkuxHLkljeHcor 2Vm34lieSoz8BDJWyDJ6UUT1HMfpwdOskODg+u8sFHaQRbuLbjp7e/+96OokhuTcFvhgF/YGeKh /gtSZx5DsUG5DJPvPbe2tdhiNQpeKFAMGsWBd X-Google-Smtp-Source: AGHT+IGPIi5KCS6+nJghaiqqBaIDBteS+Nw+yIW3S78bDe3HfZ8DlWRHR3b0JckOrBruI74JpMNZzOH6luJE20JY9vk= X-Received: by 2002:a05:6902:c07:b0:e29:29b0:2b2a with SMTP id 3f1490d57ef6-e2931deb4c6mr7548470276.51.1728950873598; Mon, 14 Oct 2024 17:07:53 -0700 (PDT) MIME-Version: 1.0 References: <20240926013506.860253-1-jthoughton@google.com> In-Reply-To: From: James Houghton Date: Mon, 14 Oct 2024 17:07:17 -0700 Message-ID: Subject: Re: [PATCH v7 00/18] mm: multi-gen LRU: Walk secondary MMU page tables while aging To: Sean Christopherson , Yu Zhao Cc: Paolo Bonzini , Andrew Morton , David Matlack , David Rientjes , Jason Gunthorpe , Jonathan Corbet , Marc Zyngier , Oliver Upton , Wei Xu , Axel Rasmussen , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, David Stevens Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Stat-Signature: jknt7s873icy5r86tn3e39h956agbc5h X-Rspamd-Queue-Id: C9AEE2001E X-Rspamd-Server: rspam11 X-HE-Tag: 1728950867-464681 X-HE-Meta: U2FsdGVkX19eq9AMcvpvydDG/5eiECYAIAuziwAQBvGVT/lZPrE7AgNdoyBGBjoGuk0CELOIl47N6++KrYG4GZJxyCz490qWBcgBvAqmikoioXn0F/HCPwoo2t2UR4LMMDvtfIkmX6OijyqAGx2dkh2+TB74jp5N7e4oPoksCxEFcfMvFREJiaLTNfj0rxjLR86GJ7fZMGAJVjYIo4d09lshiCXlALMSPxPM8Q7+plhOXWDRNLSCpJCpziqGQQUchj1JxuPcBJJc7rbGdqz0Oqo8GY22i6y5tayiN61XvByah0F+N6iMCVvqlufbXYnprWDHymnToLDtXvdEkI/6O3sgHV3EgFu6mUd8oS45+ehmTDd+4UdGH7CDT50wqwOYM9u4lMLR7E+wKwk0hP2hsUlJ09RaScSADqFPh+xcKTOO0rSDgF+xPsAAm0x267cexuCuBvbMcAwtjJJGS2gv5oo+v18tgVbn3QVSkpC4DRY3eGq3wS5nTKYFj99Rf7NoW7bMgN6zgDO6+jNjir345D9qEesXYzRlVGu/vTP8QEXNj51j1AcAgN+i/+FIL5Dq1IWhLIXSYlfbvumAzB50j5G2NxY5agytyRcnu39zpFUSA26EncabCFZLdZX5QmelCOSvgUbPWC0Ls14xKRuIeopp68Eb/Qmoc2Wh2SN+Mfe1ATl4JzPVvWtxae8eD9Jq2cCBrT6UwWnTfiuN2mY1LN3aZu6yVGNg75TrWEG4PWQEsAMHZ9viju7C0CYjQIUdmy3/HDqCwcmCRItFv8sJNNBaVef2Z+QxFpRmH+bAp3AAyQnVvL+sNSaaZJglnqOmCKGzsaF9JKvlU9xlf0rEJwpEGIDYh25fdC8UwtRebQXH9vlyDMb7JchgVG9An+XIkjkXEYtBcVxf51286vowCU6QLECAsZYMIehGZbI28Rnu3CJL/sf3b82gTvIs3R2JCLl5hySoZHV+bXgPiC4 0T6OcQQd ojZfREn/3uaUIY3S+VmyXOMbgnGkm7m/W5cCnU8zfJhc6FhYGysM8YJsXbNCGwOuHdMdAILvdPnrAdkwuomci2JiDHfK78YKU/njo3CvyHPpLz9J2hVS+Hb/KMCCJTQf0Faa12WVpxy1E2paZfvMSDPB99P4uYMqNNClYMNxno9MVOSStnmO2rOHB2R2gP8e1DQH40TM7QZKAW1DZgX458578PQOG3JyCpJxi X-Bogosity: Ham, tests=bogofilter, spamicity=0.000385, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Oct 14, 2024 at 4:22=E2=80=AFPM Sean Christopherson wrote: > > On Thu, Sep 26, 2024, James Houghton wrote: > > This patchset makes it possible for MGLRU to consult secondary MMUs > > while doing aging, not just during eviction. This allows for more > > accurate reclaim decisions, which is especially important for proactive > > reclaim. > > ... > > > James Houghton (14): > > KVM: Remove kvm_handle_hva_range helper functions > > KVM: Add lockless memslot walk to KVM > > KVM: x86/mmu: Factor out spte atomic bit clearing routine > > KVM: x86/mmu: Relax locking for kvm_test_age_gfn and kvm_age_gfn > > KVM: x86/mmu: Rearrange kvm_{test_,}age_gfn > > KVM: x86/mmu: Only check gfn age in shadow MMU if > > indirect_shadow_pages > 0 > > mm: Add missing mmu_notifier_clear_young for !MMU_NOTIFIER > > mm: Add has_fast_aging to struct mmu_notifier > > mm: Add fast_only bool to test_young and clear_young MMU notifiers > > Per offline discussions, there's a non-zero chance that fast_only won't b= e needed, > because it may be preferable to incorporate secondary MMUs into MGLRU, ev= en if > they don't support "fast" aging. > > What's the status on that front? Even if the status is "TBD", it'd be ve= ry helpful > to let others know, so that they don't spend time reviewing code that mig= ht be > completely thrown away. The fast_only MMU notifier changes will probably be removed in v8. ChromeOS folks found that the way MGLRU *currently* interacts with KVM is problematic. That is, today, with the MM_WALK MGLRU capability enabled, normal PTEs have their Accessed bits cleared via a page table scan and then during an rmap walk upon attempted eviction, whereas, KVM SPTEs only have their Accessed bits cleared via the rmap walk at eviction time. So KVM SPTEs have their Accessed bits cleared less frequently than normal PTEs, and therefore they appear younger than they should. It turns out that this causes tab open latency regressions on ChromeOS where a significant amount of memory is being used by a VM. IIUC, the fix for this is to have MGLRU age SPTEs as often as it ages normal PTEs; i.e., it should call the correct MMU notifiers each time it clears A bits on PTEs. The final patch in this series sort of does this, but instead of calling the new fast_only notifier, we need to call the normal test/clear_young() notifiers regardless of how fast they are. This also means that the MGLRU changes no longer depend on the KVM optimizations, as they can motivated independently. Yu, have I gotten anything wrong here? Do you have any more details to shar= e?