Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp2072565rwb; Fri, 5 Aug 2022 12:42:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6SU/LtgM78zyrRzCX1ni8OYcxYewL9zXigQvIJJxPKJMfdbjccq5h7WGVtQGp0JreMvuMJ X-Received: by 2002:a05:6402:612:b0:43d:5049:4d0f with SMTP id n18-20020a056402061200b0043d50494d0fmr7997971edv.127.1659728559935; Fri, 05 Aug 2022 12:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659728559; cv=none; d=google.com; s=arc-20160816; b=TMR5qkqAsHiyvwmCa/ikpdG+uTiwKQx75PRTTT7wr6wF6iQq44QuEFUG3vsjOWy0i4 4MtpzaTrCCTMfWvxbpKd1Yxz/54B9y6q7El+651r0tzOQ6jdPjd4mSKOJ2wIPf4nCTZe TfuFHZZcYRyeyiti01W4FWFI1GadjccTDF5vLQyq+of415rj8PEdEPHElqh1U+6KaXGI 1vX033Bgqrw0HRjAFWILNtvaLe+U5x4XV9udjU8tWwH0DNIhEy0pyNaaXKfyFp99W+X+ YmAFh0AJDpsEtSFTjkCNqnYFrdbcFBVQ6A5rM+KA4AUluUlxZ4/cHXWAUkJ2BooWRMUQ 8KLQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RKUUIUL1iHAOgJ7936O2ZK1JZMqC/oeNpBXr/pO1c2M=; b=PLGni1ML1mbxW0+lVSBCftCgxzjlhs0sXTVF8p5pqU7FXXrEAQ0MXGsRLYdsigASt4 Vki+WpPmq5G7pBaA7aBm1Y4lwsp+FUEiJjq7oy5Xs31AOGsWXedchtfwrSAxLFpY2mrN 5T5YbBcupkgzCxywbIAhD5VJg4AcBl7XPaRv/mseUi0gLYmvh4FvJQPbp6dLdBvoI59m 4DJ0pSwtYmBmb5t8jVYazaplJRiwo3cljAHgWJ6SrAPQWGp8o029OMv2TY9TytKQOb1f X5S8SBtJLrNOYJlHMv9f4M90HH9o+D4Llv2sJo3OmjsmkKXRSCH+kpAVSW9QCwRtpzdn htOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XJonR3uw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c24-20020aa7d618000000b0043dd6e6e0dcsi449448edr.205.2022.08.05.12.42.15; Fri, 05 Aug 2022 12:42:39 -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=@infradead.org header.s=casper.20170209 header.b=XJonR3uw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241577AbiHETZW (ORCPT + 99 others); Fri, 5 Aug 2022 15:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241552AbiHETZB (ORCPT ); Fri, 5 Aug 2022 15:25:01 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413717D797 for ; Fri, 5 Aug 2022 12:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=RKUUIUL1iHAOgJ7936O2ZK1JZMqC/oeNpBXr/pO1c2M=; b=XJonR3uwtW+WFiDJvcdgEOl5Kg L664nZw2YIp6hE1O6Qa+MmAJJ4n0YqnRjJBba1/WsTLd9MgOcskgoMdSRVSB2JbQm1LVodaeCXU+q 7iHdF1eiEah4flMBuDP7zr50XS1sGdOl1hrQD/cGRypY011bkx1UCICnW09y2C+Pppfp9+5F3+iYY jUy6BGqiw16FGVBSikLW2qXTeGZJ14+ksYukXsbdKqTPnMHt829lbOqZhcHf8GwbO3n8ZlOFAGRqv weBjofOa+m4GgZLBgWKRsxY8yWv4FOzwuIyso3BHJO1mhGCUmzJVz6/Nfb8+FHUMLGb7lKjKsrnJR jUP1fpVg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oK2vp-00BVNL-VE; Fri, 05 Aug 2022 19:24:26 +0000 Date: Fri, 5 Aug 2022 20:24:25 +0100 From: Matthew Wilcox To: Rik van Riel Cc: "Alex Zhu (Kernel)" , Kernel Team , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" Subject: Re: [PATCH v3] mm: add thp_utilization metrics to /proc/thp_utilization Message-ID: References: <20220805184016.2926168-1-alexlzhu@fb.com> <0b16dbac6444bfcdfbeb4df4280354839bfe1a8f.camel@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0b16dbac6444bfcdfbeb4df4280354839bfe1a8f.camel@fb.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Fri, Aug 05, 2022 at 07:04:30PM +0000, Rik van Riel wrote: > On Fri, 2022-08-05 at 19:50 +0100, Matthew Wilcox wrote: > > > > > > This change introduces a tool that scans through all of physical > > > memory for anonymous THPs and groups them into buckets based > > > on utilization. It also includes an interface under > > > /proc/thp_utilization. > > > > OK, so I understand why we want to do the scanning, but why do we > > want to > > report it to userspace at all?? And if we do, why do we want to do it > > in > > this format?? AFAIK, there's nothing userspace can do with the > > information > > "93% of your THPs are underutilised".? If there was something > > userspace > > could do about it, wouldn't it need to know which ones? > > > > Isn't the real solution here entirely in-kernel?? This scanning > > thread > > you've created should be the one splitting the THPs.? And anyway, > > isn't > > this exactly the kind of thing that DAMON was invented for? > > Alex does have an (in kernel) shrinker that can reclaim > underutilized THPs in order to free memory. Ah! So when that exists, this interface tells us "how well" we're doing. > This is a regular shrinker called from kswapd. I am not > sure a shrinker going through the DAMON infrastructure > would be any smaller, faster, or better. OTOH, DAMON > does allow for more flexible policy... > > Getting some info on the effectiveness of the shrinker > seems useful, though. Could debugfs be a better place? > Should this be resubmitted together with the shrinker > code that makes this more useful? Yeah, debugfs seems like a better place. And I'd love to see the shrinker code. Before you mentioned that I was having all kinds of peculiar feelings about this code. For example, suppose you have incredibly hot 256kB of data, but the other 1792kB of data are never touched ... that could cause us to do entirely the wrong thing and break up this THP. Having it as a shrinker makes sense because the hot 256kB will keep the THP from reaching the end of the list and being reclaimed.