Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp208869ioo; Thu, 26 May 2022 01:39:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz+29NGLDOv6RuWbWDFoRffJ30KXD+p/CknvOkIdMsHoB0GuQ3luWIoiIBpZ+FYpLSNfJD X-Received: by 2002:aa7:d2d0:0:b0:42b:c56b:c619 with SMTP id k16-20020aa7d2d0000000b0042bc56bc619mr8657953edr.157.1653554353168; Thu, 26 May 2022 01:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653554353; cv=none; d=google.com; s=arc-20160816; b=x5QPa9iXN31QF+CAWrryan1ImuBMKATezg5JNq7o+46owGvcPwj5y5/G6mMI0fDhzF MrsKlgQPWAxYqIffdkx2rsVeZADX9R9TZv0NJ3Q3vJ4R110Omm/THEZZdbRVKXcCFXsG BVoq2IM8xms2/gnfuoB0NlG0tNBe8lBpcQ8cgGaBbgEFuLt7C2bzGTGl+j9SO6C/RY27 kEKvFZIzn07bc7a3l6JJhQuHXYQPwlbwoKEoHv6oOdtN4uuG29oWtupfxfAomasle1h/ wCUd7ucwE93al07+KN1xexk5tM5QWziD0JwYDWLFB/ZBMplI/fYRlUdfh5uXFZ1UBUXt qs0g== 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=7P8MdhBUHeNYERj02eaiVlo3+1akuXNgpyLjujYYpb0=; b=ZigOGUVa737h4ZnWqGbdpmFYPzmkPZAd9T5gzOjAOccPPMVXCdmbBpQKqTNNXX0luK vuzs+8ysC0A8Oep/S0YKY7Gz5406e2CT26zBNwR0yJfw8Ubx7CNblna9vPoapJlzspaD QRToxr/v9bCQqI525WLEDH3bcCqKw9GEKziH9wkStHxIyb23EyhZHc5mNSwN/hzc78Q9 7z7hGdDl71unsHNE69osmyz6lnt3KtfR8scSXUYKsu39WAdJbpQ//c73iivubihh+xu1 f/Dlq7GT9IMgB62FxqQuDWhElg6wtOasxLdbRFVfosyr5ugD+6iZnhVDGNi9jOh7boR0 kglw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nGnImQMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd28-20020a170907629c00b006e895dec42asi1116445ejc.198.2022.05.26.01.38.45; Thu, 26 May 2022 01:39:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nGnImQMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344641AbiEZAjD (ORCPT + 99 others); Wed, 25 May 2022 20:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236465AbiEZAi7 (ORCPT ); Wed, 25 May 2022 20:38:59 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07FA9B82D4 for ; Wed, 25 May 2022 17:38:58 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id 202so438019pfu.0 for ; Wed, 25 May 2022 17:38:57 -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=7P8MdhBUHeNYERj02eaiVlo3+1akuXNgpyLjujYYpb0=; b=nGnImQMrxcKuAMPfn2cnaf9VK34koPZI6BdWd8L/dvJkOmKEczFMWc8Yx7hsQFZeVL 9KLxd0tBqQk1/z15iyaTJQGyj+rpJcqO/oigF6/cI0x8g+X/Xo/VBfVgAonu8k6z7tAw rX3SONGBqur0M8KowUWh/wmc3aYT+yOgmGgvthbF1GbnQhkOPFYSCTfv0l7sg5kj2jls D/lYOdddeRohuY3mRJGYNVA5mDFRmRi5K+xU9HMyUH4O1+TPylZTZEwi6U0ynqv/r7ZQ PEcsEwLY3XMn7/TlPZPqXhp0uzspbOfW5miRUT3ck3ZbCGUmofEeJzc2ijyz7b5LJr0L 9x9Q== 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=7P8MdhBUHeNYERj02eaiVlo3+1akuXNgpyLjujYYpb0=; b=WyUiarZ+63G3hx8W1Y4bYhv2qxx6QdITGgLqcFpJotjuijw9YQ30daOcWJObr+gGbP hRXLfj01K1Rpe5TzXY7kpZgwf8M8rhaA5J0ni4yhrP5YXbd0JOG6J/f8eUzmalcC1mWt idlsHu/JJY0/YA6j1SQ2Zj3q+r1i0ziyFb+UfGFadgm7t+swyrrM0kHCrL9OavzjCmhS XG+helB/Zur9LK9higoQ5d6G9XKcfq/muSIF8XOS+UeHe0bwD7vavjNrl/BNTOOT/Ser C3v355TfyNn0uQdShd5RMo23fLiTBVRd+LSLvBdAJRF4NdeSP5j+ErfCEog2pNziAwyc IsHA== X-Gm-Message-State: AOAM532m+kPzH4s0F2IBTjyPNVuZwkawvLAR+wGU+dkPFMvnPH0iKmrx yRKdpKJs/ThrTJ/3VuEp8tk2KQ== X-Received: by 2002:a62:1413:0:b0:518:4259:200e with SMTP id 19-20020a621413000000b005184259200emr34153334pfu.41.1653525537153; Wed, 25 May 2022 17:38:57 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id bh8-20020a056a02020800b003f5cc9c31e2sm141353pgb.38.2022.05.25.17.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 17:38:56 -0700 (PDT) Date: Thu, 26 May 2022 00:38:52 +0000 From: Sean Christopherson To: Johannes Weiner Cc: Yosry Ahmed , Shakeel Butt , 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 , Oliver Upton , Cgroups , 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: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Wed, May 25, 2022, Johannes Weiner wrote: > On Tue, May 24, 2022 at 03:31:52PM -0700, Yosry Ahmed wrote: > > I don't have enough context to say whether we should piggyback KVM MMU > > pages to the existing NR_PAGETABLE item, but from a high level it > > seems like it would be more helpful if they are a separate stat. > > Anyway, I am willing to go with whatever Sean thinks is best. > > Somebody should work this out and put it into a changelog. It's > permanent ABI. After a lot of waffling, my vote is to add a dedicated NR_SECONDARY_PAGETABLE. It's somewhat redundant from a KVM perspective, as NR_SECONDARY_PAGETABLE will scale with KVM's per-VM pages_{4k,2m,1g} stats unless the guest is doing something bizarre, e.g. accessing only 4kb chunks of 2mb pages so that KVM is forced to allocate a large number of page tables even though the guest isn't accessing that much memory. But, someone would need to either understand how KVM works to make that connection, or know (or be told) to go look at KVM's stats if they're running VMs to better decipher the stats. And even in the little bit of time I played with this, I found having nr_page_table_pages side-by-side with nr_secondary_page_table_pages to be very informative. E.g. when backing a VM with THP versus HugeTLB, nr_secondary_page_table_pages is roughly the same, but nr_page_table_pages is an order of a magnitude higher with THP. I'm guessing the THP behavior is due to something triggering DoubleMap, but now I want to find out why that's happening. So while I'm pretty sure a clever user could glean the same info by cross-referencing NR_PAGETABLE stats with KVM stats, I think having NR_SECONDARY_PAGETABLE will at the very least prove to be helpful for understanding tradeoffs between VM backing types, and likely even steer folks towards potential optimizations. Baseline: # grep page_table /proc/vmstat nr_page_table_pages 2830 nr_secondary_page_table_pages 0 THP: # grep page_table /proc/vmstat nr_page_table_pages 7584 nr_secondary_page_table_pages 140 HugeTLB: # grep page_table /proc/vmstat nr_page_table_pages 3153 nr_secondary_page_table_pages 153