Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12455000rwd; Fri, 23 Jun 2023 06:26:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6U/I9ZmOk2Wef5aTcBhPzS4q9ge2KN0i/cWXmFjgF39BwQVPVEoTRWC3uajPXOjqxck5Ln X-Received: by 2002:a05:6a20:4284:b0:122:8096:7027 with SMTP id o4-20020a056a20428400b0012280967027mr16591772pzj.29.1687526780145; Fri, 23 Jun 2023 06:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687526780; cv=none; d=google.com; s=arc-20160816; b=XKPMeSGvbxrDfWE/60YB2/CIGikDw2V+sc8di719qE441BigT2DVQKh8/Ai6ysxkq4 CYR6SCqMyUgC9pCELtA0JB5efqXasYSy7wfl93bfqLW4djp6ZBxFAni7i+Cu/zypo8N2 XA/DyRiEQ+MB4Cn5UpU3Z3q1I0A2O1Ymli0+DesLNFYTzsMeXmYYV1+5DIcwIdoUTnQo Gwmqc584/5pYKAp+gsiSEoqdAIhLr7GCewi5OZELHpQecIPxtrNE5l8daYQ9AkYxDYRg Jdo1mukp8pB5SZK9lTrrVnXqaEQAqJmy8+aor/KOc5jc+cBLlrXoimheI3rv0OujyLDz SxSg== 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=gz92l7DBmLTrf6935v1JTyj18AL7FL04QRL4qQAWqJU=; b=LHztwsUE/kKWTRP1pe+hJ0LsPQ1724+e329yM0Hp6oZHVgqnKryzkjy/F75ILjsL/x xxVglObIPBOcnl6m/xziTxsgXbfrFwngUl265fW6vGtGo0BbCExtFoERvrfeTbNiD/oA eCfhbeP+KDrbb0UMiMlhogVN2NwhdJDE2UYx00bhV547HS/8SPasl2p8e4RNYng65gKQ mmfUfZFm84ahJHGYJmsLh4EaoVj7Ktu1dGqgqM0Z8upFh+Vpy8FwjEoLYWjxXgdIDoJ6 duxUZsuCXb0H7y+Ba0DymOfSUVKqYO5bLdvJNJMg90FveBkF0K2Kxbm3BjqC9pNyJA7g R7nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=gIWwtDXx; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y196-20020a6264cd000000b00668718e54c6si8488900pfb.202.2023.06.23.06.26.05; Fri, 23 Jun 2023 06:26:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@bytedance.com header.s=google header.b=gIWwtDXx; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231138AbjFWNYm (ORCPT + 99 others); Fri, 23 Jun 2023 09:24:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbjFWNYl (ORCPT ); Fri, 23 Jun 2023 09:24:41 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F5B268C for ; Fri, 23 Jun 2023 06:24:36 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-780c89d1998so2499439f.1 for ; Fri, 23 Jun 2023 06:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687526676; x=1690118676; 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=gz92l7DBmLTrf6935v1JTyj18AL7FL04QRL4qQAWqJU=; b=gIWwtDXxJuivuEsWsn7sqCZTBLYzZCSIZH5HGE4qZ8EWB5QUXMWkTscVi5K7m3pLUb AWoNDhJ8ESx9DRpn3UGCp2Uvm2dath67lulczhMMzXUHSfw+KuuuWZKZ5vDu4lXfHnd5 hQR/vcg8QKo72hHneWZ3miZE29ysHMJmApIFRQ1SzZroa/a+qdV6Dpe2uLtETWZSf5Di DwUbZUrml+/apF9HoV5pAAcN8e5k4Mr7obMwZugAwGAvvUEtH2WFBgfX4jOKDMjPri+A N84eYclRTYh7THW7IcSdjB8iFp8xE+GCdJYVPjGEA03gXDcctC8fDrc4P9qjfAoL/G9z jxWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687526676; x=1690118676; 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=gz92l7DBmLTrf6935v1JTyj18AL7FL04QRL4qQAWqJU=; b=aq9y3DdW+TWLpwO8AUuJ5vJELHOU5G7EN+1IVC/D+EzvSDSlYW24ObbjafSu5SzqCF fWtuxS9qSYKxj/vYrniMef7tfdD4HLnc8wYWugswfzVsqK21z517JkDFJ18il99JBvhV +NApvFi2J0YLT9D9nHDm3PNBJjxOcOaeErj1OX29REx4evLb3ir97tEkYno9Hqkz2CKN YGvNya53moQsqB7P7e41G215ZMEjJO+b0bFwwM56s2qLAWsSaJs5bU7NWQfKgu7Z1F9E yw6fNoXWDbjAo+lwUfyXfmrK2vTsZ7iUXz2SUnC9YNxjPzlLl7vPX94tMrWc2ukJQLb9 qsxQ== X-Gm-Message-State: AC+VfDw9tEIXwAAf08HG0BGk4VT8TDUdoVOc8JD/+yPHS2fvxJuENil6 EtD009xVzIv7c3iBQ06vazcHAg== X-Received: by 2002:a6b:1581:0:b0:780:c6bb:ad8d with SMTP id 123-20020a6b1581000000b00780c6bbad8dmr5508761iov.0.1687526676020; Fri, 23 Jun 2023 06:24:36 -0700 (PDT) Received: from [10.4.168.167] ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id w5-20020a17090a380500b0025bcdada95asm1562852pjb.38.2023.06.23.06.24.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Jun 2023 06:24:35 -0700 (PDT) Message-ID: Date: Fri, 23 Jun 2023 21:24:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH 29/29] mm: shrinker: move shrinker-related code into a separate file Content-Language: en-US To: Sergey Senozhatsky Cc: akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, linux-kernel@vger.kernel.org, linux-mm@kvack.org, intel-gfx@lists.freedesktop.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-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org References: <20230622085335.77010-1-zhengqi.arch@bytedance.com> <20230622085335.77010-30-zhengqi.arch@bytedance.com> <20230623052554.GA11471@google.com> From: Qi Zheng In-Reply-To: <20230623052554.GA11471@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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-ext4@vger.kernel.org Hi Sergey, On 2023/6/23 13:25, Sergey Senozhatsky wrote: > On (23/06/22 16:53), Qi Zheng wrote: >> +/* >> + * Remove one >> + */ >> +void unregister_shrinker(struct shrinker *shrinker) >> +{ >> + struct dentry *debugfs_entry; >> + int debugfs_id; >> + >> + if (!(shrinker->flags & SHRINKER_REGISTERED)) >> + return; >> + >> + shrinker_put(shrinker); >> + wait_for_completion(&shrinker->completion_wait); >> + >> + mutex_lock(&shrinker_mutex); >> + list_del_rcu(&shrinker->list); > > Should this function wait for RCU grace period(s) before it goes > touching shrinker fields? Why? We will free this shrinker instance by rcu after executing unregister_shrinker(). So it is safe to touch shrinker fields here. > >> + shrinker->flags &= ~SHRINKER_REGISTERED; >> + if (shrinker->flags & SHRINKER_MEMCG_AWARE) >> + unregister_memcg_shrinker(shrinker); >> + debugfs_entry = shrinker_debugfs_detach(shrinker, &debugfs_id); >> + mutex_unlock(&shrinker_mutex); >> + >> + shrinker_debugfs_remove(debugfs_entry, debugfs_id); >> + >> + kfree(shrinker->nr_deferred); >> + shrinker->nr_deferred = NULL; >> +} >> +EXPORT_SYMBOL(unregister_shrinker); > > [..] > >> +void shrinker_free(struct shrinker *shrinker) >> +{ >> + kfree(shrinker); >> +} >> +EXPORT_SYMBOL(shrinker_free); >> + >> +void unregister_and_free_shrinker(struct shrinker *shrinker) >> +{ >> + unregister_shrinker(shrinker); >> + kfree_rcu(shrinker, rcu); >> +} > > Seems like this > > unregister_shrinker(); > shrinker_free(); > > is not exact equivalent of this > > unregister_and_free_shrinker(); Yes, my original intention is that shrinker_free() is only used to handle the case where register_shrinker() returns failure. I will implement the method suggested by Dave in 02/29. Those APIs are more concise and will bring more benefits. :) Thanks, Qi