Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1046769iob; Fri, 13 May 2022 20:59:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgAVOaohPwatvwrID0o44d/RmZar4a2YOQUUJyjMet0fGVoigrIo1VHUUkAByqOZiW8aV8 X-Received: by 2002:a05:600c:2113:b0:394:54ff:415c with SMTP id u19-20020a05600c211300b0039454ff415cmr17179815wml.7.1652500777162; Fri, 13 May 2022 20:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652500777; cv=none; d=google.com; s=arc-20160816; b=ZwJkcf6u3Fr/rbccSooZi7uun/2DILYUsQ86DrBQpEkEEQYrRgnQIhfE1LQXYWTt8q DJlZjOirGsElMf6hM5nuQYRaeHtNflC/bPF42vFsmy0QUuOG/YVIcXwzG84Zbmcy3Lin fjj3riSHIFCL6+s5h/uNdSRLAOPRmKxJ5YptVOGMId+JreLnIJqrnha8DCNNvlxCy5yy w/09AmRwSE4nghkIZ5oiNzeebFLpgyXFsgt4SIxf5YfzunHd9WzvVoFga9nepu4aj36j AYJdP+fU6hxavFacgqSiGYnJBhVKAu8eajj1w4GqOlk7F/i1nS6GOrVEB2W86WOElaVI v9bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=z141h5DooZE4FL3AcX+0cKxHlZQWL6e7O/2bq4FL5UY=; b=TyHO8wDJQiYBRjV0IoOzBLTGIqPX4iTVhM1RPpYHzhCUAyc+Uc4zyHSyNEBCryrvPL zssBMYs9m2YQsqVOF1xqp0vG5e8vTpqDygf4L35kWFLiD9IMZiU5uh6uA6MirtolEycP hXShB2cuHo3qNp6YDY7EqMHlM3kEJvwtPVRz5imfHxwSesVf566SBoeiYAizLoYuhP84 E+qJKc+SLdY5aKpnEtUWGAL+xllpeq/4s02qX3f//85HoeHRa6QxrZcuAYQmJ7kG366A 16QjV68Y8+tDu0MJYWybpLOp1/PofZZeU21FkcofT1Hgze6a7+rqv4mTiCQkt9/UKclF wrsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pMpyJUjU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j39-20020a05600c1c2700b0038c77be9cf5si4219023wms.189.2022.05.13.20.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:59:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pMpyJUjU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 99BDB30C453; Fri, 13 May 2022 17:30:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234936AbiEMQM4 (ORCPT + 99 others); Fri, 13 May 2022 12:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235081AbiEMQMr (ORCPT ); Fri, 13 May 2022 12:12:47 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D83303ED21 for ; Fri, 13 May 2022 09:12:45 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id i24so8072075pfa.7 for ; Fri, 13 May 2022 09:12:45 -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=z141h5DooZE4FL3AcX+0cKxHlZQWL6e7O/2bq4FL5UY=; b=pMpyJUjUuK/7b/oFgsoqZPGJMcOKB+7c5car+thP1abZdX0Ernmov9vuFLaqKMGXn2 rG8JUhF6WgH7lMygF4hmuRIwFoCrADaFG0pDWTQKNWoL6WLM69N4kM4KtTQkkoALHWrD mAeJQipbT6/IL+OPcmvLrWT3xFgMFLNWJ+O6dFPVj4sg1KmNHaULMm56Trm/hh8TOipy uhaRQ/7aUedXdd9J0nEfOtBBAWb0ZPzn5j4jRptmc960+ldd4gTqKw70bR33LbaLOe4i OR/28/FZmY9vcAYQkNkQbiAC8Sl0bxsa6t+sHaEyvc1goNVOfOnpsfXq5AH2VoYmLRhW N/PQ== 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=z141h5DooZE4FL3AcX+0cKxHlZQWL6e7O/2bq4FL5UY=; b=u3UkaJfCnQejfYLid2OgBD/1o815rc5LgfmW1KipfEbHilfRWed8TBMYefFaoDEk5z Uc6tuPwmb5piHKTyy56Rnw2V8OYJGZLU9xoUi9WcUEvEac+lYhQ0MunNJetje7CmYWE/ nKQ1QHsoxYM7MdXU32ajWElSRFy1VG2Aubv5HfW/ALsHrNNJcrDpxxa/xAoatQr3Wavi bfaiiPMMeUF8NkW+SjJ+Ky4GfLM/+utI4M4VuG9ZauTf3KiKB+eoYL0tL4p6eIkwEU4i mhLQ0fvDuefkPsitAWFCECKCLtM1Sa5WJDtdAKhsVB+Klu3M6Q/usMMDuxqN7b7CkBpM iT1Q== X-Gm-Message-State: AOAM530sj2A+J03rMJSykzRT7qJJ3admIRbBfPN3yLSx17rdZ101DIFv j+dUaz64C+7jUekvsxIB3iQSaw== X-Received: by 2002:a63:190d:0:b0:3db:11ba:cdb3 with SMTP id z13-20020a63190d000000b003db11bacdb3mr4564735pgl.81.1652458365185; Fri, 13 May 2022 09:12:45 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id c9-20020aa78e09000000b0050dc76281ebsm1952250pfr.197.2022.05.13.09.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 09:12:44 -0700 (PDT) Date: Fri, 13 May 2022 16:12:40 +0000 From: Sean Christopherson To: Johannes Weiner Cc: Yosry Ahmed , Marc Zyngier , Tejun Heo , Zefan Li , 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 Mailing List , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Linux-MM Subject: Re: [PATCH v4 1/4] mm: add NR_SECONDARY_PAGETABLE to count secondary page table uses. Message-ID: References: <20220429201131.3397875-1-yosryahmed@google.com> <20220429201131.3397875-2-yosryahmed@google.com> <87ilqoi77b.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 13, 2022, Johannes Weiner wrote: > On Thu, May 12, 2022 at 11:29:38PM +0000, Sean Christopherson wrote: > > On Thu, May 12, 2022, Johannes Weiner wrote: > > > On Mon, May 02, 2022 at 11:46:26AM -0700, Yosry Ahmed wrote: > > > > On Mon, May 2, 2022 at 3:01 AM Marc Zyngier wrote: > > > > > What do you plan to do for IOMMU page tables? After all, they serve > > > > > the exact same purpose, and I'd expect these to be handled the same > > > > > way (i.e. why is this KVM specific?). > > > > > > > > The reason this was named NR_SECONDARY_PAGTABLE instead of > > > > NR_KVM_PAGETABLE is exactly that. To leave room to incrementally > > > > account other types of secondary page tables to this stat. It is just > > > > that we are currently interested in the KVM MMU usage. > > > > > > Do you actually care at the supervisor level that this memory is used > > > for guest page tables? > > > > Hmm, yes? KVM does have a decent number of large-ish allocations that aren't > > for page tables, but except for page tables, the number/size of those allocations > > scales linearly with either the number of vCPUs or the amount of memory assigned > > to the VM (with no room for improvement barring KVM changes). > > > > Off the top of my head, KVM's secondary page tables are the only allocations that > > don't scale linearly, especially when nested virtualization is in use. > > Thanks, that's useful information. > > Are these other allocations accounted somewhere? If not, are they > potential containment holes that will need fixing eventually? All allocations that are tied to specific VM/vCPU are tagged GFP_KERNEL_ACCOUNT, so we should be good on that front. > > > It seems to me you primarily care that it is reported *somewhere* > > > (hence the piggybacking off of NR_PAGETABLE at first). And whether > > > it's page tables or iommu tables or whatever else allocated for the > > > purpose of virtualization, it doesn't make much of a difference to the > > > host/cgroup that is tracking it, right? > > > > > > (The proximity to nr_pagetable could also be confusing. A high page > > > table count can be a hint to userspace to enable THP. It seems > > > actionable in a different way than a high number of kvm page tables or > > > iommu page tables.) > > > > I don't know about iommu page tables, but on the KVM side a high count can also > > be a good signal that enabling THP would be beneficial. > > Well, maybe. > > It might help, but ultimately it's the process that's in control in > all cases: it's unmovable kernel memory allocated to manage virtual > address space inside the task. > > So I'm still a bit at a loss whether these things should all be lumped > in together or kept separately. meminfo and memory.stat are permanent > ABI, so we should try to establish in advance whether the new itme is > really a first-class consumer or part of something bigger. > > The patch initially piggybacked on NR_PAGETABLE. I found an email of > you asking why it couldn't be a separate item, but it didn't provide a > reasoning for that decision. Could you share your thoughts on that? It was mostly an honest question, I too am trying to understand what userspace wants to do with this information. I was/am also trying to understand the benefits of doing the tracking through page_state and not a dedicated KVM stat. E.g. KVM already has specific stats for the number of leaf pages mapped into a VM, why not do the same for non-leaf pages?