Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp985503iob; Fri, 13 May 2022 18:37:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpUslN8gwRhdCXDLFpNRuCeaiPQgaigF1Lb+g+oDJzWhtK1h+tYfhPUhzGr2O2r/OWSv3F X-Received: by 2002:adf:ec08:0:b0:20a:d39d:6ab6 with SMTP id x8-20020adfec08000000b0020ad39d6ab6mr5947556wrn.442.1652492237291; Fri, 13 May 2022 18:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652492237; cv=none; d=google.com; s=arc-20160816; b=RpXH9qbygjt4ld+1Y76DfMZ9u2UvVaFGQcx2rV7z6hijTicdGINB+Ssu1/38aIoAnj YZWDNU9trYqJS+bXXxdQO4MaLrymaFIk88reaX3+dQivdLwaCDCqWNmjnn7MrDHgx7+x rrNgGGrpqDdTls4l5POYW0bpdhax0RZ2PFWgl6s/w25IrIJ93mzWNtD3Lkjo6JHSEKiD UEzBpTaHqE52sSl8GvInYn0fF9waDba/f17pwoo/GR5v6DK3Fp+OuZg3D3czk87jpXkc 9GyKEvwpr0ewpsH1+GNLzl+ijg+O+XLczgYhN90VxzxeT4n1nGBvH65yrEMHmModfP18 9U/g== 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=Kye4TfWEBKeNkvsN1Z8PpM0cIuVevPyfJP2pQ+b2OJ0=; b=GXiQmVEoOSC1lOxg8jeUBkXOlXm+qn/tEz9yqQ4LkpCFub3PsgaDtTx5CADi1iAFz3 TahCX2hipShO4wkONVmjmZLE6H+sQOq9MnGqYv+GoCSN68df/k78nCCGHKNjIRUNmMwD tq+hHA/8KVzimJZ1APEfTf7akcFRvJLcU+AV26AT6k1wY6hmrUHPaIaOjp2E8M+N9Q3D /AYaFhTyGX07bBHntRz+88D3YQFPhNs2K50JvRTHXgsUnqG+M9hYuC/fxAb+ZMyl5H8w k7YBmkZJlcL/fEh6ltxhtnXogZL+lHN2VbGsolhe0Vd5MF/tqMoZXDjjaoaPn3F7BhFC FbNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b="ZZ/JJCRD"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w3-20020a5d4b43000000b00207a1edfbb3si3171502wrs.453.2022.05.13.18.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:37:17 -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=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b="ZZ/JJCRD"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EBDEA416D37; Fri, 13 May 2022 17:04:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348833AbiEMPuZ (ORCPT + 99 others); Fri, 13 May 2022 11:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235076AbiEMPuX (ORCPT ); Fri, 13 May 2022 11:50:23 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498CF164C89 for ; Fri, 13 May 2022 08:50:20 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id dv4so6927581qvb.13 for ; Fri, 13 May 2022 08:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Kye4TfWEBKeNkvsN1Z8PpM0cIuVevPyfJP2pQ+b2OJ0=; b=ZZ/JJCRDz3yE4ILSty048bcbPErmsDUK3HlgCxPZevGvO0s7lKzzyxYdFDw1dJf9ph MIp+dwz/aXhjTfmLJaPj/lFR5KENnPsRIaVfRdKCuXnMx6qMaG0uPs9glvL+IiheyQV+ I8N0k1bffzWgc5Xm+tBeTXdy8CbQJfgCaMsHgTm1sfLVt/+VGnsbnrEpzH2RKA967Lgp i0c6ZYtdpmtmfZZuTg2GnWU+ABJlGS07aIDJN1CLeOQkEF/JyGUWyE+RbOazEYEr/CaR 3SpCLEHRQ4pi9gjxDfMWcHE6xNgzt5GERI+gy2A1oDXWEszhLZUV5HDLMnSPDj/P5+Pq xL0Q== 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=Kye4TfWEBKeNkvsN1Z8PpM0cIuVevPyfJP2pQ+b2OJ0=; b=ont3fXi+lZo07IGsWpwUOEHfRgbu+mrBr+Sf/y0S40eR3TI/bSHQ7uSNCCtNKUU2/S FpkumssiI/vHZWTc1fu4Efe5cWYLri+NUtcMi8U3r4FihlXj5l37p2wUhld30s/2AGr8 yvazd44s1etrdi4fTqd0Vj6arRoL7tSNkP889QW4gVCiegYDR8V4ggqE7HXdxM3DDyxJ 4odqxoEv3zfINSWmMujC0Ni9x5yiuasEuHmkGOJbPpTaqcBtSP9OHeODGb0ZVTIDR35M xaXa4HzVrmrPAb9vCB9W3lq0OswwWoaINtoQs7DAdO+x8mNTaWYGN+gaGZglg/LK6ZnR 79Zg== X-Gm-Message-State: AOAM531z1DromhRFK20jwx0uIFt/wSlf2n4s7pK93yRinMsGLHrgbxF0 1SKKP3BUpXQuyLdnxyv+zFDpZw== X-Received: by 2002:a05:6214:401a:b0:459:5a57:ba6f with SMTP id kd26-20020a056214401a00b004595a57ba6fmr4923590qvb.96.1652457019420; Fri, 13 May 2022 08:50:19 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:14fe]) by smtp.gmail.com with ESMTPSA id f6-20020a05622a114600b002f39b99f69esm1622685qty.56.2022.05.13.08.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 08:50:18 -0700 (PDT) Date: Fri, 13 May 2022 11:50:18 -0400 From: Johannes Weiner To: Sean Christopherson 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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 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? > > 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? Thanks