Message ID | 20230911094444.68966-45-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 86F3AEE7FF4 for <linux-mm@archiver.kernel.org>; Mon, 11 Sep 2023 09:51:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 284DE6B0271; Mon, 11 Sep 2023 05:51:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 234E16B0272; Mon, 11 Sep 2023 05:51:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FD096B0273; Mon, 11 Sep 2023 05:51:49 -0400 (EDT) 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 F37FF6B0271 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 05:51:48 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AE207C0972 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 09:51:48 +0000 (UTC) X-FDA: 81223849896.10.C42ABDA Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf20.hostedemail.com (Postfix) with ESMTP id D1CD11C000F for <linux-mm@kvack.org>; Mon, 11 Sep 2023 09:51:46 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=GxWTlK1z; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf20.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.170 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=1694425906; 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=nsvoU0P27T3SHlAjt1w8muCb9cUYLpaKhV7Wpc+WlY8=; b=cHuHgV4QX+eP4hMtLCnpcj3UhCndnQAd1LZ4scDFGfeIuuw/Dlo7vYIV0C18wMAn2YqNxH w4A1YR7tjO+CAhuUrYKkHYlt67QWEa9LbAKVm1xH+ZS1r1Obljs9SDzxHVyj5nnTK5O+EQ MhHQLFnoKknvfLUSxklW7CFFGVuOEIA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=GxWTlK1z; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf20.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694425906; a=rsa-sha256; cv=none; b=K/vav0JChdvbY0fK/rH/dLfU/cE1Ft07uU55AzIIwOWBZ1Nxz13HyxRqkBJXthJTORWh9W es+ujhMr2C9fPpEvmLPs8C3cN9b4q4UUjy9CRfZMaLNub4tr3TlFaJTBFucp2PDSH2XTST 1Rc82osG4zLFQAnOiEL+sPPpQHlweFo= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1c3aa44c0faso1789935ad.1 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 02:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425906; x=1695030706; darn=kvack.org; 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=nsvoU0P27T3SHlAjt1w8muCb9cUYLpaKhV7Wpc+WlY8=; b=GxWTlK1zupiJaGt1/gyNkuW2tpwVF/SmtA7FQSPWy1Ln9IIjjgUxfrl0mP78OqdVcN hKvKfrC/qOOs8ik3fPAfi46goVEbgVdHK8n35MiXppbjnRZ1q1qYmhBV4qt3bKV2zTWK GvNhijFlKUCabgnHjwBlGXVhCWywNuSlhqA4nYUo3gwK6SKwAqcb2LlKvJwDz16ZBtii //z1g+e3pxjXDozNNx7LX+ByQchYr+Mkd1fLJKBTDFF6HZftUVfJk/NHX6kF5HgFM0kz LjEnZIZHU83nVsLVsQHW5s3zDPc/uUH8rp2MqN+Ow8J10I3f1YVE5CojSE7AKSsBSAOG V/Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425906; x=1695030706; 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=nsvoU0P27T3SHlAjt1w8muCb9cUYLpaKhV7Wpc+WlY8=; b=de5x5OGMCrlNBxgB61j6tMdzaurwCXCZLzMJ2DPgeuVJ8aMozxRMOkXIv4qVFWBFkf lD3ej/CITUxVxEbXzO9XaRHhaRZwZU6/fgANi3Byp2lag7AX7pWHZF9bmOi+hMNIByRm 83P2w/FkD5Uw2WwanXyo70uEz7aFw3d9I9ChUf/LLaPZY+SE2uLEK24r8YJO5bl2mS6x VOvk3Byn+NyA4s/BjNOc2/5p3un/y8VZ2wbAL0GlroxXX7ZDyCucCN9O+u9526aCN6LP EZGbL1s7BDC5TNsC6wNltNuXNuvSVBr2Arq0tkcg5Ac8wZ94nsiEbhG4O0MemDydHsvj 7B2g== X-Gm-Message-State: AOJu0YwXuwVTtHCY+/amhM3pL9jDm//PIm4mt94UhfDVNRo9rhdTGk+7 1WDoFPM8pvWFzsXpT+b7BNPQfw== X-Google-Smtp-Source: AGHT+IFtnlx2HOm/jCSk9ayFrW0ZCh+0jIw0rvxZkQXsUrMha5y88qwb+DelOOMwpsKlazP0cUr2uw== X-Received: by 2002:a17:902:c94e:b0:1c3:4073:bf80 with SMTP id i14-20020a170902c94e00b001c34073bf80mr11732124pla.0.1694425905934; Mon, 11 Sep 2023 02:51:45 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id az7-20020a170902a58700b001bdc2fdcf7esm5988188plb.129.2023.09.11.02.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:51:45 -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, linux-fsdevel@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com> Subject: [PATCH v6 44/45] mm: shrinker: hold write lock to reparent shrinker nr_deferred Date: Mon, 11 Sep 2023 17:44:43 +0800 Message-Id: <20230911094444.68966-45-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230911094444.68966-1-zhengqi.arch@bytedance.com> References: <20230911094444.68966-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D1CD11C000F X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: u9zqare56d7wnqnud6crxxpmbw41ues5 X-HE-Tag: 1694425906-267806 X-HE-Meta: U2FsdGVkX18rbVoBmzmqrQVt6LgMrYvmW4C6psn6lC0pZGQfOYC/9KboYOiSlvLDaVW5g25JHnsR0jkAxZhofwEeiMnrKuHD8RqGQOuwOgBWf/8AdpIgeaQs/vsN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fw5yfcuTQLQ+waTB5wUSFO/Rbs9CkYrfASRh6WiuaeHe8e/vmaCAlj+gkYpB7WkipXdfSnxUlogyin+1oidgdevWa1KtN9AoGsuVLirzFheiWkKU5Kw47K4kYwG13Lww3ffku3xt41B6zxQmQhdQLgpL5ms5eL7gW3FwmV6CLG3OCkBugbMC67cqFBvSkcH0bh5KvNgh8aR53T8qqQjf611ztrdyWTXL4vjVTu5+hHqqlcBiDjDzgmXc1xH3dGeSs7wlL0/JEULmcHuHGjbg== 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
|
> On Sep 11, 2023, at 17:44, Qi Zheng <zhengqi.arch@bytedance.com> wrote: > > 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> Reviewed-by: Muchun Song <songmuchun@bytedance.com> Thanks.
diff --git a/mm/shrinker.c b/mm/shrinker.c index ad64cac5248c..471c07d75c4a 100644 --- a/mm/shrinker.c +++ b/mm/shrinker.c @@ -292,7 +292,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); @@ -305,7 +305,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(-)