From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6BC2C04FDF for ; Thu, 27 Jul 2023 22:59:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C74156B0072; Thu, 27 Jul 2023 18:59:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4ADA6B0074; Thu, 27 Jul 2023 18:59:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B128E6B0075; Thu, 27 Jul 2023 18:59:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A069D6B0072 for ; Thu, 27 Jul 2023 18:59:45 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 51BE114055B for ; Thu, 27 Jul 2023 22:59:45 +0000 (UTC) X-FDA: 81058910730.16.6B04CBC Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf27.hostedemail.com (Postfix) with ESMTP id 4AC4140008 for ; Thu, 27 Jul 2023 22:59:42 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=fromorbit-com.20221208.gappssmtp.com header.s=20221208 header.b=X7pt5Ouy; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf27.hostedemail.com: domain of david@fromorbit.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690498782; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8CTrna5t3S7P99W+zrM1I2ApZYIkXTVQedDFVAI6oIw=; b=S4SUTk5NL8izFZnVYecn01oTYV/ncTeS86T+vB8c3RmVHv96ofsRNop+VP4FaL21r65agh JsgYl5eeV6+NVkamQur+K/nngipevyNEh4KGmI5yA11byUbF6CvEe3OmyNVi/OFEwHvXcv 2vsE0XzT3HHHIPJNw+fOTu4nNJq45Jc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=fromorbit-com.20221208.gappssmtp.com header.s=20221208 header.b=X7pt5Ouy; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf27.hostedemail.com: domain of david@fromorbit.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690498782; a=rsa-sha256; cv=none; b=5xb1U/bNbC6xpvJ0OtccIVBMq4gKTzXpanjFsvUvvFLIY14rTCSgefwHP7MHYpg9+t8eOX GadMURXCiKf37HT7mFjNaQy2FQNoab+2f01UgugvjKkHef1J3yGpk3C4qJrBQFb6O+BSqI DmxI3SyQBgtsePxR5AgscpfpJ4cnoVA= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-686f94328a4so673985b3a.0 for ; Thu, 27 Jul 2023 15:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20221208.gappssmtp.com; s=20221208; t=1690498781; x=1691103581; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=8CTrna5t3S7P99W+zrM1I2ApZYIkXTVQedDFVAI6oIw=; b=X7pt5OuyEbf8f6R9fnvI9dxfnaaqjP1RGRY8ZMiJ1wEZkopGyRUZXV3N7HE87n67xj XeLWxsKHlNX6ErnVJUF/xO5BY5VT61hhmCqWCbxit+6W6UUMx7WmvB86s0q+wgGSoL6W koucWxrpBOYNBJME5+HxRa/lXlSreJXWQaoDeJrNnWxYMUw7bNkMz2551ucFVRtsjQZW 0ldvdZqoq1ohkP2t1Jbzv+uf1kwplqapkGN1TtrTmsgZICGsR0gfv1ElN5pvcVjNfGjj OPatiCTf9mYCZ8F6QAcUCONXn7kELLjAWaYShbgFOaFFniHTDeIvjRJJRIf4kK+rSYkZ RVyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690498781; x=1691103581; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8CTrna5t3S7P99W+zrM1I2ApZYIkXTVQedDFVAI6oIw=; b=UFJNuSivwJ8mPgCse7bad2WaasmX+43DXg44ncWWlq4Ms8wuaBZBGm583URoxsRczf GxsJhllU31WIef7/s+M/z+D5Vdgw71U8zpQez6z+AI5SJa9GKgIbb+ihGEHkRKd0HOmK DJoxsiEfELo2j+GZCrJns/00+1ZoI1W/EF25wnXuxxz+7mbfAX84icMbP5GUVzuQT09n cDneMiEpA0P3kv6l+vSTwP5KPSgCfynfIJo7l0g/up5y+gUF3jWViGaF1hZT2Toaoo9D hviqLz1HrT1ltb5sXZebvXAuNaHxUBWeeJeL+siL/bq/7nedrJE0gWyaAADR1rOzy15q +tHA== X-Gm-Message-State: ABy/qLbIt7Zs6YpIwxKamBbuy/kxI6RPLBCgyzXHUwqbo8b86o8tRffJ YeSOROnsev+9cEOpagItsR1HF3qVo7pf7A+GpmQ= X-Google-Smtp-Source: APBJJlGFE8oAcAZu2XvzWjC5bjR81v7OIjjTfZ8m+EaEe6Rjpq3cuwvHN3I08mErFwOZJpneP9Ly1g== X-Received: by 2002:a05:6a00:17a8:b0:64d:42b9:6895 with SMTP id s40-20020a056a0017a800b0064d42b96895mr61072pfg.5.1690498780930; Thu, 27 Jul 2023 15:59:40 -0700 (PDT) Received: from dread.disaster.area (pa49-186-119-116.pa.vic.optusnet.com.au. [49.186.119.116]) by smtp.gmail.com with ESMTPSA id p24-20020aa78618000000b0068702b66ab1sm1115813pfn.174.2023.07.27.15.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 15:59:40 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1qP9xJ-00BKKZ-1O; Fri, 28 Jul 2023 08:59:37 +1000 Date: Fri, 28 Jul 2023 08:59:37 +1000 From: Dave Chinner To: Damien Le Moal Cc: Qi Zheng , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-erofs@lists.ozlabs.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, linux-mtd@lists.infradead.org, rcu@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, Muchun Song , akpm@linux-foundation.org, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev Subject: Re: [PATCH v3 28/49] dm zoned: dynamically allocate the dm-zoned-meta shrinker Message-ID: References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> <20230727080502.77895-29-zhengqi.arch@bytedance.com> <56ee1d92-28ee-81cb-9c41-6ca7ea6556b0@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4AC4140008 X-Stat-Signature: 37a754myorp9cjqpnfgz98q4awsbzr3u X-HE-Tag: 1690498782-82201 X-HE-Meta: U2FsdGVkX18o3jyLAW3v41D3IKxv0TvvMoQxaQszoRj1IYnC+M6JIS+7fqF9N1s67652Wr6onLOvQ+UtBDORmuaRaiTdlURt/N59Rg6vP+9erpsyLjUGI3ntSusyd56wJBKeIjTQtqp6wFkJjQgvXM431EfVmO8BM0MyX4XiHEEs5GFGdcDGT3EHfoNXDEjGl2TYAVuacCCV112IRcPAkRBWEmKwDW2Hdw7zPxxjZu1ro0JA4qFa4K5MH3ti37qAz4r5M+kpT2Wt5NFxJ6BFT4DijxyL1Uiu5G0pxsUgRbGH7ssc3Cth6RAb1wHKBi1tJZKFOQhtA5smQ16ukbPFLLScHzJNMfpdFqClsaZU2xzNIpyiZzzGn5oKdno6M1hJ72BiywPvpeVFPF50oifUop+NTxTY7pGW/4DrqlQnZqEpSBF+lH+uDk+8L2w/mm5aJd7Ui143zCEsUanP5fja0huBoG9aKlHU3/Tk+dT/otNQghEjRW1IyK3vRb34JfCmivykVu9GJo9z7GUW4h2epU90pTNYKcic8QQkblctcf8cpRX6lNRxzfUa+MiQTfIKivtdJsTa8rDK0iabR6vJ3cLotWLB6UkkC/V8Xx4jUHumAelZg0rzU0gmvsOPj9yuL5dgXhBjfSHErVSITu6aSt2MnP3rIrzmoF9CLdAc6k4Z+F8I9sSeY44CcfURBQTEMgsbiscrVh0jz2Gkcy9rC7UoDSmWthzsnRRJUPbwWs98PlKZjKKEC/t+FDgRKAKY2WSTAqa8icsH76F6TCOnkyZuXtmPU1YRJqVUMbIQkRb6pffu4nEH95S1u9QnNGhYc9c1NJQfDY6aYyl3GGwQiF8EBvAkfVOExfJ3Y4ChJ/zm6KUsR0PjZa2BgSVjTH72x0YP6T2rgVze4nsXBuW2Q1lmMaxaSSuLQ5KQsGo4nfhKd8H9zB6cbXlOCgFtm7J9AXrA41Ulu35ofeOny8y RMFFO74h SWv+XE2eOalALX+xszZXut6h3LwGH05vwC/AH9c17KtMJk4Jntb3q9IzSfQOMRY9j77o5APHVdDaeV9VIXU3PaLPwkJBMukkEQxccQuK17u2hfV3mZAxtZIgvH3Rb+fdZyrBpP3wsDz6GXNriMoU155U3JMB/78z2KFi1XTemdLRcbUKCOYvitdXxg/vnIz5XuNUsEGPXTZZ8PiRi6TNUKAQbM8fxe4zqIqXoNJWkvWro8Ewq0MjnB3r+/MfPX0plICngtjy66/NNNIffkfKvZYYCVhAbMeexw0XeVL1ZwRPk02GjPtaKKe4EmnushlXvPLDnNAIj+cmzj6kaOK6IiOp53nnf5Yzik+Jj2Ls4nKk0vffU1rEV4uS/bun5yoFnXRhhRJU8y+b85f6l/ArQQPI61BmbVn7rt8z9vh4YblrO3W9zqls/QaFoRD/9lLegJnfX X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jul 27, 2023 at 07:20:46PM +0900, Damien Le Moal wrote: > On 7/27/23 17:55, Qi Zheng wrote: > >>>           goto err; > >>>       } > >>>   +    zmd->mblk_shrinker->count_objects = dmz_mblock_shrinker_count; > >>> +    zmd->mblk_shrinker->scan_objects = dmz_mblock_shrinker_scan; > >>> +    zmd->mblk_shrinker->seeks = DEFAULT_SEEKS; > >>> +    zmd->mblk_shrinker->private_data = zmd; > >>> + > >>> +    shrinker_register(zmd->mblk_shrinker); > >> > >> I fail to see how this new shrinker API is better... Why isn't there a > >> shrinker_alloc_and_register() function ? That would avoid adding all this code > >> all over the place as the new API call would be very similar to the current > >> shrinker_register() call with static allocation. > > > > In some registration scenarios, memory needs to be allocated in advance. > > So we continue to use the previous prealloc/register_prepared() > > algorithm. The shrinker_alloc_and_register() is just a helper function > > that combines the two, and this increases the number of APIs that > > shrinker exposes to the outside, so I choose not to add this helper. > > And that results in more code in many places instead of less code + a simple > inline helper in the shrinker header file... It's not just a "simple helper" - it's a function that has to take 6 or 7 parameters with a return value that must be checked and handled. This was done in the first versions of the patch set - the amount of code in each caller does not go down and, IMO, was much harder to read and determine "this is obviously correct" that what we have now. > So not adding that super simple > helper is not exactly the best choice in my opinion. Each to their own - I much prefer the existing style/API over having to go look up a helper function every time I want to check some random shrinker has been set up correctly.... -Dave. -- Dave Chinner david@fromorbit.com