Message ID | 20230727080502.77895-9-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 5FB0DC001E0 for <linux-mm@archiver.kernel.org>; Thu, 27 Jul 2023 08:07:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEB0B6B0075; Thu, 27 Jul 2023 04:07:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9C766B0083; Thu, 27 Jul 2023 04:07:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B64898D0001; Thu, 27 Jul 2023 04:07:29 -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 A57586B0075 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 04:07:29 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 789178102E for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:07:29 +0000 (UTC) X-FDA: 81056662218.11.8B645BD Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf23.hostedemail.com (Postfix) with ESMTP id 787FF14000E for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:07:27 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KpqQJYQn; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf23.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.173 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=1690445247; 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=ppdDbzxLfV7T8uyJ0+LWzuRMVQS50F9BO9dGotbDPbU=; b=a6SS2KHlPvt/KLX5GlSCqdgKctGVkRGHzWEoOCVzcl08hBY3GvyX2inXsw1L8rBF0MkIRh QvfOtB9wXe9XlcHbiCbVbEJ165WNTlaBpY+I0oQ1f/fLE3rn98aY6Ru6dpMDX2v6PLOI5w /84YcTkpUXE7nXMzama6PyEueJH+lHA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KpqQJYQn; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf23.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690445247; a=rsa-sha256; cv=none; b=ZzRus5boQO4uRHtDX0U8224BHOm6Vty1ExWSXO/ojdj6KFfbDfWanLh0JR8TCIviNfYiH8 OnY01Eb1+A+crgk9C1g6VLuug0ERuye1rAjRjzxykI2jxT1FYyPU0oNNja4mZadRK/b50Z k7rLv9jC2910tG/GYhLvwvll6Mid0GY= Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-686f74a8992so77393b3a.1 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 01:07:27 -0700 (PDT) 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=iBMoPybgGeMu6ffuRPyie3AAt2xzQ7tzmocKt7d7p9CzBfpq4FNZCIABDWwWpxKWXh hWdtfY6I0Rl7BBDL9klkM+am3Tt/DvsxGO+tryYFurmw0IbcwSDPgz4ZdeJF2g+lYojC Fdba+6de2I1nEVBDx5m/4QM1h//7qMDF7EKR2xV6GEacUFkatv9qg8tz28Tri23Y207m UFDL7NtNAkZx6ySHS2HchjbxbnIcBMa2ljK2+Wa+xwAi0YYeKYGAcpXMEgLxA4Fgam/Z sepeEYeO8dy7ryUkpo8ql/7t3IkM5dIkKAw6/miGRHjc8Ox0QVudbWFAeWmgIybrwX+A pajQ== X-Gm-Message-State: ABy/qLYEce9KTm+shdtAgpdziwq5zIcstCvCY+FQQEVQHhE5vZdjYXMH M5bTmNdX70UdzD0vLfEKxfnuIQ== 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) 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) 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>, Muchun Song <songmuchun@bytedance.com> 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: 8bit X-Rspamd-Queue-Id: 787FF14000E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: dihjie8wuyjnxaurz3k3x36zsgd3hyz6 X-HE-Tag: 1690445247-84103 X-HE-Meta: U2FsdGVkX1+wqmFyz5C3JzcIZJDADGfNoS/ZycAhH6f05whknJ+HsU86wHbcz7Rfg1on0gjaIobmXnc9HzP57dqJ9V1xo19byLXCp/DCnDrG2OUsQzh/BrbOi3jl+imZyupn40Vs+HZnztRC2yNwEFkJrISnFsKKlkPEjXV8oj8Xsa/kQN04U7HC8Ux+osr7JD8IF8aMURY/dILQHK+nVqSbJx7F1dZeXXMozIGK5gtNpyd8gROrLs3ZwFiSFIpwA8FJXiYsCWIYMwnMwYjXnN712+T3m2ryok55umpQjbRvQxJWPqrezfcv7FYsZ4spXJsjA2DNJlVmUFTFUgDt2lU0yPoze+aW93x5MWfI2RwcvdTF3GBEIPj3NAksY3eF/DOozdZxJoEvp2M2bNs3JOaJggGx/g+aI8z+8SDFo8n2T6XdHe0Z+rwkKQmCcEfgQx6nKdATiw5p2jl8WL6ydu/CbSuhT/UJWIWhGZLnkOL8uWDfPOQGmDtE0ZpWOA6SIjyVeXXrVHZyaCg7eJObG2bSu+SNOIoczhnT/SpqybJm5qhFh5tpqlPcXntoA7nV/DWeWWEVopE+1oY7awkQPd4jRvgSSnhuhzDSwVPQ5faxlg8IQanMuM8+syaqS/z+V3rHrIgKRJTPVQ76o6XwLvZtS+dqKosQAPHKbgyS4PkVd0EKOEXZvXV4Lb7PTV4Vi4FOBHZgGZ8o5SQMjvxgJzeux01hrpfX1/oVd5apLKVzs80+zcGha33PtOrL7od8iy91CoGBhxnivcC12OMaEUoKAFuil5U/t8ZwuqLSw/Lzm66Sl80ieYEZ7Gc562NR4swpRNBwFqlWVon00u29bICmILoosmrmVtJV3U+latS+Ipdzl6uQ3++NW/XG7l2PnfvBb7S2CYwQW4uNrNgvHnX1/xUwdjJyrRBDFmMnDsRFG/LEeHLVNDYqK1pT7kSn33I/fr48SnZolSNImDa dpEaGe68 ta1ptZMDMn163BGc814RbZIlHF+Igc94kXUdFGWCVd4rpTFxbNGN68+Ye9pQK2evvM94vbHatOb+7fB2FYOeNjZlSq+vHiTM0KzOZIx2y4w62gFKalUXYO7nybKiMnJVNWYLfl9JtIkpukbXeVQX6mtP8jpZ8h6cda4NAaaUtV4zYg2KxjeNikugx2Gx2jgM1W4RUMkMoln72mTKuh8ee+zu7obSx5l/7kSF8Uy+MJgpxWAgQAkKk0wVlsJ46ub+e/zubzfCiMW3C3DIbV+49HluUNM3gry+zt2jWKQ+S6wvZdgymtGD0/VbQ5BVNyAuvD2ubjMSdKyT7SxFcqLoOC0TFYWXOdpfABgM7jgSM8bk8c+lWaMR8YDaTFNX4yFosQi4axRvI2WvEyniFPSpSDPMxQHOqYLC4gOsvumg/zzis+sD7vnnWSpAstHvRPH+C8buS0xME7+UGGyb9KzRMxjS58A== 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/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_ORDER + 1]; static spinlock_t shrinker_lock; static struct list_head shrinker_list; -static struct shrinker mm_shrinker; +static struct shrinker *mm_shrinker; /* 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_flags, @@ -734,8 +734,8 @@ static int ttm_pool_debugfs_shrink_show(struct seq_file *m, void *data) struct shrink_control sc = { .gfp_mask = GFP_NOFS }; 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); return 0; @@ -779,10 +779,17 @@ int ttm_pool_mgr_init(unsigned long num_pages) &ttm_pool_debugfs_shrink_fops); #endif - mm_shrinker.count_objects = ttm_pool_shrinker_count; - mm_shrinker.scan_objects = ttm_pool_shrinker_scan; - mm_shrinker.seeks = 1; - return register_shrinker(&mm_shrinker, "drm-ttm_pool"); + mm_shrinker = shrinker_alloc(0, "drm-ttm_pool"); + if (!mm_shrinker) + return -ENOMEM; + + mm_shrinker->count_objects = ttm_pool_shrinker_count; + mm_shrinker->scan_objects = ttm_pool_shrinker_scan; + mm_shrinker->seeks = 1; + + shrinker_register(mm_shrinker); + + return 0; } /** @@ -802,6 +809,6 @@ void ttm_pool_mgr_fini(void) ttm_pool_type_fini(&global_dma32_uncached[i]); } - unregister_shrinker(&mm_shrinker); + shrinker_free(mm_shrinker); WARN_ON(!list_empty(&shrinker_list)); }