Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3933814rwo; Mon, 24 Jul 2023 20:26:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlGtWv1YlzmYA072vzK7FhL85VFjOSkA1X8oEUHzuUJLgU1+1fgKmnGkn5rr992Brwul7XrW X-Received: by 2002:a05:6a00:124e:b0:686:2539:9ff2 with SMTP id u14-20020a056a00124e00b0068625399ff2mr6948985pfi.9.1690255565208; Mon, 24 Jul 2023 20:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690255565; cv=none; d=google.com; s=arc-20160816; b=TZ0ZfuHtqnNDK+BB6wjOF8qlqksXGGmQ5Fyzo7Cvb0zOGSg6fESIXGGs7WGQoXayFf ZZyx3YGMYv1tQt5K4eSreoi+FWxzJwvOw46bm++VIlzxqpU0LZrdpEk2azR58JliR9vm b2cEJjnEMXL8BHWEGfomVmKE3/6ESAzlIANcWaKN3S1LR026T2toP18k43SvQjOnKPgt wrrD4NOnwsPAf8nlBv0vOzJBi39eM7L6Ielag2q6UsW8T+PT3pSzAaiWOZ24z9Vg7lUE m45FTo2Obws2g3SUVNJqADOrgdnEf/Ti0qB+ni/DLgShx0FeB11SAHXvpGhLUsmvFbfr D8fQ== 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=BOm9JtzAMmxvhoSbX2NtL3QoGfALrOaBCsSuiN3HvS8=; fh=5/ZNgJg0+ZCMm23VO+DGRpJLY+5EOowSVsn/sOZJOgM=; b=TCAjII1a7yJ9SXbc92PVnuGUu/IbnMCqxbnaTLnjfXqqnvCLtu/XB2b7Tvi2b4HrGA oc+mDZ1b+9uWOlEEkRm2+IbvRtvZ8bg+THsLftY6N9WjKM0MbWdmWvObb3kGTWLA4Ups cuhPtStVBCh8aMWNoBJm7LaXJ0WDAHY/kXLG2xZaT/yzSrnot9d/eCIb31vuqExtpQM0 qSU7bybLtJcQL3cgNep2/4SQEKDNmxHdyaLcaHdevptWt7XzrSeT4dKW5yl+Q87HN4Hz xGROBm5AoyGQexYVyJ4sorNJ/+F2t3wtoUz00NgfL+drv4/ux3hlgGGgrmRP0a9gmiq6 DL7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=S6qTrQW9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a63954d000000b0055b2c94e7b1si10120156pgn.190.2023.07.24.20.25.53; Mon, 24 Jul 2023 20:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=S6qTrQW9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S230027AbjGYDB0 (ORCPT + 99 others); Mon, 24 Jul 2023 23:01:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjGYDBY (ORCPT ); Mon, 24 Jul 2023 23:01:24 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F30E7B for ; Mon, 24 Jul 2023 20:01:22 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-682a5465e9eso1177315b3a.1 for ; Mon, 24 Jul 2023 20:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690254081; x=1690858881; 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=BOm9JtzAMmxvhoSbX2NtL3QoGfALrOaBCsSuiN3HvS8=; b=S6qTrQW9jNBAqKkMe5A0Cu8+HbQDlzC3TLro07t5ACviirx/XqhnqUPjiclTs78MVw L8tR0RX+uwWODTuNUCn9GO7p4bXpfIsdbkjqpY0PqVfJilI1CACHVzYlY/iV0sWP5V/3 T3P+fsJZrl/T8/61jZYJY4PyQofvYiMvXNGAlNPnqvgQIdqIJpCErJLddWxt9/CHMYvA fQfQW01/Y2q+AlIExOo9mNzILsmJhUWs4VPYn88so7T3w1Nn66xNTb/c35K8Neo4b+tp wg91etpXIESM3veFJOsmMl9xQ0iXGYxs+8+DAjrpr00+sWBSXajvrars1puw7bQqkMd4 /qUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690254081; x=1690858881; 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=BOm9JtzAMmxvhoSbX2NtL3QoGfALrOaBCsSuiN3HvS8=; b=exmF85g3pskmdcVTxJAvd5ZME7fo6YzMykmow9CdpfVylND6cGwAS/RunJCHVJN6oi sgp6/3s6/vVyCLnmNsByDwDMac7Q0KHIb1cyPkDqZTjDrV7dsHZ7JhbubTBE2W1vwZSx 45E/OnQNy43OqQrDR/Gbon6eyh0ATHJqWrtxJoiNHV7HGr27dnxky9vGvwQ3+WFEQMrs 0B3SPaozyRhaRNnoZIESTWfCflqw64zplxPKA/MmOHWiz7J4dLl7S4KiVf/coDCDeyVr +sH9EqRwCEba+ERGhlJNeDrzHU03NBoA8Zn03YdwzOQ1XpVUPVkNHd9WpIXXFMt0zebu SNGA== X-Gm-Message-State: ABy/qLbOjAxMYVv0OZI1kTKHjvxl+PJS0i4CAKkUZ+dpsMrycw5NwQmD Uc3D8RPrJO1swPY3nqUYA44d+A== X-Received: by 2002:a05:6a20:160d:b0:111:a0e5:d2b7 with SMTP id l13-20020a056a20160d00b00111a0e5d2b7mr15056320pzj.4.1690254081364; Mon, 24 Jul 2023 20:01:21 -0700 (PDT) Received: from [10.70.252.135] ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id fe15-20020a056a002f0f00b0066ccb8e8024sm8472563pfb.30.2023.07.24.20.01.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jul 2023 20:01:20 -0700 (PDT) Message-ID: <9b149dd9-1617-9af4-4252-6d0df01f93b1@bytedance.com> Date: Tue, 25 Jul 2023 11:01:06 +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 v2 03/47] mm: shrinker: add infrastructure for dynamically allocating shrinker Content-Language: en-US To: Peter Zijlstra 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, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev, 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 References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> <20230724094354.90817-4-zhengqi.arch@bytedance.com> <20230724122549.GA3731903@hirez.programming.kicks-ass.net> From: Qi Zheng In-Reply-To: <20230724122549.GA3731903@hirez.programming.kicks-ass.net> 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-kernel@vger.kernel.org Hi Peter, On 2023/7/24 20:25, Peter Zijlstra wrote: > On Mon, Jul 24, 2023 at 05:43:10PM +0800, Qi Zheng wrote: > >> +void shrinker_unregister(struct shrinker *shrinker) >> +{ >> + struct dentry *debugfs_entry; >> + int debugfs_id; >> + >> + if (!shrinker || !(shrinker->flags & SHRINKER_REGISTERED)) >> + return; >> + >> + down_write(&shrinker_rwsem); >> + list_del(&shrinker->list); >> + shrinker->flags &= ~SHRINKER_REGISTERED; >> + if (shrinker->flags & SHRINKER_MEMCG_AWARE) >> + unregister_memcg_shrinker(shrinker); >> + debugfs_entry = shrinker_debugfs_detach(shrinker, &debugfs_id); >> + up_write(&shrinker_rwsem); >> + >> + shrinker_debugfs_remove(debugfs_entry, debugfs_id); > > Should there not be an rcu_barrier() right about here? The shrinker_debugfs_remove() will wait for debugfs_file_put() to return, so when running here, all shrinker debugfs operations have been completed. And the slab shrink will hold the read lock of shrinker_rwsem to traverse the shrinker_list, so when we hold the write lock of shrinker_rwsem to delete the shrinker from the shrinker_list, the shrinker will not be executed again. So I think there is no need to add a rcu_barrier() here. Please let me know if I missed something. Thanks, Qi > >> + >> + kfree(shrinker->nr_deferred); >> + shrinker->nr_deferred = NULL; >> + >> + kfree(shrinker); >> +} >> +EXPORT_SYMBOL(shrinker_unregister); >