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 90ED0C05027 for ; Fri, 17 Feb 2023 16:00:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05C376B0071; Fri, 17 Feb 2023 11:00:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 00BCF6B0072; Fri, 17 Feb 2023 11:00:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E15A76B0073; Fri, 17 Feb 2023 11:00:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D0FF36B0071 for ; Fri, 17 Feb 2023 11:00:14 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4922DAAF1F for ; Fri, 17 Feb 2023 16:00:13 +0000 (UTC) X-FDA: 80477245506.16.CD20B2F Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf30.hostedemail.com (Postfix) with ESMTP id 54DFB80025 for ; Fri, 17 Feb 2023 16:00:11 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sUkblHuJ; spf=pass (imf30.hostedemail.com: domain of 3iaTvYwYKCLYoaWjfYckkcha.Ykihejqt-iigrWYg.knc@flex--seanjc.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3iaTvYwYKCLYoaWjfYckkcha.Ykihejqt-iigrWYg.knc@flex--seanjc.bounces.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=1676649611; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+ASrBAOfhB8V2b1UWnVkBSljvQtym3PPwSnuFL8RngU=; b=j9HTZqBy+eWR+RapniS6Jf8sJPObtuKfHLRZnfdnRidBlJSZgVd1vVJSYGAYTLT138TfyE oyxFt/5pnEWj21/AsicKljCELNYeLfyMnMlHwse8lKt9frhDkzBc16ApvMQnWCc+7EQWx2 Twk2RFvP3kQkGuvLbYWygEIDDypenR0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sUkblHuJ; spf=pass (imf30.hostedemail.com: domain of 3iaTvYwYKCLYoaWjfYckkcha.Ykihejqt-iigrWYg.knc@flex--seanjc.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3iaTvYwYKCLYoaWjfYckkcha.Ykihejqt-iigrWYg.knc@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676649611; a=rsa-sha256; cv=none; b=FlttEkrt5dn9SUVvxf2QXlAB9eMCJZReBwEoTNncq7g8VU+V/cHCrZSdv5czhe6unCTAmW AMCQaxgJuyRBiE8VO9sb1SkY+jyxG5s2T5aRRADV4EHMTVmKBduAbCmUankIjIUUV90U7l D9qLu8JVI2FXYkMeg1lLapZea85auQ0= Received: by mail-pg1-f201.google.com with SMTP id o19-20020a63e353000000b004fb8d5b8aa8so769826pgj.2 for ; Fri, 17 Feb 2023 08:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=+ASrBAOfhB8V2b1UWnVkBSljvQtym3PPwSnuFL8RngU=; b=sUkblHuJ9dulsxh4CZcm+FIp/qRpAAcmRtfvp6ULnSXppIvCitchjm1OUit+QXJRWj fwJ7Xd7LeD3Frj7FzM+U/mMAyXTZ8R5RK0CcMGNMR8PLROcI0/4xgADL5vqH5U+/VYgG dkLQqFX5fKeKJhpV5Gz8z+39KNbu/jjFTFfYD8mmFsM5kC/nK+Gp9BDhC26xn+icV0pC bHQSk7Mqvc6fB6p4dz8MrdQupt1NEggpWvfcZBir6hbXow/Kay6VqXDNaQVda+8NmyZ/ DJpPCojT4dj2fTwoDxf+msJ00C5RYvwVAx1bbgonDLlmp6LfYVABRQ30VMxJGXDgaHEA nfVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=+ASrBAOfhB8V2b1UWnVkBSljvQtym3PPwSnuFL8RngU=; b=b96SeVUxrZJL+3IdlzTOadnya2tHZPliSAB4dbNmJt5/ZtdlHUAyT4GrhTugX4rr+/ LHADpcKW2Lvlp8YpW26Z7hRmy976R0dnou9UQGfcLxtHlk+ru4UIx8feQtvCpxAl7Ro1 KSsGdDRyATWuB8YPTq8YiOJsWaQb0KNg57fdnrIghZnKoWd5MzIIqWWvyfIhEZyORu0w pWIP5+IpC/F6ifPJTI1lYop3g9KLcOtdVVkgxgZyv1NgPN8QVlmVg/BVxEtmiXccNW5z qv3dVXuaYhfEyzJJkPI6BN4wpFU90ojwF32QxfKgOdg8vAUbcPSUGR9MEf7Q7ReIaUj0 0DRQ== X-Gm-Message-State: AO0yUKWcRxYnOqW5F3248ZTMogCfV1DfE+SFB74eyh8715dWM5LEF5Rg h+zZA86Z+0bSYkfJ4/ekKoENcVQxMk4= X-Google-Smtp-Source: AK7set/TQ5moWaaNQcL8V8kGjN9B7zl+2zJIJ8kumCX3x4I/RGgInnGSIHRIAYNv9fJ3WTWtfSDyzLo0yfI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a02:43:b0:4fd:72f3:5859 with SMTP id az3-20020a056a02004300b004fd72f35859mr296462pgb.2.1676649609963; Fri, 17 Feb 2023 08:00:09 -0800 (PST) Date: Fri, 17 Feb 2023 08:00:08 -0800 In-Reply-To: Mime-Version: 1.0 References: <20230217041230.2417228-1-yuzhao@google.com> <20230217041230.2417228-4-yuzhao@google.com> Message-ID: Subject: Re: [PATCH mm-unstable v1 3/5] kvm/arm64: add kvm_arch_test_clear_young() From: Sean Christopherson To: Oliver Upton Cc: Yu Zhao , Andrew Morton , Paolo Bonzini , Jonathan Corbet , Michael Larabel , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-mm@google.com Content-Type: text/plain; charset="us-ascii" X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: mowuzpo4jdycheczycquc1ribgg6k6ie X-Rspamd-Queue-Id: 54DFB80025 X-HE-Tag: 1676649611-154693 X-HE-Meta: U2FsdGVkX1+Buu5dEr4PmySaQSCaRKjfmYGeRrT2EtUQZVRNCoNcSXOoiIpMVrRLbAdxFL2d3W+sepInK7rZqSPGEgEWsZ1PiwQRIE2iVP7mT7ZoGgCZOaRqBrWnhu1+ltpz54qV5dKc+V5zij4in4T2f5b3465vbyQmFkyOnDoQRKlTdaeLdBoeoZKG3lh9rRghcudlVprddEqsXxps+b+rYKNx6JRTMo2Eya7dxMhxsYsx3+p7W18DtqD/A7a54HUe8I9shfKzB1HaS3EM5M5jBcZ7HxlJcgflPcPxMYHdApSkAmP4Cu1iBbGFrOXYx0Gt1gO7dx//eF4xh6nrW6Cv36FRiZ2zf+qrQZu1TmOq0+fv38VIhRgQifDyTWGxmnw4zACG98ZfCeytEHjfh1AmYopPZw4SPCs1L5j9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xw/RpOM+p2P9fBoe4IFeJX8MepmeZiASinqT02YaDbhccFMSHb4V/W/cOwzGSbuBm9HcKnNOEbuo46qVM1RzTf8UMG1H+OOXhBdbZPqV79GgpCaPt6QU1dGK2keSd/qxE47ndXxwB4K+s3AfrVRt5lQSnMztxB/sNs7YwE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Feb 17, 2023, Oliver Upton wrote: > Hi Yu, > > scripts/get_maintainers.pl is your friend for getting the right set of > emails for a series :) Don't know about others, but generally I would > prefer to be Cc'ed on an entire series (to gather context) than just an > individual patch. +1 > > On Thu, Feb 16, 2023 at 09:12:28PM -0700, Yu Zhao wrote: > > This patch adds kvm_arch_test_clear_young() for the vast majority of > > VMs that are not pKVM and run on hardware that sets the accessed bit > > in KVM page tables. At least for the x86 changes, please read Documentation/process/maintainer-tip.rst and rewrite the changelogs. > > It relies on two techniques, RCU and cmpxchg, to safely test and clear > > the accessed bit without taking the MMU lock. The former protects KVM > > page tables from being freed while the latter clears the accessed bit > > atomically against both the hardware and other software page table > > walkers. > > > > Signed-off-by: Yu Zhao > > --- > > arch/arm64/include/asm/kvm_host.h | 7 +++ > > arch/arm64/include/asm/kvm_pgtable.h | 8 +++ > > arch/arm64/include/asm/stage2_pgtable.h | 43 ++++++++++++++ > > arch/arm64/kvm/arm.c | 1 + > > arch/arm64/kvm/hyp/pgtable.c | 51 ++-------------- > > arch/arm64/kvm/mmu.c | 77 ++++++++++++++++++++++++- > > 6 files changed, 141 insertions(+), 46 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > > index 35a159d131b5..572bcd321586 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -1031,4 +1031,11 @@ static inline void kvm_hyp_reserve(void) { } > > void kvm_arm_vcpu_power_off(struct kvm_vcpu *vcpu); > > bool kvm_arm_vcpu_stopped(struct kvm_vcpu *vcpu); > > > > +/* see the comments on the generic kvm_arch_has_test_clear_young() */ Please eliminate all of these "see the comments on blah", in every case they do nothing more than redirect the reader to something they're likely already aware of. > > +#define kvm_arch_has_test_clear_young kvm_arch_has_test_clear_young > > +static inline bool kvm_arch_has_test_clear_young(void) > > +{ > > + return IS_ENABLED(CONFIG_KVM) && cpu_has_hw_af() && !is_protected_kvm_enabled(); > > +} ... > Also, I'm at a loss for why we'd need to test if CONFIG_KVM is enabled. > My expectation is that we should provide an implementation that returns > false if !CONFIG_KVM, avoiding the need to repeat that bit in every > single implementation of the function. mm/vmscan.c uses kvm_arch_has_test_clear_young(). I have opinions on that, but I'll hold off on expressing them until there's actual justification presented somewhere. Yu, this series and each patch needs a big pile of "why". I get that the goal is to optimize memory oversubscribe, but there needs to be justification for why this is KVM only, why nested VMs and !A/D hardware are out of scope, why yet another mmu_notifier hook is being added, etc.