Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11959477rwd; Thu, 22 Jun 2023 22:38:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mccU6lbCTtu7qAQEURT/lg7QdWp8j1GjjfN9G+3XeVT0+FOK3kzfpjF556AIoHzpJ2n5X X-Received: by 2002:a17:902:d491:b0:1b7:c09d:3f7a with SMTP id c17-20020a170902d49100b001b7c09d3f7amr992263plg.11.1687498701587; Thu, 22 Jun 2023 22:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687498701; cv=none; d=google.com; s=arc-20160816; b=pCyPWqbujHY1jXrcED/HjrurQfVHZGkI2WdMkRdmetPYIAFX2L+efHnHJhghoONtBd wPMKfBPV8LrP0eqZUwh1STPv1Djl0w3R/7SXwxChYWN7AeKLm1cc0sR+nqCsa+7Kzw+V dKj5uD53YY7fMMFWOC2GnDyi5C7N77P0LJAZi2AALj03g0yaVs/my8kJhGo32HK8Y1PT qwbuCZ7Bi7XimbTk0I+3RvvJ+EaQljIzNj3UFFE/vDa5C3Tr9j/4y/4sN0k3ZSjBfv3p CPiO/9Fu480FM1wzrwvjHzh02ipAuEB9/NT4VqzAc+r6mKnhkxEvnJUOmFJlDZ2ZIr94 i5ug== 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:date:dkim-signature; bh=I74A3FzNlMiWSwenHJ0qW6K9Kk3RrnXa52gDQFbNI94=; b=X7gJmaRxAdNN799avayy4tCE2AwSixkj+ADoSn9vH/QrlpPkary9ETFBPqY/Azf7c1 OktrTl4OsHpu9IVBm9bYV3Z8TR7DFcJslbzyCqcajQnhyjelx0+RSkQwSbTjwTUFhP1S 9t39o4ypfqqGuyvOPVVJvVF7rxRAd1h81a3hA+fZyaSrZBl8XZH4ONk5rEOI/2rNvGhc +LcdYinaUrqnPCpopIhCmU/8gPVPOimhbXemohcVF4inOufUsD9hdAY/oggkMcKCaBfR 1eWq5/Nsj40GWtMq574qCSulh76VB+ngj594lfJcRP2NBJhcN/1FJXj+j5OjjEGUkXW9 1I1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FE8O7Vw+; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a170902a70f00b001b53b6d8ebfsi7682659plq.56.2023.06.22.22.38.03; Thu, 22 Jun 2023 22:38:21 -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=@chromium.org header.s=google header.b=FE8O7Vw+; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231433AbjFWF0J (ORCPT + 99 others); Fri, 23 Jun 2023 01:26:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjFWF0H (ORCPT ); Fri, 23 Jun 2023 01:26:07 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4A6212C for ; Thu, 22 Jun 2023 22:26:02 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1b6824141b4so10167955ad.1 for ; Thu, 22 Jun 2023 22:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687497961; x=1690089961; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=I74A3FzNlMiWSwenHJ0qW6K9Kk3RrnXa52gDQFbNI94=; b=FE8O7Vw+I3Rj3/ymdkfv8Bc+lpDZ080s6kF+VZ6KYuJ8IcvSDzEvJHrYtehbevzDKJ k39KSog3mD45RBSDswKQweqzUA8WL0SL0uOXty3tY4QBaCgZzpYfPiVwVN0bS3NDj5Wp Vlnc7que1gB/FOXny+Xqd3OrpA8296BqQ44lM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687497961; x=1690089961; h=in-reply-to: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=I74A3FzNlMiWSwenHJ0qW6K9Kk3RrnXa52gDQFbNI94=; b=fFBvlds7A7YrAoB4MWyzWJISQl+NQEVCmz2sActGLgIl03m+QVvQCex98MsrSh0G3B frTvWcg0WapaSV1Igcwcm5zV+FKwtWy7PT9NKBDPORFMNquNTLzJtDqQffYFsRwvRjp3 rU1w+H57i/bcv66wSFYA2gvkDBdhTW/FYh+53PT5UnetTU6HKrg3shYhufwGTTl2G1jS EPN19Pw/4guxezD5DyeLr4eLTtc/vixfwa493421t65HLUjmuFfQo5tTKHQ8pC8SmdH9 F8iQ3XtxplS0RGxj/dKfSEwjbwNhqaeTcLUNEWiHgOvYreIUwGqjIpZngvDJTcebOZs8 DlSw== X-Gm-Message-State: AC+VfDzEfzX17dg0TMKOgq+fVeqp7P5Oaop/49yhaGevkzSMwJTyDMm5 20tG8dnTfSn6ulu0i6GSa89Baw== X-Received: by 2002:a17:902:ecc6:b0:1ae:8fa:cd4c with SMTP id a6-20020a170902ecc600b001ae08facd4cmr41235916plh.7.1687497961344; Thu, 22 Jun 2023 22:26:01 -0700 (PDT) Received: from google.com ([2401:fa00:8f:203:3383:b451:fa2:1538]) by smtp.gmail.com with ESMTPSA id c1-20020a170902d48100b00192aa53a7d5sm6288753plg.8.2023.06.22.22.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 22:26:00 -0700 (PDT) Date: Fri, 23 Jun 2023 14:25:54 +0900 From: Sergey Senozhatsky To: Qi Zheng 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 Subject: Re: [PATCH 29/29] mm: shrinker: move shrinker-related code into a separate file Message-ID: <20230623052554.GA11471@google.com> References: <20230622085335.77010-1-zhengqi.arch@bytedance.com> <20230622085335.77010-30-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230622085335.77010-30-zhengqi.arch@bytedance.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FSL_HELO_FAKE, 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 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? > + 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();