Message ID | 20230724094354.90817-47-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 15E53C18E72 for <linux-mm@archiver.kernel.org>; Mon, 24 Jul 2023 09:54:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A109B280006; Mon, 24 Jul 2023 05:54:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BF4B280005; Mon, 24 Jul 2023 05:54:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86082280006; Mon, 24 Jul 2023 05:54:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 75485280005 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 05:54:20 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 419B840957 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 09:54:20 +0000 (UTC) X-FDA: 81046045080.22.873CADA Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf16.hostedemail.com (Postfix) with ESMTP id 2AE5918001B for <linux-mm@kvack.org>; Mon, 24 Jul 2023 09:54:17 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=dwKlx1oQ; spf=pass (imf16.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690192458; 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=CMESg6KcZ1f/x8j8WNeV/0Ezds9kYbd4Innm/bU0Ooo=; b=2VSnt+2yWPJIT+oNF0HWW6JYscgQaZ+3iXUMdoohXNhi0wYkEcyXITchx8/4LNLAxZduLY Z2KnbmN1PWB6/XONUkH4N9bSgtYZQ1lVT8ppV3WQpdxX1wRzAeUPD/5y5TEeslMN5z1ULJ vjdhW09ak5jL8yyiKgakRGF2gpTqjaE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=dwKlx1oQ; spf=pass (imf16.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690192458; a=rsa-sha256; cv=none; b=H4m0L055T24zDEiExSDicny84TsvMx7LxSrmcVyDWn5EN9lRIl3mciUkbZUpyTqY/hLfPK 5LLelXHBGkLKgn2IZg9WC1ZooYn0homccLx3y/De7/m8WjlGvVY97BgxlI+bahERaSoPVs g7VO/nspWgUuC4czFX+/JX0587rtCjo= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1b7dfb95761so5887725ad.1 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 02:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690192457; x=1690797257; 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=CMESg6KcZ1f/x8j8WNeV/0Ezds9kYbd4Innm/bU0Ooo=; b=dwKlx1oQ8gC3FGBisAur+bDXIIsIsnjGtPcpy7zH7OHDzky5UKxSTJ05GXNV3ifxFh uFNY+8ub7jUvRzU2N0mzwWkyUcySnlCtwLD3JQfZApULo5o50SUYvFf7wmqQeUGg+K3w AqzVxAjjzV5PNtSqJauuHxoQULcgDnOjWhlM27zpLCCDDjhxzzb13/oecO1ube7S7m7P 1safwLAq/c10jFTLUU1Xqd0TB13zkKzwSGxlgMOCVqCgGIAn0g9Om1mA4z6ti880Mese Evcqc6hGgzGiGoOdWdO80KWYfeQwXeXM+h1Vq8tuq+SebTbp5eEFtPf8XLS7hjdlVp+9 zxcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690192457; x=1690797257; 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=CMESg6KcZ1f/x8j8WNeV/0Ezds9kYbd4Innm/bU0Ooo=; b=RCWo/NTQWIP50/P/cRrkQtmpvnhdM1zr9pDlixlKQEkOY5rId25I5zWoWeCXrj8CHW 6d2XjUZHpYGN/JolRoU1OU7OYPG9bg3O8bn0YmT25byD4bixsAwZdZqXWZJP5wS1op8q XlIq56DW2QOVEzKI9C+VsIzonVQA/+1ReVjBm3cd2t51M6pm0iZguWVQ0vHwG5KbnOeA 7IWy4br2UL490fPjo8Z94/GvTWxawJervpGiivXRaKNZEqTl42IduBTJ6OmVPZltZTvS 3ufaVY2Adh7vGyivtyaiGPs7UuFVdfua+mw2swORNXUohDH9MEGGLSXWw0Dgp/r43rJg YnEA== X-Gm-Message-State: ABy/qLZ/mq4RA2mIRmRMtyyfXuOvLsSIfm8g/Tx8B+DbCieo9s7/3mEB U6lrahvoHl8/pWKd26feP96s3Q== X-Google-Smtp-Source: APBJJlGXXWR+7sUNZwfELUHGku1GBmb2Z0Up/m3d12N15W4mEcGvzf3zzmR3Y2DB2osG2hV81y8tMw== X-Received: by 2002:a17:902:dacf:b0:1b8:9215:9163 with SMTP id q15-20020a170902dacf00b001b892159163mr12209813plx.6.1690192456927; Mon, 24 Jul 2023 02:54:16 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d5-20020a170902c18500b001bb20380bf2sm8467233pld.13.2023.07.24.02.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 02:54:16 -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 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 v2 46/47] mm: shrinker: hold write lock to reparent shrinker nr_deferred Date: Mon, 24 Jul 2023 17:43:53 +0800 Message-Id: <20230724094354.90817-47-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230724094354.90817-1-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-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lrkAmaNpGGEbxWXJtTXaflbs/EA1jXRz/20xyMcH8 NNN45Ngm NjYcSFzP0mYpvrpOqYJ5htc/Qct+mVIkP5ybWzqNIuJJ+FN+KYM9iRtDamZG5njpEjRofbbEA9v440u3UvnAM2BeIU8aJaxDsWty3y+R7OrCHU9ck6zYKpgqS/HrA+UpGNe0Xqgh3cikUvbEWc5C5ryUhBqlZgdfbo87Aj+ypG8heVVb+TpQ5pi14uy5z72agXmZzk8aogir0gkj3saWhObqb9Dc0caTPFFQsl+FbzlhxC3E13+KKdDRoRULdC3jYHIudG7asgLBO8L69vWx/+/JeBire27KPCq1ydztmNl6ljQXTdrCBzSHf+SPMfdWMEXVGXbY+c538htTfTi7E+31XSfnwRsYSPHx1YxSy7pmlTqlXT36tI08fcePwBBvlLq1Gn2v2XF+7Wxq9oZRzUq/NvCh/H/2dy2PVXaZGh5XF2KlGdP/H71aQQ4Ky2EwsYCTwHQjGJS2t0rLwptNV/6QpnQ== 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 744361afd520..90c045620fe3 100644 --- a/mm/shrinker.c +++ b/mm/shrinker.c @@ -303,7 +303,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); @@ -316,7 +316,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(-)