Message ID | 20230622085335.77010-27-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 5D9FDEB64DA for <linux-mm@archiver.kernel.org>; Thu, 22 Jun 2023 08:57:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE8FC8D000E; Thu, 22 Jun 2023 04:57:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E98188D0001; Thu, 22 Jun 2023 04:57:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D600B8D000E; Thu, 22 Jun 2023 04:57:34 -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 C973C8D0001 for <linux-mm@kvack.org>; Thu, 22 Jun 2023 04:57:34 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 97032B017D for <linux-mm@kvack.org>; Thu, 22 Jun 2023 08:57:34 +0000 (UTC) X-FDA: 80929780428.06.F3C6706 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf14.hostedemail.com (Postfix) with ESMTP id C63A7100006 for <linux-mm@kvack.org>; Thu, 22 Jun 2023 08:57:32 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=I9WP6mv1; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.172 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=1687424252; 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=YpqAnPCFjvBxCUJyQNRij7IdVYJH6Jib7EICYqtSs4Q=; b=eeYLYEdpJ7mAnK6H/1VHg+46MtzfGne+0X52lL7Q9bh9esBCVn+C4zV2iYrxkqgszYTQPk zCr+LXUT7RhgRsOmB1/nGuhXi8R3jFaTM5Osl9205zfn/E6t1lh1+MJT9QgFtWTyUKApxO 8/bY33DSTo32dq5SV5pLzqBv+7qpncs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687424252; a=rsa-sha256; cv=none; b=OQdiJK3I1nyID4ZBfjH0P5Mv8eCyRsStP9JnXCsVdcqN0SKhfOJMWqZezikdmSCNrfObif 6eOIIW4ERWhAwOgiJe0/8gI32bdiLrQG1CXgYE/rmeKXXHh/nM4KEwvXHgF0SUIGPJTfc5 rg83BoNLp6ZEP+Av5O9+ULpOVRiKxj0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=I9WP6mv1; spf=pass (imf14.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1b5585e84b4so6829415ad.0 for <linux-mm@kvack.org>; Thu, 22 Jun 2023 01:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687424252; x=1690016252; 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=YpqAnPCFjvBxCUJyQNRij7IdVYJH6Jib7EICYqtSs4Q=; b=I9WP6mv1rDRCGtgaLzA9lhBXeFPAHaj8y0iyY2DOjVEWCsT2F7nfNJVwyIikm+kMao zO6QJGdxbeP+Xd2yLUuD3B5OfZQRm3B4q5mm2BLvCFNnuFgYbDreBXTpY911jw5PjLjw 5qBcX7//daeu9fw2bM5v9uWJQ3Yj963JAAdMROcF9Ug6KJW+BwPKjtr4qnEx+svXyNj4 WQtBJXjBe1rX51UFB2Mb+BbnprNNOvKWLYHk9IXF69UQEETABYtrhl0ZHyku4x/+376s ovmIBUSgYXrVJUG8L2WcJE6QBBiCJCq44tzgQbbUxJYU3EpXiLR3t2TzR3wvfdUTA7wG r7SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687424252; x=1690016252; 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=YpqAnPCFjvBxCUJyQNRij7IdVYJH6Jib7EICYqtSs4Q=; b=NzqwFXaVfUWiyNfxTCsWcxHHY7Km4lyDD+r8iJuFOB3+QyiURPYJLjX0I3/vdCCIXj ai/IISSMMAZ9GoH6EfqdF+9QMMdTH14kXY/3S2TUm6bXUho4xZ+wK9CVCe/3AF/O6LQe bk0pf1t5V3JUweKxn1qUYHdxmhcu/aQ0Ygy8wYmQra2eY521YZNyiMZFov8QS1aGTca4 MFGq2y9x9Zw+ZQeYXNpjtcqBo8xULS484l5VGlihBjMorAUlDDQBZj5nW04n0uYlvgGt Kh9T4WWBc9XyomqJSgzyfP2dya7FNLpWyisjZU9DZ8fo9iYtzqUUCT6H+4mQBYM8MIFr bRUg== X-Gm-Message-State: AC+VfDxKnxU2YmJYpDimUkdtXcmEwlDK/1yJv2cq/i+Gb+IFVj0MLIjr 8K66wJp0ZpQnE4Qz9XY0DKUmKQ== X-Google-Smtp-Source: ACHHUZ6FoF5W+f0N2ZUpFBUVBh1vs3Mj6G9dcM80ve0PhcTP+4niqZQRBrFmYJGvwbhs9MGB3E6MuA== X-Received: by 2002:a17:903:32c4:b0:1b3:e352:6d88 with SMTP id i4-20020a17090332c400b001b3e3526d88mr21673124plr.6.1687424251794; Thu, 22 Jun 2023 01:57:31 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id h2-20020a170902f7c200b001b549fce345sm4806971plw.230.2023.06.22.01.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 01:57:31 -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 Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, intel-gfx@lists.freedesktop.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-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com> Subject: [PATCH 26/29] mm: shrinker: make count and scan in shrinker debugfs lockless Date: Thu, 22 Jun 2023 16:53:32 +0800 Message-Id: <20230622085335.77010-27-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230622085335.77010-1-zhengqi.arch@bytedance.com> References: <20230622085335.77010-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: h7jyx53ejrww6yest4uwf5no4m6mywiq X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C63A7100006 X-Rspam-User: X-HE-Tag: 1687424252-913621 X-HE-Meta: U2FsdGVkX1+qP9Doz+2u6PN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/tu8sHEIycfXl79UCROKrdyUz36PjqcmnwIgfarSc1jh3K364rCRhbR0WMXGJZmyCC28CM9EWNAU6ASu6cTvX4v0iujHBiV+bPMCUQfU6z1DuS3uLQN52DayL83gX3z0aGhEffya2ZaO5mRKHb20vYTpbN7RrRuWzJpkD89+tddORT7AUk/1wqS5qR6Zq8is295/X4FTcfHR7ZOsPk3Ui4FXKHTY7gFCob9+7XUmCQye7Dm9VyzmYWXySbEizs2l5cHVroxHt/cprIbk0dci8lakSNme0j5W8sFdpz7HEESpyO 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_debug.c b/mm/shrinker_debug.c index 3ab53fad8876..c18fa9b6b7f0 100644 --- a/mm/shrinker_debug.c +++ b/mm/shrinker_debug.c @@ -55,8 +55,8 @@ static int shrinker_debugfs_count_show(struct seq_file *m, void *v) if (!count_per_node) return -ENOMEM; - ret = down_read_killable(&shrinker_rwsem); - if (ret) { + ret = shrinker_try_get(shrinker); + if (!ret) { kfree(count_per_node); return ret; } @@ -92,7 +92,7 @@ static int shrinker_debugfs_count_show(struct seq_file *m, void *v) } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); rcu_read_unlock(); - up_read(&shrinker_rwsem); + shrinker_put(shrinker); kfree(count_per_node); return ret; @@ -146,8 +146,8 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file, return -EINVAL; } - ret = down_read_killable(&shrinker_rwsem); - if (ret) { + ret = shrinker_try_get(shrinker); + if (!ret) { mem_cgroup_put(memcg); return ret; } @@ -159,7 +159,7 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file, shrinker->scan_objects(shrinker, &sc); - up_read(&shrinker_rwsem); + shrinker_put(shrinker); mem_cgroup_put(memcg); return size;
Like global and memcg slab shrink, also make count and scan operations in memory shrinker debugfs lockless. The debugfs_remove_recursive() will wait for debugfs_file_put() to return, so there is no need to call rcu_read_lock() before calling shrinker_try_get(). Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- mm/shrinker_debug.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)