From nobody Wed Nov 27 21:30:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1690445267; cv=none; d=zohomail.com; s=zohoarc; b=g4Bm/MWm3keKdg0WAE8Uvluqzp4Pl/HM0XqSsJufqIphFd6V/nehwiv32o5cGWFO+inejgmvGPCFfsywUrzR9h4py1mDXToXA490SHFX5e6tC4haqAWVp/hkkil3CJMhIhLBuxwzeluL0GjNa/5sdBR2i9XOTF9MV3T6O5TwBJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690445267; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ppdDbzxLfV7T8uyJ0+LWzuRMVQS50F9BO9dGotbDPbU=; b=JIQoCNOziMZVOLRWBCyBTLeH5i46BVwZD/dPLdWugUxA+DVqL3LpnsjVHa9BtfCjqy7SM7w9jF+bTqpqmbbwh/BaA3r6SnxngbXaCLGc0On+5OX0oHytpOxCCcgJ4flofwcF4PteoSWPT78GTjLwyHqaCFwn1G78wHWyZwco66E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16904452674551018.2426776518479; Thu, 27 Jul 2023 01:07:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570849.893139 (Exim 4.92) (envelope-from ) id 1qOw1z-0004eV-AR; Thu, 27 Jul 2023 08:07:31 +0000 Received: by outflank-mailman (output) from mailman id 570849.893139; Thu, 27 Jul 2023 08:07:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw1z-0004eG-6I; Thu, 27 Jul 2023 08:07:31 +0000 Received: by outflank-mailman (input) for mailman id 570849; Thu, 27 Jul 2023 08:07:29 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw1x-0000Tn-Rq for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 08:07:29 +0000 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [2607:f8b0:4864:20::432]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a002fc58-2c54-11ee-8613-37d641c3527e; Thu, 27 Jul 2023 10:07:28 +0200 (CEST) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-686f74a8992so77396b3a.1 for ; Thu, 27 Jul 2023 01:07:28 -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.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:07:25 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a002fc58-2c54-11ee-8613-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445246; x=1691050046; 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=ppdDbzxLfV7T8uyJ0+LWzuRMVQS50F9BO9dGotbDPbU=; b=KpqQJYQnD6XZcHjbv/+muTq0vlYb8upK5OWv1aGKt50KKzUi7i+JzF6oBUUsqnnZ8J r8wNd0ItebBMmbL+7PFob82/siVz2lcTITJgiPWkofH/9LJHrT7eh309V59HxxQ0mOlE DIoyoSTd+eeARDBsSwfCZZT+D1eJ9vMkwqGXz/n2dx2kEZLuZLLaNunG9PbX3wXH0AxZ KS3Doj3WekVbT+DS1JWdAAgXSNDy2XRSFj8TbzZy0Apg5FVE8T/dZYbRy2KedtCvtde/ VVp4H8rT9xtwGwXR6cSDDmcPYDcWy0CdFKjtAgYv/8XnYUvwEF4uwit6TMoEpzOExIim mxxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445246; x=1691050046; 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=ppdDbzxLfV7T8uyJ0+LWzuRMVQS50F9BO9dGotbDPbU=; b=BoL7dOFWH4Zc0q+U2+7qcNg6I1XAtHIlmWiUkuKw+FbOkufw9kFFBiZL2dQnGai2B0 cc6SpWa/0zLbJLZ+yUykLl4uwtos3QNAJUMkA0IyvhaW+XLA136mRJBW28t/9uAMbFW8 T1rwP/d0cwSIswBCGNfMFIUwc08Zx1BZxBsKPj8Tv/XO8bWMX3llfH/KO3iM4MWHlZh2 65zzT9lJlI+vsDr90PWBVcIGuVwrLKk2zGFAElDKxQvdsJvjiTzEbJrgvnmbmxNxg7Ny 2RPIQAShc0XUz/HyQfcWGVCz4Ww44a4PhFibXylgpF5wP/GB3hb/78ZHmaDtNEE1kd3Y OpLg== X-Gm-Message-State: ABy/qLYiXzRFCetgm5IoDw1LsEwMkc8mmLe5c3S8WGVHK3sPFR8REFQE Q1wfMDwToyZuSFSGFtPDlhrCuQ== X-Google-Smtp-Source: APBJJlG6gnRngQzsFbw9KnzolcByCK3s/MKtuzn55eodinGMlyRsxgSHfIHEIFN3Q1pZ+W9H3PfVAg== X-Received: by 2002:a05:6a00:2b90:b0:67d:308b:97ef with SMTP id dv16-20020a056a002b9000b0067d308b97efmr4583872pfb.2.1690445246349; Thu, 27 Jul 2023 01:07:26 -0700 (PDT) From: Qi Zheng 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 , Muchun Song Subject: [PATCH v3 08/49] drm/ttm: dynamically allocate the drm-ttm_pool shrinker Date: Thu, 27 Jul 2023 16:04:21 +0800 Message-Id: <20230727080502.77895-9-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: quoted-printable X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1690445268393100001 Content-Type: text/plain; charset="utf-8" Use new APIs to dynamically allocate the drm-ttm_pool shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- drivers/gpu/drm/ttm/ttm_pool.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c index cddb9151d20f..c9c9618c0dce 100644 --- a/drivers/gpu/drm/ttm/ttm_pool.c +++ b/drivers/gpu/drm/ttm/ttm_pool.c @@ -73,7 +73,7 @@ static struct ttm_pool_type global_dma32_uncached[MAX_ORD= ER + 1]; =20 static spinlock_t shrinker_lock; static struct list_head shrinker_list; -static struct shrinker mm_shrinker; +static struct shrinker *mm_shrinker; =20 /* Allocate pages of size 1 << order with the given gfp_flags */ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_f= lags, @@ -734,8 +734,8 @@ static int ttm_pool_debugfs_shrink_show(struct seq_file= *m, void *data) struct shrink_control sc =3D { .gfp_mask =3D GFP_NOFS }; =20 fs_reclaim_acquire(GFP_KERNEL); - seq_printf(m, "%lu/%lu\n", ttm_pool_shrinker_count(&mm_shrinker, &sc), - ttm_pool_shrinker_scan(&mm_shrinker, &sc)); + seq_printf(m, "%lu/%lu\n", ttm_pool_shrinker_count(mm_shrinker, &sc), + ttm_pool_shrinker_scan(mm_shrinker, &sc)); fs_reclaim_release(GFP_KERNEL); =20 return 0; @@ -779,10 +779,17 @@ int ttm_pool_mgr_init(unsigned long num_pages) &ttm_pool_debugfs_shrink_fops); #endif =20 - mm_shrinker.count_objects =3D ttm_pool_shrinker_count; - mm_shrinker.scan_objects =3D ttm_pool_shrinker_scan; - mm_shrinker.seeks =3D 1; - return register_shrinker(&mm_shrinker, "drm-ttm_pool"); + mm_shrinker =3D shrinker_alloc(0, "drm-ttm_pool"); + if (!mm_shrinker) + return -ENOMEM; + + mm_shrinker->count_objects =3D ttm_pool_shrinker_count; + mm_shrinker->scan_objects =3D ttm_pool_shrinker_scan; + mm_shrinker->seeks =3D 1; + + shrinker_register(mm_shrinker); + + return 0; } =20 /** @@ -802,6 +809,6 @@ void ttm_pool_mgr_fini(void) ttm_pool_type_fini(&global_dma32_uncached[i]); } =20 - unregister_shrinker(&mm_shrinker); + shrinker_free(mm_shrinker); WARN_ON(!list_empty(&shrinker_list)); } --=20 2.30.2