Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4245687rdh; Tue, 28 Nov 2023 16:34:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtVU62BFzMzna2tHVeOF5x+Nqe0nIm5qZNfbu6tyLalwxsYPuNScYDH4BMCLyRkwXXnjHq X-Received: by 2002:a05:6a20:748d:b0:18b:594a:284c with SMTP id p13-20020a056a20748d00b0018b594a284cmr27042458pzd.15.1701218097549; Tue, 28 Nov 2023 16:34:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701218097; cv=none; d=google.com; s=arc-20160816; b=PbjdqNW/6UfkGN+PqzSONaq0BNk+DIwNsJSJd0wztMiBymlcy6+QdYw+GqDqqKAngf yaWF3dQqDAPqVZaL8uJEpNENm9PsqIGr19dEk88qD8BENJSDsb4rHWhS78hVYFBJQ79f Ur6dZVn57Qv54tZYdmsBWIjQgXpjYUOeL+Ec2o6y+AP6rqzps2E85Dk9AwDqx3LKEQ/P 8J5ZYofK7c0IrBGVVQMnIu9m8ry7sRhmHmlIX3SoKsJqnw/QHbWRS52w0/mEEOb7dJg4 DoSAuIO6YkiwCF6jipixN5YK3hdefzip9v9aYatnmSSS/kkoTaPHw51TVU95LI6uxd0i pgWQ== 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=eCG5NdHCzdxGKVLi7pGKuTOz+k6jebi5zet5ZX/JZ48=; fh=1tYR+vbXUsSsWc1Q68w2BL85L2TtMK5NyhMjAA/h94Q=; b=aaJHx9LMaiOWKLbMA2xXOzD7LtHLPmJeub9v1pARQAyLQ4dQoWrwJ8s5GuK5aVT9Yh UM0X7Aod/QHnkWBm7AkRZKW4sJp4A1gJLeLvHG3eCxENauk+GAgLz1cglq8tKqD9wTUq Frmk6WBZqUxbiBffPsFhWbiW3HeJSFp/joc2cCem8QBJTZ053Wt2ofOHjzTZ9Zw6nTLL YRnGgPk3Fv6BEQ1+dRkNC2Dlu2OCj5RFLpDc6SI7Te6nsBElseJw951YCAyA47q2POie Iq7/TNXXBPW1JbOOoV1jTiuBXO8Uo4y/J3UJr635uIlVPzd60BUKs1Oe/1MLuMTjye0C gs/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hCs4fXYa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f12-20020a631f0c000000b005898b0b851asi13239926pgf.530.2023.11.28.16.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 16:34:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hCs4fXYa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id CFB94803A5B6; Tue, 28 Nov 2023 16:34:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346649AbjK2Aeq (ORCPT + 99 others); Tue, 28 Nov 2023 19:34:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbjK2Aeo (ORCPT ); Tue, 28 Nov 2023 19:34:44 -0500 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29C5319A6 for ; Tue, 28 Nov 2023 16:34:51 -0800 (PST) Date: Tue, 28 Nov 2023 16:34:35 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1701218089; 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=eCG5NdHCzdxGKVLi7pGKuTOz+k6jebi5zet5ZX/JZ48=; b=hCs4fXYaAgMAWKjmXvNJIPSN4wz1/xn8Hyz7XcidRcR5ozIfrhEmkmovPoPbatOFeyi0sR f5cLYwhH4ikIcioHBYBkI7vKoibpemOsxn9lz03kIJKOsQT9Qe4lcri3b5Zvuiw3zpxZSV NMtLh8oxUJgEibrBLVOJwAD1owi6AO8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Qi Zheng Cc: Kent Overstreet , Muchun Song , Linux-MM , linux-kernel@vger.kernel.org, Andrew Morton , Dave Chinner , Michal Hocko Subject: Re: [PATCH 2/7] mm: shrinker: Add a .to_text() method for shrinkers Message-ID: 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> 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 16:34:56 -0800 (PST) On Tue, Nov 28, 2023 at 02:23:36PM +0800, Qi Zheng wrote: > > > 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. I agree with that. It seems that the feature is mostly useful for kernel developers and it's easily achievable by attaching a bpf program to the oom handler. If it requires a bit of work on the bpf side, we can do that instead, but probably not. And this solution can potentially provide way more information in a more flexible way. So I'm not convinced it's a good idea to make the generic oom handling code more complicated and fragile for everybody, as well as making oom reports differ more between kernel versions and configurations. Thanks!