From patchwork Mon Feb 20 09:16:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13146181 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 0BFBEC05027 for ; Mon, 20 Feb 2023 09:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6208A6B0075; Mon, 20 Feb 2023 04:17:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D0B06B0078; Mon, 20 Feb 2023 04:17:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 499126B007B; Mon, 20 Feb 2023 04:17:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3BFFD6B0075 for ; Mon, 20 Feb 2023 04:17:27 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F35D4160F42 for ; Mon, 20 Feb 2023 09:17:26 +0000 (UTC) X-FDA: 80487116892.15.3760E6C Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf02.hostedemail.com (Postfix) with ESMTP id 27EEB8000C for ; Mon, 20 Feb 2023 09:17:24 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=JxT0r83N; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.50 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=1676884645; 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=+SuOsoPKf5aCTrdN4oo5ZtKUiUHbFHnkKOWfb3ggCgM=; b=WCRSpCtACx7v52npU1m16J4Emc/d6AllV5gtpuArF1Glp3fhhGkH5KNYUoWueqT1atu9aO XpjV80gFELzStMcMbVd0R9/SBamOhTsyInfAUJtaLzZXWEz6b8GN+XytrbzDJZv7m/o8Xg OBVCcFcJP5/bJFD2NHHf4TKFTk5u5II= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=JxT0r83N; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676884645; a=rsa-sha256; cv=none; b=TMvRGkXExYf6bXjqlmxhrh66/sthLpGjUzf0NyMTH6ODP8gq3m8YVJAlSgrDyuGmqGcAp4 Ojqi+sR9gUSi3w/AucqPu8vEKyXL4Jjbup5D3YBY6K/svmDey0GRzhvBki7aVBt8+wiJrN sCO+b3IEfAe4usn7EW3ZIRnLxbfWlSo= Received: by mail-pj1-f50.google.com with SMTP id d1-20020a17090a3b0100b00229ca6a4636so787683pjc.0 for ; Mon, 20 Feb 2023 01:17:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; t=1676884644; 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=+SuOsoPKf5aCTrdN4oo5ZtKUiUHbFHnkKOWfb3ggCgM=; b=JxT0r83NllZWDrv7JUbi57ga92yM+aV9REzj4acVWyDEC0qP6CkyEbEtUoBJBuS9q0 EmuU2mv0gSa+rVWs9ezOVY7JDMeIZ43k4AXpUSAQB6AdIxCSGzjOaPZ6AwD8FZdu+xj8 KqBK8u5KJuURh/jBiBPwgQcLVYo8QdvgjooE8iFX5K/C+5c1neFrb20RGiwO7pLYhkpx Pm7zBDLdADM1l0+KQy41Ws2iuIjA3OuXyqw27+xYBk0HctZU8tWkikX0xOU4A6qvcPuI IeHxUsqC/EryGaQnmdCJLqENq3+l53MZEuHQ8WxAIARks9MMf6XnteE6OVTM6echH0ty jkKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1676884644; 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=+SuOsoPKf5aCTrdN4oo5ZtKUiUHbFHnkKOWfb3ggCgM=; b=DMJkYxOXCOFKMGtaH2+MmnA51Rw76Snbx55dMXB2IiwF63TEgeduNW62BAyFCeq7bj KNXx++P6KhptYHjPQDrBFp1d4Fy9/Fu8eTJOu2ddAXtq4GaC+g9nPKaZ1CW2o2uJKTLy DYHbOWhLviIgjPlSSs0cPB1SbfnwBCrFqiOkv8y2ANNSi+DezKF4WJNAkfXIrWu8CLLT 54aCI5BWE5hYyEBacJ8s6VZUAlfoTd0x0oEBhGABCKh3JyDiQB0JOPW7nXddYCjidopF HLGL9S5CuKAJWWe9Ebqaym0lcFBEu0mm18ERQ8kKj1NkfTyqOE+owROmA/vfpfHFn2VT 8sbQ== X-Gm-Message-State: AO0yUKWwLmiTn9Qs6VOfvSG9PzXTrYCruVobzuVqF3sg6Rl4ybnAIDw5 4pyXJcosN4CK69hMVQiuvmHoNg== X-Google-Smtp-Source: AK7set9Jss6nYpleTWMKLk37JYg5U2t/GE2b3ogkN+P0mI3dj50eWKwdpAoiMz4LEqWxjmoXlXyuDQ== X-Received: by 2002:a17:90a:a516:b0:234:9d30:84ff with SMTP id a22-20020a17090aa51600b002349d3084ffmr950101pjq.3.1676884643904; Mon, 20 Feb 2023 01:17:23 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.229]) by smtp.gmail.com with ESMTPSA id fs13-20020a17090af28d00b002339195a47bsm432382pjb.53.2023.02.20.01.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 01:17:23 -0800 (PST) From: Qi Zheng To: akpm@linux-foundation.org, hannes@cmpxchg.org, shakeelb@google.com, mhocko@kernel.org, roman.gushchin@linux.dev, muchun.song@linux.dev, david@redhat.com, shy828301@gmail.com Cc: tkhai@ya.ru, sultan@kerneltoast.com, dave@stgolabs.net, penguin-kernel@I-love.SAKURA.ne.jp, paulmck@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH 4/5] mm: vmscan: remove shrinker_rwsem from synchronize_shrinkers() Date: Mon, 20 Feb 2023 17:16:36 +0800 Message-Id: <20230220091637.64865-5-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230220091637.64865-1-zhengqi.arch@bytedance.com> References: <20230220091637.64865-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 27EEB8000C X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: xbt7b7mgrhdccwcobb9fxipby7fgmnzo X-HE-Tag: 1676884644-416537 X-HE-Meta: U2FsdGVkX18WolTxhBsK+QrCO9KPuk02UdqmQU+Rae5WYF8ca/EqPsZ8XlHwQ9Clv+77tviV6a/o4EunOTK/1jMOxZizb/hP5lrHHl4OhQ15Tz6hh9iO3hfPxqEAPyX8N/1M9wIWuPRmwqARRr/zAI2fkjDA9MWrov/bGkwqgvzjdnX1VjfwDltKVe6CgeFhmqGOLGp7N2YIXNj11sbcm2V2ObKYx1GUvAd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6O20vTtFrfMATiBNCkDw9As7eAKCZUBUWoC2WjC/dMSROCR1omEze40H7kNg0Yo7sRZIn7k+nhoIUyboG0VH371re6pRKLDTsU3b1vMSC3Xq1GOFlS+r6NJgZgHic+m7y6k9bSPSoHLquee6PQlFduFaGTESA1b9JC8SU8JPy/ncJSDDG2LomVWgliYqlQ2+Hsw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000372, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now there are no readers of shrinker_rwsem, so synchronize_shrinkers() does not need to hold the writer of shrinker_rwsem to wait for all running shinkers to complete, synchronize_srcu() is enough. Signed-off-by: Qi Zheng --- mm/vmscan.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index dc47396ecd0e..b8da56beba96 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -787,15 +787,11 @@ EXPORT_SYMBOL(unregister_shrinker); /** * synchronize_shrinkers - Wait for all running shrinkers to complete. * - * This is equivalent to calling unregister_shrink() and register_shrinker(), - * but atomically and with less overhead. This is useful to guarantee that all - * shrinker invocations have seen an update, before freeing memory, similar to - * rcu. + * This is useful to guarantee that all shrinker invocations have seen an + * update, before freeing memory. */ void synchronize_shrinkers(void) { - down_write(&shrinker_rwsem); - up_write(&shrinker_rwsem); synchronize_srcu(&shrinker_srcu); } EXPORT_SYMBOL(synchronize_shrinkers);