Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3638927rdh; Mon, 27 Nov 2023 22:24:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNXsfNUHEmXRDDZMVMkS4hDr7kmCqzVMgCjCYrtD3B/WJ6ZYK/+KYnP0IQTaZoyUdJFXJ3 X-Received: by 2002:a05:6a21:192:b0:18b:5b7e:6b9 with SMTP id le18-20020a056a21019200b0018b5b7e06b9mr21188689pzb.2.1701152654633; Mon, 27 Nov 2023 22:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701152654; cv=none; d=google.com; s=arc-20160816; b=lQw4FemDz1BlEyyrHKlheFqjfwmNnlHMXO5Ckk0Xjaw3MAtPA0D8d/J1VLDivUuZeM 47KaSNEpP+SG/Gq09C55j78LGEdCOD29A1oLFD9MayZwJkm+5azlKQcMlqU6dF/xqa1k T3VjdkIN2n7F0y6gTSiYpLmRPql+QUX6MlQBa95dLgvPf62V/OO02N2NWdN0111yE+/7 m1agNC43ITvE3RTg9JbvXLtUBxbhK8oJ1y6LtsOL3IFQ+RY14gyvTCOuuBT1IAxyZH7p ndxO0Bw6q0Bg5chVDmyRZRW8XjZwHAvPVoR3IIX827CoR9FTpuKcSIkE0uD38aIZ0dbm iRHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=LbwrnUh6cvf5haA/BX0nPLmj+8uunF8iu3+nmhJrr78=; fh=QGq/bTQpNfAZiJeWXRwX1QwcFxlbH7UfSAmudQAz5sE=; b=NlX0CfLnQb3RPmzcxd/BMjvkRslyIQDxJ4YmBT2d2dvwCMQTi+DA/VC1oni4ffKfei i3cNfrviQO/MsVmHM1z58ZNQrQLockhUUptePT3WOSCOt0yYt7EyrOp8nCyz7pOIn5D4 XQGofz+ox5yDBoeQWVgt7WM6ISrX7fWfb6Ka4EkNty/y1666DWrlmWMFuqWQBIWrb5/S Wr0mgqwk//ikWZSSrhRqlRCpMohbKmUkRXrnpF9U/8IaLmrG83aUPeA8gs96awJU8uAE fNqBTHAG0mnKMjhQRqizZv3SVqca9wQq7IA7229fG88lxAuQZoAWrdZLJDQ8Bp0y3PH4 P75g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=eqg4cHZB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id a6-20020a654186000000b005ad5178d053si11066024pgq.347.2023.11.27.22.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 22:24:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=eqg4cHZB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id D5AB480E60A8; Mon, 27 Nov 2023 22:24:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343632AbjK1GX6 (ORCPT + 99 others); Tue, 28 Nov 2023 01:23:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232892AbjK1GX4 (ORCPT ); Tue, 28 Nov 2023 01:23:56 -0500 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 999DE183 for ; Mon, 27 Nov 2023 22:23:42 -0800 (PST) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1f9f23b4fa2so1038919fac.0 for ; Mon, 27 Nov 2023 22:23:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1701152622; x=1701757422; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=LbwrnUh6cvf5haA/BX0nPLmj+8uunF8iu3+nmhJrr78=; b=eqg4cHZBkRVQFJQxJk0tiMAtrX8JxIV0TxYsm88yvGpba3WT3PllaIUyu1jSfPRxtG nIuCRfgZEn4rdpvSU00CXxdEQdeZ2M/wdPxM5PreKc5VxixU6PinzwaZNGRRXkQlEUE+ 49hN8/1p9dSJl+jeiGOR+BeLy5vNvtTRQYvyBpA6ldrKyZ+8dvQPPadt96aT0Q0uVISb NO43D/ZR23y54UmLw6HeyEmLWXyZbXjXYw+w4yGEte1MYdRvS1DocmtTnpvYA4hsXrk6 hRBQENeTp0rYzcyCACTbG7COuYAw4CsPXMxCWMBnZZMYijiEdL+uWpmnAZbHHFnMcmBh L0Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701152622; x=1701757422; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LbwrnUh6cvf5haA/BX0nPLmj+8uunF8iu3+nmhJrr78=; b=V6knGSvH9RmJaUxbjs8Wr2A2QDyWmtuwsaUnDf1/YxTY+XwjtKtOhtIpfbHB21uoZk Iw4KFJA0bkIKMVuzWzTsYdReaWLnAo1ViAp+AZfxopjpF/wZcxnSfN8g/EjWI+KZFxIW XOXYJhyH6HeIjojZQZ/n/3I4/aOz7zPRIa+BBP6j2WlydXdM7BTp4RVYSUUqcqHjmaSC n5YRn3ggYmIy93W76fHLOXRtV+T7FSyjakMtAXYIjQHfyqHyj0yTpPnpwYbOfkYVsw9Z zYrW/knglD3okyIyQ/iIQZ7SrkbKbUz2RIxyJa9rlbRsLbASoaoODE/GKJqcg8Kn9tAm H4tg== X-Gm-Message-State: AOJu0YwuZv2ZQzzPBLBR2lGRwvDDvq1QOYWvDZP/7Mqhl5525hU3SpuM UqWT9i+0t9kFZPnMo0egQJifVfTYqMFQojoxI+k= X-Received: by 2002:a05:6870:64a2:b0:1fa:138f:5419 with SMTP id cz34-20020a05687064a200b001fa138f5419mr14947863oab.0.1701152621834; Mon, 27 Nov 2023 22:23:41 -0800 (PST) Received: from [10.84.152.29] ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id f11-20020aa78b0b000000b006c31c0dfb69sm8227059pfd.188.2023.11.27.22.23.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Nov 2023 22:23:41 -0800 (PST) Message-ID: Date: Tue, 28 Nov 2023 14:23:36 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/7] mm: shrinker: Add a .to_text() method for shrinkers Content-Language: en-US To: Kent Overstreet Cc: Muchun Song , Linux-MM , linux-kernel@vger.kernel.org, Andrew Morton , Roman Gushchin , Dave Chinner , Michal Hocko References: <20231122232515.177833-1-kent.overstreet@linux.dev> <20231122232515.177833-3-kent.overstreet@linux.dev> <20231123212411.s6r5ekvkklvhwfra@moria.home.lan> <4caadff7-1df0-45cc-9d43-e616f9e4ddb3@bytedance.com> <20231125003009.tbaxuquny43uwei3@moria.home.lan> <76A1EE85-B62C-49B3-889C-80F9A2A88040@linux.dev> <20231128035345.5c7yc7jnautjpfoc@moria.home.lan> From: Qi Zheng In-Reply-To: <20231128035345.5c7yc7jnautjpfoc@moria.home.lan> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 27 Nov 2023 22:24:12 -0800 (PST) On 2023/11/28 11:53, Kent Overstreet wrote: > On Tue, Nov 28, 2023 at 11:27:11AM +0800, Muchun Song wrote: >> >> >>> On Nov 25, 2023, at 08:30, Kent Overstreet wrote: >>> >>> On Fri, Nov 24, 2023 at 11:08:11AM +0800, Qi Zheng wrote: >>>> Hi Kent, >>>> >>>> On 2023/11/24 05:24, Kent Overstreet wrote: >>>>> 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 >>>> >>>> OK. >>>> >>>>> consistency is nice. >>>> >>>> However, this is inconsistent with the name style of other >>>> shrinker callbacks. Please use the "objects" suffix. As for >>>> bcachefs's own callback function, you can use typename_to_text() >>>> to ensure consistency. >>> >>> That would be inconsistent with introducing a convention to the wider >>> kernel. >>> >> >> I don not think .to_text is a good name. I really do not know what it means >> when I first look at this name. I knew you want to report the objects of >> shrinks, so why not use .report_objects or stat_objects proposed by Qi. >> Although .to_text is only used by bcachefs now, shrinker is a general module >> which is not only serving the bcachefs itself. I think it should be better >> to use a more straightforward name. > > No, .report_objects or .stat_objects would be wrong; this isn't > generating a report on the objects owned by the shrinker, it's just a > report on the statistics of the shrinker itself. Now I think adding this method might not be a good idea. If we allow shrinkers to report thier own private information, OOM logs may become cluttered. Most people only care about some general information when troubleshooting OOM problem, but not the private information of a shrinker. So I thought maybe we could add some general statistics to the shrinker, but adding private ".to_text" method is not necessary. Also +CC Michal, who is reviwing OOM related patches recently. Thanks, Qi > > That's why the convention is typename_to_text() - generate a text > representation of an object of that type.