Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp619991rdh; Thu, 23 Nov 2023 13:24:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGem4TZwFi+ohh/ZqfWN0RmAVHp9wINPjBRJy+AsWLe1r+f5Lr4kSCNtQn0a78aaI91X6X7 X-Received: by 2002:a05:6602:2a44:b0:79f:d4e6:5175 with SMTP id k4-20020a0566022a4400b0079fd4e65175mr1035462iov.16.1700774667679; Thu, 23 Nov 2023 13:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700774667; cv=none; d=google.com; s=arc-20160816; b=Uc+3WaHwcXyDgwKflPp5vkoriKktnhRc2ODSGjiEpIIYC4YrMVawQJYOg9fWdeSzst KbnlHT8MeMEtO+cr/RlVCDYAP/l3+lltK75NoHJ4AYym+TtjBFGoUzqmRlJd2pAjxl7/ 9qo/q0u3DJDmmPBB+AHZlX2QVleWtBcK6v1jL0HYI8YolUvnoQxAgynhWNt2Hj9FoYva ItgHfuIwuMvoXb8To1eR3SyXWTAWad6XCS1icu+D8IiDcWMy9LNa/qC+9s42U9VVU52z gubeYX9vGfICq26XBIUnAUaMMAW5yvbAIb65XrH9VTqotC1fEZD5SF2/fol7lGrPih9O qX3A== 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:dkim-signature:date; bh=7ZLXHI2Ndk3rHHsAuo56iifYdV0BTffvf5dGp9YUFqg=; fh=p93j/5NtDdxscw1HoC47XqsES8pLHjwizQgr9uK58x8=; b=PFArk5O/lgcWxRN/cDQ17KwXg0YxcboTD/LCVRkxNfZT+qjp69/POR5xwTdTW+l4rG j/STnfmDS57xzvULDsw1U6dzBnOZ1WNN8+399vY9O9LDrWzqbfPErfmQeBbMfidaTSus JwGnxip3FS/WXOYSKs2JMC57b3sKm7ksFTH1QCV7nAPUsiTouEDw0o+KKPMHgQf81pJz Mg964WSdcrEuwT6Ad/nVN4Y294B+SbH6hkFvoDpVcUj7F5mJZqeAw2OkvsVr/qX2i8us 9lfgGUHZwkb+t30kMQfMbA0wm0FKZrMKO5eTZip5y0VPCDF0W672UyAT46g82pcJnFYI 3sMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XxPzFZrt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id be14-20020a656e4e000000b005bd27920754si2314645pgb.204.2023.11.23.13.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 13:24:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XxPzFZrt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7E573828C4A3; Thu, 23 Nov 2023 13:24:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229478AbjKWVYM (ORCPT + 99 others); Thu, 23 Nov 2023 16:24:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjKWVYL (ORCPT ); Thu, 23 Nov 2023 16:24:11 -0500 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [IPv6:2001:41d0:203:375::b0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58297130 for ; Thu, 23 Nov 2023 13:24:17 -0800 (PST) Date: Thu, 23 Nov 2023 16:24:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700774655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7ZLXHI2Ndk3rHHsAuo56iifYdV0BTffvf5dGp9YUFqg=; b=XxPzFZrtvipkxFgmFlx/ExysB/xnfphkaUcLFZbqpwUXkPvQsLc2IZXsi299cEJPyvv/14 pfZlRTUxePNx0ah8qULgO/bJzkahkISeivJkSuhB2Y/7Y6xSyf5zaU3Vwl2JSZjX1Uuv7S NDq+tYptKfF1tikav+qzthg5l6luMeM= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Qi Zheng Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Qi Zheng , Roman Gushchin , Dave Chinner Subject: Re: [PATCH 2/7] mm: shrinker: Add a .to_text() method for shrinkers Message-ID: <20231123212411.s6r5ekvkklvhwfra@moria.home.lan> References: <20231122232515.177833-1-kent.overstreet@linux.dev> <20231122232515.177833-3-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 13:24:25 -0800 (PST) On Thu, Nov 23, 2023 at 11:32:59AM +0800, Qi Zheng wrote: > > + void (*to_text)(struct seq_buf *, struct shrinker *); > > The "to_text" looks a little strange, how about naming it > "stat_objects"? The convention I've been using heavily in bcachefs is typename_to_text(), or type.to_text(), for debug reports. The consistency is nice. > > > long batch; /* reclaim batch size, 0 = default */ > > int seeks; /* seeks to recreate an obj */ > > @@ -110,7 +114,6 @@ struct shrinker { > > #endif > > #ifdef CONFIG_SHRINKER_DEBUG > > int debugfs_id; > > - const char *name; > > The name will only be allocated memory when the CONFIG_SHRINKER_DEBUG is > enabled, otherwise its value is NULL. So you can't move it out and use > it while CONFIG_SHRINKER_DEBUG is disabled. Good catch > > +void shrinkers_to_text(struct seq_buf *out) > > +{ > > + struct shrinker *shrinker; > > + struct shrinker_by_mem { > > + struct shrinker *shrinker; > > + unsigned long mem; > > The "mem" also looks a little strange, how about naming it > "freeable"? The type is just used in this one function, but sure. > > > + } shrinkers_by_mem[10]; > > + int i, nr = 0; > > + > > + if (!mutex_trylock(&shrinker_mutex)) { > > + seq_buf_puts(out, "(couldn't take shrinker lock)"); > > + return; > > + } > > We now have lockless method (RCU + refcount) to iterate shrinker_list, > please refer to shrink_slab(). Will do!