From patchwork Thu Feb 23 13:27:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13150330 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 349C8C636D6 for ; Thu, 23 Feb 2023 13:28:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDEDA6B0071; Thu, 23 Feb 2023 08:28:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C8F526B0073; Thu, 23 Feb 2023 08:28:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2F8F6B0082; Thu, 23 Feb 2023 08:28:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A26BD6B0071 for ; Thu, 23 Feb 2023 08:28:29 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7FB7E1A0681 for ; Thu, 23 Feb 2023 13:28:29 +0000 (UTC) X-FDA: 80498635938.27.8722F17 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf07.hostedemail.com (Postfix) with ESMTP id AAA9B40015 for ; Thu, 23 Feb 2023 13:28:27 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=lETgDORH; spf=pass (imf07.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677158907; a=rsa-sha256; cv=none; b=bRHVYEph7cc9SCAOSpxWqfvViTg3WhCYrWnLujqxYZ1Da8/7OiYg6wAltaXDYBXxZIbtK4 wsTUc/3f0wXHtQEOdMvY5Fa1BGufJv6lERi+UGp/6B6SaH1O7GJt+Ea8BCDx5xLtMe/1T/ wqoKkXDvP2ctMyTFZYLF6xIziDXum0M= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=lETgDORH; spf=pass (imf07.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677158907; 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=CCg67xK9T4mK7fnQXbRxQLg+KO6dWMg4osRlqGhwwto=; b=wtG30G4t/6GmhDhnCoKBleLRAG7dvK/Mn+ZEUCCFSeTOqLnsIEXL/Y5P7zLTs5l4xSU1YR P4HBMcajml40lRi6ILC4CDKQ+QGQJVY9n50MhHHliRhSd3Ie4PPYUXeT2T306drtU54AlB xenWUnBWAdke9zLoptiwJ1csGtRTl6o= Received: by mail-pj1-f47.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so28218pjh.0 for ; Thu, 23 Feb 2023 05:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1677158906; 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=CCg67xK9T4mK7fnQXbRxQLg+KO6dWMg4osRlqGhwwto=; b=lETgDORHGvM9YstoHGbA1w0c/zosszK5Tl/tNTL5K5GecaMVH3OBn+bE4nEakg6egq Pvrj1imBQ3mvMDd4ZkkT+KTl+KI7731rrPWGJr93xhck6jDmBdEQXOnXXEO1QfhSK6RX ygXjpnptKdeVKz4W3Pi6mq9d0qV+R8FOe534PaajduVj/IHLnCHezzp/AdV++OCktNuP 8w/SRgZpNscp1wPYqJzwvIGsa1g6aKBO/N4rrdP+sT3ClXNrbTOpm5Hjwya0rBJVadLP 3Nf3Tv+Z4D5QSw8ejD088MsxJyTzHJO0ORVGeG8DQ79R3RuVcqlVVKIQp+9BWC5EuICj qEMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677158906; 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=CCg67xK9T4mK7fnQXbRxQLg+KO6dWMg4osRlqGhwwto=; b=aJ/96k2gX2ES1hNQ/2JFqfxk8Zd9oZ/HxXtUU7YbM80OCtL7XeQKFsp+7P5hEUUDFx We3g1OLx/D8QWdB0330+YHYpyTufpcu98zGb0gLLv6dgFUyyVuzcnDi7S7ZjWP66dgWw BzPtxH4DvN35pHwYNm1ldBr77J409leTijG8so2euXDjWn/pHjWzjASUe/ztMdj5RBHX Wx8fJ7TpUlYBlU34HB/SSmbDkLTHHpQjpekQjSgyAMr3P5DHvfAEEMs9vPgMD/PRN/NA CPe679ggx7/bpBhk9g/WmUPSE7LjZgPAz116jA2Zf3y22g/LRrcG4VwoXx3bBWkqKJhr M0gg== X-Gm-Message-State: AO0yUKWIh31aZyXTMIJDL18cZDW7mwHGnZ5EtNFOjGVBL+uHn0PsjqQ3 srXKpLMXzwY57uLx7BrPyTBtvw== X-Google-Smtp-Source: AK7set/QZbVb36Sv4JLFW6OnERnzffyx6wAbjX3Cubg0yhkLOIgaCU3CSjc6M3m8hEj3yZzy5iBl6A== X-Received: by 2002:a05:6a21:33a4:b0:cc:35f5:1a84 with SMTP id yy36-20020a056a2133a400b000cc35f51a84mr1073433pzb.5.1677158906681; Thu, 23 Feb 2023 05:28:26 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id g18-20020aa78752000000b005a9bf65b591sm3848591pfo.135.2023.02.23.05.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 05:28:26 -0800 (PST) From: Qi Zheng To: akpm@linux-foundation.org, tkhai@ya.ru, hannes@cmpxchg.org, shakeelb@google.com, mhocko@kernel.org, roman.gushchin@linux.dev, muchun.song@linux.dev, david@redhat.com, shy828301@gmail.com Cc: 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 v2 6/7] mm: vmscan: remove shrinker_rwsem from synchronize_shrinkers() Date: Thu, 23 Feb 2023 21:27:24 +0800 Message-Id: <20230223132725.11685-7-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230223132725.11685-1-zhengqi.arch@bytedance.com> References: <20230223132725.11685-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: AAA9B40015 X-Rspamd-Server: rspam01 X-Stat-Signature: 8x7mjyc4od13ixsnnjpaie7bc19rpcu9 X-HE-Tag: 1677158907-447489 X-HE-Meta: U2FsdGVkX19Uwb3IwYd8pt7KzMwvcy6HKbmsnGsnBGjIYhObU53FrBRjP7i6nN492nnm9Hab1+PJIGNaSI6QzgffnAq3lAlVV0IMKYhOXSPtg4/ylALoaQQ4uxPodroSQ00IwLLuQp7adGEtQUOIVGSqz3rystU94kd2ImoetppR3s1saOfMi1BTA6ZfMN4N4MvkNGCzCTgm+vLeibxCdhjLXC8fbVNGb55fd8k7mPGThrrRHWfVGFzE7wzbczwcsWJkpnCjEbStKUzBlvCOFEcUAtzQJ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qmRszPrr6odYHRtpIKJbrj1w5ZM1Me6yGZ2/fVnsjpj5FMQxjhWoY77Cu92DawMNNlumBivtFnE1crxhtz8BS+2VV5ghmbUGx6fCcn5azN5orQ== 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: 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 89602e97583a..d1a95d60d127 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -794,15 +794,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);