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 720F7C3F6B0 for ; Tue, 26 Jul 2022 18:04:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0EA28E0002; Tue, 26 Jul 2022 14:04:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 997028E0001; Tue, 26 Jul 2022 14:04:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 811068E0002; Tue, 26 Jul 2022 14:04:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6AD918E0001 for ; Tue, 26 Jul 2022 14:04:03 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 44C4B1C1EBC for ; Tue, 26 Jul 2022 18:04:03 +0000 (UTC) X-FDA: 79730024766.03.D3E1447 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf05.hostedemail.com (Postfix) with ESMTP id C907A100093 for ; Tue, 26 Jul 2022 18:04:02 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id w185so13925551pfb.4 for ; Tue, 26 Jul 2022 11:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jhdzRZUAOMTnCV/vW7pBqgsIJIfjNF/pYz/pr69nELI=; b=ptd/st7Qx1CEBd6nXVmofsETHlqEG5YHpXzAHoHWMHaxaLqLQRwhFD8DrqTGh313HP IhmbQkRu0orlHojxKg773kXGBU90oYKT/i2R8RIWnvFI/6XWjOJwk/NLwViv8Eohzc71 0u1CxuXzpRO+SKGj4rghNIk24TUgiK6N5EMVsSWyZucFXHEwqrREOemBmRGcO21GlJv+ BHPELPoCCxRkiXuj0q4tx3KOjfEFuVK8aaztJ92oE13l2AqbgmCf3A+ZhaLe8cNklHQ/ gZtTgJkayqLParwE71HzxpR93H5vfYmTwDBbX/RNcN9pr066yekhsOaOlX87QwoQCIMQ U+yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jhdzRZUAOMTnCV/vW7pBqgsIJIfjNF/pYz/pr69nELI=; b=P1rkbmdUKivcNZcZJ31/3u7BE65uKwVcCtb3uOIMj3V8VBQj3KeGv6c7/Q4agN4Ew6 8pdoumVCpZ0sXisYlWzxuwtz0ydPjLyyr53UlhGx7NAp9FV7kQatC/Lu/KnmmNWWq63l muXZIM6OZIwOtNICGyzE9s/tiqtz8QouoSj8Tbk6Cs2yCdCMdbSEk6j4R9T24RmYGDjz e5VzCM5PK5/UGS8cld2CeFvLHnUe4VwAk8qhbYe5hRuFOrAlixeU8hTd8XA3YAfeyoxt BN2/lYQUES8ohlNpRttg2wobyYuKDqIfVTg6r5eA9GcPtqOzdyxIrZlJ9GYmmlO4yL/V dceQ== X-Gm-Message-State: AJIora9WGokMb/kthBby6ZiUMtD1kqEo8KB3MeTEKy/tuosQZZBaw+fc CEMJpo0Mesl/a341UVzs9VWKSQ== X-Google-Smtp-Source: AGRyM1uKR6/hOW723JGGrSJD19noCDp0+vmsYlXYClvLLQpEtHJHtnV8BUou5cQTx2omdbkUrVjS2Q== X-Received: by 2002:a05:6a00:1c54:b0:52b:a70e:8207 with SMTP id s20-20020a056a001c5400b0052ba70e8207mr18313321pfw.48.1658858641379; Tue, 26 Jul 2022 11:04:01 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id f4-20020a170902860400b0016be0d5483asm11848682plo.252.2022.07.26.11.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 11:04:00 -0700 (PDT) Date: Tue, 26 Jul 2022 18:03:57 +0000 From: Sean Christopherson To: Mingwei Zhang Cc: Yosry Ahmed , Tejun Heo , Johannes Weiner , Zefan Li , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Andrew Morton , Michal Hocko , Roman Gushchin , Shakeel Butt , Oliver Upton , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v4 3/4] KVM: x86/mmu: count KVM mmu usage in secondary pagetable stats. Message-ID: References: <20220429201131.3397875-1-yosryahmed@google.com> <20220429201131.3397875-4-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658858643; a=rsa-sha256; cv=none; b=hPTLltk02LII81MoVyuCzyDZpAGJfXZNt2ZoZS3y3jduaZUek/aYylPBQ0IDlgh1Brm0Y1 FBsd2rwEvpjyKyrueU62nR1BYgRClMu2I0B6sA8Hp6y5LBDk17R/RaTgpKT2ZMuW8NiLTo atH70Mgs3t3HD7TPyeJgLhbVunZMihU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="ptd/st7Q"; spf=pass (imf05.hostedemail.com: domain of seanjc@google.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=seanjc@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=1658858643; 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=jhdzRZUAOMTnCV/vW7pBqgsIJIfjNF/pYz/pr69nELI=; b=tJ3sIiXaKXpOi+YH7x/pZET/dIGI1yfJiIyIFCsAS7Gbabt9xXXr0ITnGtwC0UZdi5LPtA 5HWlyKxjnUM8m/06IGK4IjIG6K8xgm9wZcGQJU1DVN/xZAGcOOKCBlYFSWi5Gav9wNXZ2T 7vwavVcKrCULqIUDofcJbuWbHSQN/Vk= X-Rspamd-Server: rspam02 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="ptd/st7Q"; spf=pass (imf05.hostedemail.com: domain of seanjc@google.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=seanjc@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: psa4umm3mfu5deemn7cgd8bpirx7w1e6 X-Rspamd-Queue-Id: C907A100093 X-Rspam-User: X-HE-Tag: 1658858642-793336 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, Jul 22, 2022, Mingwei Zhang wrote: > On Fri, Apr 29, 2022, Yosry Ahmed wrote: > > Count the pages used by KVM mmu on x86 for in secondary pagetable stats. > > > > For the legacy mmu, accounting pagetable stats is combined KVM's > > existing for mmu pages in newly introduced kvm_[un]account_mmu_page() > > helpers. > > > > For tdp mmu, introduce new tdp_[un]account_mmu_page() helpers. That > > combines accounting pagetable stats with the tdp_mmu_pages counter > > accounting. > > > > tdp_mmu_pages counter introduced in this series [1]. This patch was > > rebased on top of the first two patches in that series. > > > > [1]https://lore.kernel.org/lkml/20220401063636.2414200-1-mizhang@google.com/ > > > > Signed-off-by: Yosry Ahmed > > --- > > It looks like there are two metrics for mmu in x86: one for shadow mmu > and the other for TDP mmu. Is there any plan to merge them together? There aren't two _separate_ metrics per se, rather that the TDP MMU (intentionally) doesn't honor KVM_SET_NR_MMU_PAGES, nor does it play nice the the core mm shrinkers. Thus, the TDP MMU doesn't udpate kvm_mod_used_mmu_pages(), which feeds into both of those things. Long term, I don't think the TDP MMU will ever honor KVM_SET_NR_MMU_PAGES. That particular knob predates proper integration with memcg and probably should be deprecated. As for supporting shrinkers in the TDP MMU, it's unclear whether or not that's truly necessary. And until mmu_shrink_scan() is made a _lot_ smarter, it's somewhat of a moot point because KVM's shrinker implementation is just too naive for it to be a net positive, e.g. it tends to zap upper level entries and wipe out large swaths of KVM's page tables. KVM_SET_NR_MMU_PAGES uses the same naive algorithm, so it's not any better.