Message ID | 20230727080502.77895-24-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 2894DC001E0 for <linux-mm@archiver.kernel.org>; Thu, 27 Jul 2023 08:10:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2ABE6B0092; Thu, 27 Jul 2023 04:10:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDBA58D0001; Thu, 27 Jul 2023 04:10:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7D576B0095; Thu, 27 Jul 2023 04:10:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9B2306B0092 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 04:10:32 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 23611C10A0 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:10:32 +0000 (UTC) X-FDA: 81056669904.20.C8396D7 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf28.hostedemail.com (Postfix) with ESMTP id 36E37C0005 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:10:30 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=iVGfsyXk; spf=pass (imf28.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.182 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=1690445430; 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=uDu/4z0sff3MNLq2Hem41DvJLtW9HR7Ht2OY0+o3IBw=; b=Qtn5Fut1mEXeKEkO4qSDRcsRWrOcN2VsJA+cyO1frFBgjM4bbx3yMILqWp+HMoKUC3TbyO 7TleqczSIfcn6Uv19E+JYU8L8pr+tDdq3SWMKOUGj4rJbF8OmrRYE/k+Q8mV0Qmnl2sVg/ itC8Ss4vp6Bk3oZ+heIKzUpNm8452Lc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=iVGfsyXk; spf=pass (imf28.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.182 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=1690445430; a=rsa-sha256; cv=none; b=PLG9o0Kf0Tyb7tcbqPMM/jVYgpx9F64E2j+6KPZ/EMDdgadaAFwFav12W5T/aBIFJYUyff WJFHNBcxTt+rAEzXToSCeXAcSJPo9+Oills4b7CEE6wVrVVYJ60hAY9Ldj6/8zUvSJswCv erTF2NekFaofWhAagTRxcc8U+xusUWM= Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-686f74a8992so77889b3a.1 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 01:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445429; x=1691050229; 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=uDu/4z0sff3MNLq2Hem41DvJLtW9HR7Ht2OY0+o3IBw=; b=iVGfsyXkMcKNuSj4S4+ETT1e5FnNKRSLwcupS7aKQrOa2P/cg11EPb/fa7MepSVN0c souD70V3XZBCWCF1GY2G8kOBoazYK/GwCZP5iJVITEwRi2CFhPhtCnmN6NHRYDRfscjM ei11bn/3SqGlS2cI+uWxsIZ60GgV8/Th1+KRHAcGdOM/vcClXnAdg9IcKu5dXKtmCkaz 1Uv1368bMlurEfH1GvebpNgAfjlYTQWl+OVWRYv+SAitVhKYxMqk7I6vstlqXAV5ZTFg 13mCns35aGRuj+msRJnkqY3lYp1C9AqbhcZNDVttxslcFzKIxthPN+0g8mDIqHh31rTQ XhNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445429; x=1691050229; 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=uDu/4z0sff3MNLq2Hem41DvJLtW9HR7Ht2OY0+o3IBw=; b=UfjyrKPrZc12zzEcAjr/jjJolgZlDOWzHemjVHtrRlMYfy70wcMBB/x6Qiysq5MwvP 6LtBjXpow9tOUBT2juWrksHLrfRSeET8CzsjPWAmhDTEAMA4kx24ixQkQxxaulSEaFRZ t4tOjNzDlCra4Cmy95lRMCtIknihgY6gLx+jT7E0LQWJ7RDFsaajFFNuwOfAn4MDlKOl ElToWCMyLHWG9xxuP4rmqfOBxwjzEWrTBrmiqk+oL9eo4CIPs4366kLq5PAQCQtmtbi8 cZWnw4pLhvzgixHfVVJOvnkEWfWLwIy+gGY89TLkEERhr6x3b5J8a+f9r/gC7hRBpQHx +FHw== X-Gm-Message-State: ABy/qLZwHMBqKrK0RYdHhRbk4zNEOMfXpcjHgNf5AFk1M3snVR5f8lQa 37MI2kDfB+q1X0qSIbC2aVZqlA== X-Google-Smtp-Source: APBJJlHGswV8UzzwdSNooBFOlXCa2QxTNwcJjWEIeOA/B6KtVME+e61/tgitLanHgBraDSTbcyHPAw== X-Received: by 2002:a05:6a20:1595:b0:137:30db:bc1e with SMTP id h21-20020a056a20159500b0013730dbbc1emr5696433pzj.3.1690445429121; Thu, 27 Jul 2023 01:10:29 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j8-20020aa78d08000000b006828e49c04csm885872pfe.75.2023.07.27.01.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:10:28 -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 v3 23/49] mm: workingset: dynamically allocate the mm-shadow shrinker Date: Thu, 27 Jul 2023 16:04:36 +0800 Message-Id: <20230727080502.77895-24-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230727080502.77895-1-zhengqi.arch@bytedance.com> References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 36E37C0005 X-Rspam-User: X-Stat-Signature: igmfjj5h86awq6ck1ijndq9kay8wra78 X-Rspamd-Server: rspam01 X-HE-Tag: 1690445430-797251 X-HE-Meta: U2FsdGVkX1/eE53FrlxbFUU4fFdEo5x8zoj1KTY1fFISzXbKUsD5wuTEJC5cVKVxVKmTY8a7vdKH7thpUI0seIXGBAarAgGIMrolVT5kyePCdcpVE1YUxtlIMp9O/50hVE8fxJjrb+WOKwXwjxozi/MgF9fP6c3wK2fNwDLwOInloX1Q5tg0+jivmfGIco18NL3riRBQoYmf98/VRVNVLOydGrn9MSOIDicfLrc8C5qL1bq4F8+7RfV52dfXqxudRPawx5OiWRGv+7RUsrDFuw6u4qCZ0srmRhhsdN4SV8aNBPPWAkcaBgcCxJZ/HajaztMmM4J1dZbF0AR/Rfi6SlVpxhww/kP+BKbpw/owVEVX74m298vhYHEXPPZU2NDmurClQZAwXoqffK7uLMlCMR0XB91R5+pPesoLUAHzOOae8C0NNwkd57GVGiMhQI/ywPXy0m5WH8n7zbOAv+P7gqXT3Z1JsWzBPjlXUwwbI5PDdApJ2teFdXNbf584o5xuW5ZzVHSctJiuHIgPP5gGjcDr8SHDnWKLfGPTjhuKVV7SwMs52WMZZvWU5D5CgQZJiewmwsWDvQme3uyWp1MRVH/BJQ9B+4mwic+m7nrmWmEbvvexgmtaud7Z9kbbNmi/b8nbPKuUnesTD7RDDe80Pdfs3Uf3pjaPNO0fPqKMQXfdKXmdVenNmke8D/AlFB7yi8fveyLtBfAdiHVK6S5YYUrgB7tRklnSvTX8umiDHk+1oekZ0IdMstbOSaRtZvgpAD2FtF3qTDwL9IbOQPWYGMQPjNoV7rERRrJO15gYjTNrjyk6ac981mvhaDt4+82x1Sp5hEJ/iWt9nK4ZyymAk7z+OY1GRkR2sdSjp45NTonbDsxv9NOQ8JhjSmhzL5Ji3mHm6l6FVbYI9+kr7qXd7B8Yf4JdfdoOhkOJcQ9rYNDNqjGtzKEZrq8ylp8drReuBVTmaX+u553qLf25/Ut +tVXMd0O Cgn/P5ACpaHfLQiMF7OnT4Qp0Vgx86pij9Nyopx9PPUTm9b5JZrcuv5Xwo+U50ShAK95St5CGJNCYlJM9NVzilaOsc1QiJbRkaZTdug1UgJ0wWQlGGvZrpONq9bPqPBe8t2tR4Xl+SEcqrv/byZLQu9w4JmuoMj3tT6+rircEwMCbFjhzBW5BOBRfBsFROao95UkQDmsMQUjT/zUTWwfs5LQEXFZJu/LrO3h+8JTJp10Usd+CpHJypF1Q6I8ZZG80Lp/Sn5678soXdsCRbwFh2TNyqimpvacrhCVnbNweOjqDyimpHp5zCxnf2/bsEDMHC5wKblco4nPd7x47kmWxjrwj7UeAmek4N044U1o3o0XLlEHukHOJhiE4yosIKhGfKl+LDNVd60LAtgAv0M7CQuhW1yfU6yo2sKTo 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/workingset.c b/mm/workingset.c index da58a26d0d4d..3c53138903a7 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -763,13 +763,6 @@ static unsigned long scan_shadow_nodes(struct shrinker *shrinker, NULL); } -static struct shrinker workingset_shadow_shrinker = { - .count_objects = count_shadow_nodes, - .scan_objects = scan_shadow_nodes, - .seeks = 0, /* ->count reports only fully expendable nodes */ - .flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE, -}; - /* * Our list_lru->lock is IRQ-safe as it nests inside the IRQ-safe * i_pages lock. @@ -778,9 +771,10 @@ static struct lock_class_key shadow_nodes_key; static int __init workingset_init(void) { + struct shrinker *workingset_shadow_shrinker; unsigned int timestamp_bits; unsigned int max_order; - int ret; + int ret = -ENOMEM; BUILD_BUG_ON(BITS_PER_LONG < EVICTION_SHIFT); /* @@ -797,17 +791,24 @@ static int __init workingset_init(void) pr_info("workingset: timestamp_bits=%d max_order=%d bucket_order=%u\n", timestamp_bits, max_order, bucket_order); - ret = prealloc_shrinker(&workingset_shadow_shrinker, "mm-shadow"); - if (ret) + workingset_shadow_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE | + SHRINKER_MEMCG_AWARE, + "mm-shadow"); + if (!workingset_shadow_shrinker) goto err; + ret = __list_lru_init(&shadow_nodes, true, &shadow_nodes_key, - &workingset_shadow_shrinker); + workingset_shadow_shrinker); if (ret) goto err_list_lru; - register_shrinker_prepared(&workingset_shadow_shrinker); + + workingset_shadow_shrinker->count_objects = count_shadow_nodes; + workingset_shadow_shrinker->scan_objects = scan_shadow_nodes; + + shrinker_register(workingset_shadow_shrinker); return 0; err_list_lru: - free_prealloced_shrinker(&workingset_shadow_shrinker); + shrinker_free(workingset_shadow_shrinker); err: return ret; }
Use new APIs to dynamically allocate the mm-shadow shrinker. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- mm/workingset.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)