Message ID | 20230807110936.21819-48-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 BEA43C41513 for <linux-mm@archiver.kernel.org>; Mon, 7 Aug 2023 11:20:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BB116B0075; Mon, 7 Aug 2023 07:20:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54D308D0005; Mon, 7 Aug 2023 07:20:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BD898D0003; Mon, 7 Aug 2023 07:20:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2E6CB6B0075 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 07:20:04 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F3A6F1409CB for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:20:03 +0000 (UTC) X-FDA: 81097064286.04.A3C6067 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf05.hostedemail.com (Postfix) with ESMTP id 5F7F9100011 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:20:01 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=i3OLYIqg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.41 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=1691407202; 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=X5ij/O+E/bk/tTzX9mgxwiCynzBHcXx4EKtI9EsHayo=; b=c75EPncV0oMaUWpBJwhfheksCQ7ejH1dmuUCQtUIFrsE2O0yBfNT1DkGtPdYhoEbGHtUMG zcfDQXWqngVWYWLkkHFQ0JAs+PxP3TskdLnGuO8eJCfLWAkPK2qjnB7LJnEg2yefxyw/k/ dvIalrLKND+jprAHiQ7JIl4MiSx79ZU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=i3OLYIqg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691407202; a=rsa-sha256; cv=none; b=kmlD9qF8Yp5OQitpzDFOSVu0lOiv9c9K4vJseu1xXOM03xAreZLnOzc8ZWmpBhIFAOyrdp VkNyMnN01fn7PS8oDAdFITgO5Bq/HbGJq2PXaRV/kZ9Y7/X/JOWwBfAJ23unL12Ma2yaQP uSTTLYQrwJUsbB6/NOWv9G6qxIy/R0M= Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-26890669c8eso933006a91.1 for <linux-mm@kvack.org>; Mon, 07 Aug 2023 04:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691407200; x=1692012000; 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=X5ij/O+E/bk/tTzX9mgxwiCynzBHcXx4EKtI9EsHayo=; b=i3OLYIqgHrVEAaoeqhN7xu/7U1C+reDkv4O93uYT3wVXPD8PclsjVNwGlC6uACGJON 5G7yHqhhbIuKFoghA6ZSicHcXMJKMfCogQ8szn+vWtZn4EOKB8vbAdIc7rpijTp0cbxa Z/AamO41rUovV3Rd5mToLS3fdUn/gIbndWW5fXdkD//uV9WpRp/5E2yE1kJcYdxc2q43 2kKg85HGCsKzT23sBdglbe/LKtHC4WUeFtaNvdRNowxvHAXGs/cRyz4+kFuB/ka63yH8 5vv+ldmlZuknYjC0UrMsohE+IjtZuT+2tIf1cSRO1giyAMKM5zLXRshImNoV+3DwaEWW qy8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691407200; x=1692012000; 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=X5ij/O+E/bk/tTzX9mgxwiCynzBHcXx4EKtI9EsHayo=; b=Xe68d4CYnva89IJm4vVenb7qNPPayWd0JJ9pr2W4IZ/g1mAxatwe5S0wLZjFbR2vCl hDoTXmQpIpWy42230Olnl/IpZRZoZeMvFveOLszYJa0YBQ7o0FKkPtXk7doYvzfhr41a wOfG93JANCfUhLTFSIy2cf8Nskdx5XVctA0wZwx/EUPv7iNUbpnLBAYPtwj5w6DBVbhL LjtWxFLIIRkhDEeoCzSP/ePh4364iFcL4F98pFXRGbcRl312KjPEUIhIXKv2y6iJq06i RvTP40aszRkVJlgtEth7g/Fz0aGUBCBbCyC7QV+mrWpIF8CXErKnFlMy3S8GFB9A571+ QJ6g== X-Gm-Message-State: AOJu0Yy8bAtB0t9e3Z3AkOcp0FYTa0puMkdbHZbxUBEJtHgoP0fQZ8fs BB3t5wq8KNBEgIWs95+TCPIsaw== X-Google-Smtp-Source: AGHT+IH1iUQIXRu8fJbzxUHSh+kWmc44BJdJFh0ZxZy41KSEiq7lusFAb/6JfkXEPdg45Q03TKbByg== X-Received: by 2002:a17:90a:9c3:b0:269:41cf:7212 with SMTP id 61-20020a17090a09c300b0026941cf7212mr4973775pjo.4.1691407200010; Mon, 07 Aug 2023 04:20:00 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id y13-20020a17090aca8d00b0025be7b69d73sm5861191pjt.12.2023.08.07.04.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:19:59 -0700 (PDT) From: Qi Zheng <zhengqi.arch@bytedance.com> 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, simon.horman@corigine.com, dlemoal@kernel.org 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 <zhengqi.arch@bytedance.com> Subject: [PATCH v4 47/48] mm: shrinker: hold write lock to reparent shrinker nr_deferred Date: Mon, 7 Aug 2023 19:09:35 +0800 Message-Id: <20230807110936.21819-48-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230807110936.21819-1-zhengqi.arch@bytedance.com> References: <20230807110936.21819-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: 3komjzdnq5feuoca1x5trip9oxj643yx X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5F7F9100011 X-HE-Tag: 1691407201-908243 X-HE-Meta: U2FsdGVkX1/paXCJvOt29EztZy0A1EIZ51mZsL95PvEW/2Ndi9mxTTQIRr+ihx6gDWNf/gFDkY6bL9rRwuiDuulVsRBDFx2TuYos76Wl4YiJI+rO9gJOj+vF3On+or1Wd7HbcqcJ7hitCvWcjF7HnUFng4u6OtNis/BCv7PvW43EHKd+Rbss/yb7lZFAWepODhVJprb7YtEPLwOquhLEcf27Hhbnd5gyPpIBgVwSAaI9q5DjHCZ/ndWxPrH5yPyWS83OZ9YuUqbEVTtZlKD/qY8r7Rz+20kZOMGkYJqm3fCWbBk/tdgzAc5Y3dJCYkay1NXSAbHTo80hl8zAlNVWulsnbxjFe2gYdrxbQOfzqvpOqLOqwXi1NCXoPO9QJhLVv6NtVwQ4BAH8Gx1Fc4cu031azFw4nvYdlAtn4O1EP7T8JzBz+8ytVIsYVyFJFDP36QimDpBpwELKKbqGp4wQNnbkmv47jdPw2W5DLGRU0xlhi++/XZ+slyPo8fMBAWItEmxaVR9pJ19ctqQdG5pTVV7KdIQDwSMyCXZRhsswQIPKoUd+9BFWZS5sR3dGJK2VYq2m9e1/SceqnkFU8t7LTksv14340+3uP0vgavpj87T39RNhQVAR0UgvIJGSAVZGrFgPMdKoLPDEgTBFpx0cU2u9R3Nfh51eyUhFKvHMUqZDqemrnDGQO8aoOvtydzkYIeDo33iAFenwESGlwVyGH0qzxSsZUIEsX3jh0Ok7QkAAV69Gl0Li2qovuhCAmcyhNB87csu1yV0rNLMdYAoP/AFMTMW+83b/Hm9IeQFkwQvZZvckPADuiLIJyX1djBcrHCTLssZa23skrBjilKhCJOknqZ4gETfpSZhoepeq0wOFhbRAP0scqsM22uKtLe0m9e3rY50nCGxJO1QETFyHl8EP+lDM4QEIBuweQoBSLWHgxPdDJ0Cw9DtTxdc7e+cGY0nOP3IG7KcBaSe/rTD 7gw9MBlY IlQHAhMGxjoX9XVORRlHwPhP+c3o+SLiez2uuc60PMsFU+aGyUjB4MJToPzWBDS1wP0KjrPXse1wSBd0V3zD+Y8lhlgEihASH+jr9fKKGYzdQCzKmwbvttAVaxrUxVsrKdgSzVU0zDongZV+HSe0Fc2o+/5MTaB2K2L65I6ThY1vB/VyCX7LBOCTIrEBDLk8XFaAk3E505ROs35xIVLPzZ11Zu+mlcU2N5Ibe5L0Kg3GT9+Mq0hzIlXHEJJriNmG60+eF6goaWYkw+g8rAro5taI4kXAn/KiUCyXAHkjTvVNJsKlklW5KW29vKr8LSeK9aqQoHfPcVSWlJniS3zEwBYkHueTKlUWAYUd8Fe5VucdQaixy2INu9Ra8wpO7uXpkhH4govY6DLuBK8Cb7Rrdz6fbKr14Ty7gdXp618AJCJAyUMJI+T2rqcvnGmR6JbSxFh3zZnICaCHY0TBnjMfcmvzIeQ== 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: <linux-mm.kvack.org> |
Series |
use refcount+RCU method to implement lockless slab shrink
|
expand
|
diff --git a/mm/shrinker.c b/mm/shrinker.c index fee6f62904fb..a12dede5d21f 100644 --- a/mm/shrinker.c +++ b/mm/shrinker.c @@ -299,7 +299,7 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg) parent = root_mem_cgroup; /* Prevent from concurrent shrinker_info expand */ - down_read(&shrinker_rwsem); + down_write(&shrinker_rwsem); for_each_node(nid) { child_info = shrinker_info_protected(memcg, nid); parent_info = shrinker_info_protected(parent, nid); @@ -312,7 +312,7 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg) } } } - up_read(&shrinker_rwsem); + up_write(&shrinker_rwsem); } #else static int shrinker_memcg_alloc(struct shrinker *shrinker)
For now, reparent_shrinker_deferred() is the only holder of read lock of shrinker_rwsem. And it already holds the global cgroup_mutex, so it will not be called in parallel. Therefore, in order to convert shrinker_rwsem to shrinker_mutex later, here we change to hold the write lock of shrinker_rwsem to reparent. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- mm/shrinker.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)