Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2074058rwb; Thu, 27 Jul 2023 01:21:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFklPOL2mWMgkKrn+5xgacfmI8Eq87qsJG1Ol7kmOwUv0XnzI16O6mPef6jf/aKb6y+Q/Lj X-Received: by 2002:a05:6808:18a6:b0:3a3:f5b9:86a5 with SMTP id bi38-20020a05680818a600b003a3f5b986a5mr2909414oib.41.1690446078441; Thu, 27 Jul 2023 01:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690446078; cv=none; d=google.com; s=arc-20160816; b=k4j8UOe/fLsEVKfz+kGpOOTnN/U+VfuesbegLZiYmSj2qkIHEoOFCU8t0TBn3UOz2x 7vrDbIO3xCqyVHO6WIcYGwz3VKHfscfR6zsUOnWHbUwdk0YsXdE6f1LRziDbhqSDlrpE 4pPAw5bn1D5I9doJG4TlB2nZdroJS+D1MtMtr+OUgLVcY2oEozKen371YLmC5SoQ9reB 7YRSNOMzbT9tjX+QEgZCyiKNy3RiBIusW8VJ0rSpGZM9hH5H4Na5KNasno0baMxZlDbq JChSbBgGjf4GU921ssyq55J+QHe06ELNJJKPdgw+ROZ1ZZjXCPcawH534DwsY5cIWYMG K9kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5ddhCZTkz2TFo7oGCFzg4uU7nrLecafIDKLLill2eh8=; fh=NxkGAd430gburLVd9IjvP+jLcLBa8IzZa5IqPWgCN1g=; b=aS3phwZKuM21bvv8PkDVC8aXKnM39q21kGq83/tRy7AqlOZEEnUcl1Gb3lo0ls0KpB BsQoVW7Gs5YFhOqm4xIboc1ot7xn2E5zmDfMuid8VR80NkRW0YQspDsZRJO2niWyxbVa 3SU+SBX0scR/zrzvBksrOel2YdeZk5dJNih5+mEYXSLdHaxnVuvEAJKtR2160sF7l1oG Jme3fjjpjgVCNlipcHL6z5CJwo0SV/jR9h0MTjw5T1wybMgU9PMCCdkhW0x/+SeXHkJP /maHlXX96xrV6ZLMwdRVB38/XRv7W6+m239GE8tauJxQosHz2pOPuCHGo9ogyRPrgls4 cMLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=EEgKRQyP; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 a2-20020a17090a854200b00250ce1755e9si1032372pjw.14.2023.07.27.01.21.05; Thu, 27 Jul 2023 01:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=EEgKRQyP; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 S233299AbjG0IMI (ORCPT + 99 others); Thu, 27 Jul 2023 04:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232207AbjG0IK4 (ORCPT ); Thu, 27 Jul 2023 04:10:56 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EEA22D7B for ; Thu, 27 Jul 2023 01:07:34 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6862d4a1376so188279b3a.0 for ; Thu, 27 Jul 2023 01:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445196; x=1691049996; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5ddhCZTkz2TFo7oGCFzg4uU7nrLecafIDKLLill2eh8=; b=EEgKRQyP19rDGzyMkxrAyrND65/av9N1ZEpraFKdjf5iHd/PgC9Uhy/xnwzeo3ff8l m3TJD5UzpvFEDeBzcRtJtOD/qHmmEUSLFJuussVMd7PAkAK7iQKGftfC2f44nNeUEfJr mKle0CkHpRLYz5sWKpGW6Zb4t5WjMo/pANabwTgogYiGmsOD2+fKJGiw7ZJ36fC4jq2K 1KqECLKCfE0K//MR+hlNLb+3ZgY7viYlU4DaknQaSi+VFe2dV+fDBnzCaNkdmNFv1cVa f6nuMbduVm+LsREYRbVVclCckYchB0Qi+6OZAWegvIeaDdeHomKe1HhIBSolAxF7uDUX dSVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445196; x=1691049996; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5ddhCZTkz2TFo7oGCFzg4uU7nrLecafIDKLLill2eh8=; b=AMYJ6Ogyhx54M5WSPjYTB0dtAJs4MAm0KFK0UW/CAT88HWtEwRPfLbRpnxaMJ3zM9+ rW6QhvUQbBjqGyE2f08JFJqp5splt9zJ0eV2Nlf0KfuvxSW4jRLty2lr17cVRK3wWpWT 6nR73tbHDi2hGaJ6Zl6uk8IHoOBw1cR+ejXbmVyMh1k66Av/TnJM9Ss1Ae7kEU6v5Et6 ZVecTBcOnk8enygyV54CYupr2SMMIjjCGPb811Fq8N/eT3ngE0KudHkLBwMAm8qhSlDu jYaoqJbWN12cw/cy8Y1c+CceC1JG/u/Xwvb7WvvzrlgHRCSqaEtKpTNaUKDUezwCBauj NaMQ== X-Gm-Message-State: ABy/qLZPfe+Q4QHIQIoZOFh6Emp4wy2lJjJH4Ib8S5uZ9ubh0BRoU6P9 Z+BatV3VhJdNZs5xF79WhqaMBg== X-Received: by 2002:a05:6a21:6da1:b0:134:1671:6191 with SMTP id wl33-20020a056a216da100b0013416716191mr5882289pzb.0.1690445196605; Thu, 27 Jul 2023 01:06:36 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j8-20020aa78d08000000b006828e49c04csm885872pfe.75.2023.07.27.01.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:06:36 -0700 (PDT) From: Qi Zheng To: 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 Cc: 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, Qi Zheng , Muchun Song Subject: [PATCH v3 04/49] mm: shrinker: remove redundant shrinker_rwsem in debugfs operations Date: Thu, 27 Jul 2023 16:04:17 +0800 Message-Id: <20230727080502.77895-5-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230727080502.77895-1-zhengqi.arch@bytedance.com> References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-nfs@vger.kernel.org The debugfs_remove_recursive() will wait for debugfs_file_put() to return, so the shrinker will not be freed when doing debugfs operations (such as shrinker_debugfs_count_show() and shrinker_debugfs_scan_write()), so there is no need to hold shrinker_rwsem during debugfs operations. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- mm/shrinker_debug.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/mm/shrinker_debug.c b/mm/shrinker_debug.c index 3ab53fad8876..f1becfd45853 100644 --- a/mm/shrinker_debug.c +++ b/mm/shrinker_debug.c @@ -55,11 +55,6 @@ static int shrinker_debugfs_count_show(struct seq_file *m, void *v) if (!count_per_node) return -ENOMEM; - ret = down_read_killable(&shrinker_rwsem); - if (ret) { - kfree(count_per_node); - return ret; - } rcu_read_lock(); memcg_aware = shrinker->flags & SHRINKER_MEMCG_AWARE; @@ -92,7 +87,6 @@ static int shrinker_debugfs_count_show(struct seq_file *m, void *v) } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); rcu_read_unlock(); - up_read(&shrinker_rwsem); kfree(count_per_node); return ret; @@ -117,7 +111,6 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file, struct mem_cgroup *memcg = NULL; int nid; char kbuf[72]; - ssize_t ret; read_len = size < (sizeof(kbuf) - 1) ? size : (sizeof(kbuf) - 1); if (copy_from_user(kbuf, buf, read_len)) @@ -146,12 +139,6 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file, return -EINVAL; } - ret = down_read_killable(&shrinker_rwsem); - if (ret) { - mem_cgroup_put(memcg); - return ret; - } - sc.nid = nid; sc.memcg = memcg; sc.nr_to_scan = nr_to_scan; @@ -159,7 +146,6 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file, shrinker->scan_objects(shrinker, &sc); - up_read(&shrinker_rwsem); mem_cgroup_put(memcg); return size; -- 2.30.2