Message ID | 20230807110936.21819-23-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 92D5CC04A94 for <linux-mm@archiver.kernel.org>; Mon, 7 Aug 2023 11:14:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 281F26B007B; Mon, 7 Aug 2023 07:14:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 232486B007D; Mon, 7 Aug 2023 07:14:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FB7D8D0002; Mon, 7 Aug 2023 07:14:43 -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 F3D056B007B for <linux-mm@kvack.org>; Mon, 7 Aug 2023 07:14:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CA07E1A0961 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:14:42 +0000 (UTC) X-FDA: 81097050804.10.534F3AD Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf06.hostedemail.com (Postfix) with ESMTP id EFDF218001F for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:14:40 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=B1CW4rX5; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf06.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.50 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=1691406881; 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=k7DhdK4yFPkNQSoF6zT6Au4mlLD45d27N0vPIDRCvBj3/WxHN2JJX2CcNlNNIlNwAcYWyc oNfj5TijlY0HT3DyLeOzLxry5pKa8Q75Es1VS0ic1gBOxFp5IzgTzVT5ldb7VM3Fwhb4ze IDI8PCg4lJeXAphWjWdNQlvjk0l9e3U= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=B1CW4rX5; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf06.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691406881; a=rsa-sha256; cv=none; b=NcT2Vg2SSy2wCdfTu8iGS94N5FK+jwl4h1hqb5k4vYOSd1TvhYGYmAMJsPTuB8/BaNszYT xrkIB9ZonHi6t9RGrkc43b/LX3lqLymliKk9uyRv8vbqLM+H0uA+OK6MYlo4myp6wJo13R 7AHLoyviYPL0qVm2bnt1fTh9j0umf6o= Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2680edb9767so930624a91.0 for <linux-mm@kvack.org>; Mon, 07 Aug 2023 04:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691406880; x=1692011680; 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=B1CW4rX5HR96iE4C61mcE8Vf6RLeUtYXgDxnwBceT7ft1IC5S++icQmFIFvrt4cG/L 0c/u6FKIvYpbVXU295bMslZ7j2rgVaXwSjJRaIMLa4dIqq6HefzeIHqMKw0/Lo0rsfaU nsC5mn0wc4B6AcTwpHE7UQo4S/4ZAugQvuMvQEsWqhRZLmPoe9oa0Q7yCYFnuuapzCun SWccc4DpmmmlhTogFq9P0LyJEl3ZRZ2cm803+AIasPp033eu68uxaCfAoKnHA+NQuDMw Rtim+7y0rt6vcYQJO+qKgz5xgBY8yFO2AMQKXPDTy0z1fvoO5gByJOuvIrJQUEDpduII rIFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406880; x=1692011680; 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=lwFr7qzbvCnhwJ1cLWr8f9CkIViCZikWjiH4+usvN/Jg4LaXcNLiZvPguRvtrIoDyS efq4hJOY9H7bj95WisHxoNMv+Ej0mpKqA4+OZhZOJ64L4r3mHlr+RapM4jX+BFn5Y9lF qVv0NeH8KX2le1D5Dho2yqNGRI/1zOQLL2bwjKwLyh7vStwR3ytmmGEf7mqwsI75w1QV 0VL/WF1q4HV3MVe0oCNqxc5QBWeHD2a8p4fkPW8KMUqc7h+nsCdXyIG4Tsy9RLfTi3vN cMjL53LALqYV6JnjM0amHOEFUzwbOadFpQr16iODh7K2Zs+TEuADZv1hSclfSW1kcNC0 uVDg== X-Gm-Message-State: ABy/qLarscCUNpQF+cpkSGiwGa2fhphW9yofoyg8qQIu840HetDhG+dj X6CfgmoIbQ7ucECPwu4LUbw+4g== X-Google-Smtp-Source: APBJJlE+JUQU2KnCMqxKRhVbnyE7g/MjXwiwJL23ihCwbN9GtK/yS0Snkx/m2fq2fyEzRCC+VQ52VA== X-Received: by 2002:a17:90a:1f83:b0:268:3dc6:f0c5 with SMTP id x3-20020a17090a1f8300b002683dc6f0c5mr25034377pja.0.1691406879873; Mon, 07 Aug 2023 04:14:39 -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.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:14:39 -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 22/48] mm: workingset: dynamically allocate the mm-shadow shrinker Date: Mon, 7 Aug 2023 19:09:10 +0800 Message-Id: <20230807110936.21819-23-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-Rspamd-Queue-Id: EFDF218001F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: u85mskdqk71atnzygfzxtf8k7k7hp1op X-HE-Tag: 1691406880-448870 X-HE-Meta: U2FsdGVkX1/7s0Yorq2IQYKM8JB1G/JWFagAdwjaFPHo/Y6dAht8AnmnuufQ5FhlGCPF0B6+IhGLLnNrLqm03tIy5AfwAVZ9x6DW6lZ0ETyBPSM4bchTc5PA9jeFFka7ryPb2q/rAJ7EncYsB6IbB+EuIO0Zp/XZb0Ld0I/lVJN0N9mpGUTfkd1mDdTHMRlkmMMPympuqv4OBOLklRF1gmzewrah9CozyT1iHv8bJrXWzX1pMmagpAHZFcoDYPmsfgJ/SOKsGBng0/9uCY19RbwJnTFnARnSI786GOiBSrQQ/uJ/4a9lQmaEWyaL+lZn+LnsHAEYxhQ9kPYaDvYIbIfFZJvhA26RxFVOOgBiasYRaN/kYOspI2z+FLVIsSCKcJ2hD2gYi6BvHsijeua2oE/ggrwliLYXAV4xoQdq4d2Hj0JOGsgqeBUoePlHas4uWCJCquJRnaKGxzHtO0YKGjoBv6FCwc0ba1PNWmkVbg3ARzJWuWf6joxHkmFqcHLaYl7UEAacDdgqMPwjZhur/dKkY1E6gI1RkVmjYlb8QOXZBoRCILf/vHq50ob28HfwGgCTrS7TxSeL4qDFW3BsjSVzMfZSHX8akDfkv57SjIK3StOh+spvrIS+D7AX4S+MJvzhsVhICrbjb9FBxpnfBi2G9QsrQ7QDheLblWO9LmSSKez1NtMlv5h+P1ZP5kYL3G6p4gDb6VfS4VN4bg9Zk+ykomE4xaBqQZ0JNCmJRM8PmjV43ev0uGPfFPcxqkRJFnonW7Ennq4iVI1xu7/qSqnt8oHobjcaOHnUpLw/NQwRnpxmnwVipLoY0QlxaYlCpMrO4Sf0NPkGAoc3fWUchUfDSiiPLlr7fmGrjOwcOC4ZNMw5yJSw+Dlgadgx+Ra0K877OSsnFJeUc2ffv3tuES0OXrunvVjX2Y9bRk/GNw1wDyNu+2ems3G1BQs9N2Yg5SQV4lmAu5P99tKhgFJ EdSovSat hGjRPqNVcEu1VZ+q7bXJF1+mx7ebJI1ve3HklqOpwyHOVgbhA/hfH/zNt76EVRtjYvxTCw7gc8kRYNGqM9u4r5XZMNbUwaoZVjSVSOSnAQ/QTK71d7NJlL9+I5pYpQloohEYDv4DAudiXmeVz/dv5PAzNvus84r8IaJljOT00q6y0UtbOLN6YtNR6ZIVFgbMe/hFJmRtC6HpAhlCQoIcOT/p7vHBrpgycdrvUm9IH1ZqS/Px3R59Gmff5oiq12bTlCzXq+kZnPID8tfueanp3SQMLlFrt5Mgc/kPsR2eDvGZ2VwXgmSI0DlM6/JxHL0SAWc01P4afPU7Pqh9ONGjcEMFHL/5tj4A8WNdvSzzQM0eo3OmDx+jFabie/jmM66nMwfC0aUYnm0QkQk++NmaiMKOKeVZ952pYsiuD 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(-)