From patchwork Thu Jul 27 08:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13329146 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 6C1E0C04E69 for ; Thu, 27 Jul 2023 08:06:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC3806B0080; Thu, 27 Jul 2023 04:06:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C74506B0081; Thu, 27 Jul 2023 04:06:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B15156B0083; Thu, 27 Jul 2023 04:06:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A3A2E6B0080 for ; Thu, 27 Jul 2023 04:06:39 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8606D1C8B32 for ; Thu, 27 Jul 2023 08:06:39 +0000 (UTC) X-FDA: 81056660118.19.890B5BD Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf14.hostedemail.com (Postfix) with ESMTP id 9A6C7100011 for ; Thu, 27 Jul 2023 08:06:37 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=EEgKRQyP; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690445197; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5ddhCZTkz2TFo7oGCFzg4uU7nrLecafIDKLLill2eh8=; b=Es0pFLZtGXmK2k9QXBNPEa2jB4N4MK/6jLnmbSqkE6d7RCL78qzF2hs138iUT9LaWEPimX pE8r77HypXG+GZLrvQF/3UOm7MuXHVY5q0uOdwH56BA86kC6ktYQxati+zkr+QT8h0uhzc iDm7Lw+baii9v1aYz4QSVXNo2pp9uho= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=EEgKRQyP; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690445197; a=rsa-sha256; cv=none; b=N7NVGCJMTMZQMMQILkK+8IZdS29FM7PORkGg/04celEE67L++EaymfGWt7S9NaiKA0rAK6 KYpq1Pgpg1Y9A75ml5Dx/pwR7YFlppfsICjn3a+q8qkTGsBxAylr4lxhBzq3TUYqrx8ORn 8szJb1wB1JW8+kT+iUyEiJYukPXC2Y4= Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6748a616e17so182346b3a.1 for ; Thu, 27 Jul 2023 01:06:37 -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=g8uHz6J0n8s+v2CXX8AJCk3qzdz5w+VGoG8wd6yRlmK4Jv7lzDKptMMxYRzgFU66dS jAqEZPmt5aRyMX/vGaZAqKrZlBdkwRS0eMxMK59FgCZaJRcDMko92KSwcNdff6ZjtML/ HFHfFyz7Kzdr9ZA9lYCBYnyE2yTFsvc3w3ghiZ6VagxaDB5TsyyjGD/XUBA7yN2hajgW DnNhzYoGSs61evitKbcd854jrX1nD40WM7wEfdofFgDi0OWLqG1EpTihfP8lgv+aWZSu JyMkXQql6mXKT5BrfwjKwLafKr9HU3hiqZMNEjoRpNaJADWm6anRxiz0mGMhIhXMCFuB IuXQ== X-Gm-Message-State: ABy/qLYpE9pCfHx0to6oZCKe/U9qmCTwbRiIcj+A7RkJN9cnpsTr2IwT aBCwcAVwyGJ3wUHrKQvou/gBFQ== X-Google-Smtp-Source: APBJJlGC9GcjpF//RTfgHk/e3ibfMuX5WCzda5QO/QIZ+yDcAz1vV0DX9dFwhd70yzWPOAQ384luFQ== 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 X-Rspam-User: X-Stat-Signature: paryphwmymrtff3q96yra6dckiwkxqcu X-Rspamd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L5SHBCpKLXD5V5wVoO985vExCDVD9rNl2O/uhkcZ5dOtH2vDZQQKZ60PyyNinz3QzyYYBtxYVtm0l4R+mb7ESIKioezQgGVr/B571YTCoBNXoyNW0JFaEMQSadeoAjgn2+KKX2J6x6gVp7K1IqS4EWmuJXB8f6HTfAQ2dHRYWr50B7aR00GXKVnXXR2ytJtU8ajL/tlIe2Ddz3nB7JUXt2/m/rXOeS3v+nmA6f+5XoGO+lW9Rnv0EbIhwGQvHzKiTKVV1UmRhrEc6PJdDmrrzpJNg790Y8XbKR0wSBbMVleGgcthSOdmQe568c26lEADzybFTItrlfLSqDHqxvrfyTlpix0GAhPtopX2VSbW2S36CN04UftFSZd7bi6682b+RpOUS5fo/s3b7lCP/nn8SrT3IezmiivEn2RG5JumpKjM7qBSIH8P+h2vKpUSD56USXqp29Q== 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: 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;