Message ID | 20230807110936.21819-8-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 D0460EB64DD for <linux-mm@archiver.kernel.org>; Mon, 7 Aug 2023 11:11:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7161E6B0078; Mon, 7 Aug 2023 07:11:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C4546B007B; Mon, 7 Aug 2023 07:11:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58C278D0002; Mon, 7 Aug 2023 07:11:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 496076B0078 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 07:11:29 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D1C3D140879 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:11:28 +0000 (UTC) X-FDA: 81097042656.23.604610B Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf28.hostedemail.com (Postfix) with ESMTP id E7188C0018 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:11:26 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=MlLUTFwB; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691406687; a=rsa-sha256; cv=none; b=CUeHoLufXsluflVCyL0l3HqeMQKleCXTP8gG1pGeP0x9UA4BmF70d73jZyPj66lm3F1cyr OZjgFLkX7wP8nTYk0cA77CjEmzY11hLdXk8j5NNqzyO96HgptB5wVb3xBh2qGPYVVWRUoE mGx+SWk6+xbvbR7DNPa1zR3gPN/W+DI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=MlLUTFwB; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.176 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=1691406687; 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=6gyOnlRCitj/Wy0vLPBAGyww0oZRAGqArswFqbf3HUyWMGi6T0F8jSzA/iGrVaUzn6/rJo M3bAplsoktkRX0xFEbJ31IKiEl3DKA6Wwh9xrmoxwQ9UBszVUKE+dnY7lDa8KfpyOE0mRq MXYzreLuVEA8J/GvJAA4FOUOwBUa1Yo= Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-56462258cdeso525401a12.1 for <linux-mm@kvack.org>; Mon, 07 Aug 2023 04:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691406686; x=1692011486; 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=MlLUTFwBYj7txqomyX5RsQbZ0tuOTesyUPZa0imDy/CbzwI18VWLrI273BHEpiy/59 rQ1jtyDjjrm0A2fn5g0PDon6y1ODu6aNGJCylYpk7eBz5aCl8EYDqiryatgBLfE6j6wl z5DQPgedGrLwi+nxG0CDlruIcPgTiyaIMd4jUriznEP5tOm9lhp6XNenm09AU0AYyYPz hP8xB6m5xmZ4JEVQ0Bc2ouPU+2lWMJulVYbharTYlD2LjNPOhOgz1BVr9kOg3WfUC2R8 kqamQX4BkmNd+ktmJD6D1JNyz78v+ezzbXueyJ3khYdsrERbOdoO7diXy9Rr3O+Hss94 NCVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406686; x=1692011486; 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=CtqaEhFgXrUeP68p/mTPiCyuVG/rQwhuI9lCuHAk2I1myGHN3NmWZavKXzLmOek5LI /Z7IM+kVWL1gwG7Lpryqu47So+QdmuW1x4E9qGR9tlB071AA1FcDAIpQrEceq9uppCje mAwDK+q6LEPzchQq3scNzBLw6hqtLHrAY8+hRJoPTx6puM3QmT8fBGkketNFPWVI64Sj 7faT6+aGxAsTSaDR3PE0/YOBLY0eEJbx1pBLNMIx8YMiEJDQnCDLOLRn7VzsuP6waXZx 2SUeh6eWfelJYckqpQPz2Cy6bieERM4F/if/skPq7qAQoDL85HSxnB0Ix8ameAKyjx9A rO1Q== X-Gm-Message-State: AOJu0YwGhlF4G3XbptX3C9cx1gyTnKZh6oGhD7xSPcLMpP2VMcEnM6cM ezh1pVjienHaJc5/g7iwhUb2bQ== X-Google-Smtp-Source: AGHT+IF4N48rqO+yuBXOFXn//EzxG9zSjzgF29ivUv9kLYfrFhE3z4laIyd5mkV4h78zNK2JaBG8Rw== X-Received: by 2002:a17:90a:9c3:b0:269:41cf:7212 with SMTP id 61-20020a17090a09c300b0026941cf7212mr4956295pjo.4.1691406685878; Mon, 07 Aug 2023 04:11:25 -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.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:11: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, 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>, Muchun Song <songmuchun@bytedance.com> Subject: [PATCH v4 07/48] drm/ttm: dynamically allocate the drm-ttm_pool shrinker Date: Mon, 7 Aug 2023 19:08:55 +0800 Message-Id: <20230807110936.21819-8-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E7188C0018 X-Stat-Signature: d9p9zdhzpiydapi7qqybm7bo69ouugpd X-HE-Tag: 1691406686-822658 X-HE-Meta: U2FsdGVkX18Y/3cnZZ5ktNKRxiB7vbHTMdcZhxCki3xyhG41OKjVhqHP0LXdEkGO6UgztQDjSh6fzn+hFAJRnDPbhOXiIj8y2Xs9ah5Ki4Pt7pFV9qSR5t+S8NpU6DTkELahiUk48U+Mi+5J6R6Jwqknhxg1WkfFT1j/khErvS1yiV7IWodRlShebNdLKh2yGxHcRKr+tJGJ7bnmTOFSGoS6zVSNtLB7MAAqmy9OuCpy1i2pUTh1UvsDM92zW+CJyCIF860bAU2IoHLYuzuwj7kwG78peWreeA7EMOvNKxTFtwaYXmc4iev3NXnXhjwlDCAN9A65r+y1zFMPNdyXNUgMchbcmeBBohb9M7RcvfMuUYIvirR+RPXhTj7P5Vc26B1+GcgM+JYdxuH0fGeNW1QpnPVkRyd51KQCHqkRkP2F7mDHKJR+8FXCqQpc6ovHtSxOKbckLmykU2esiofp6h0OycylKU0OHd1sp74xIMJqxUmM55xojUNF5rwvfPeserkUw1Vufn6YUHGeA1ieIvzs47Pe07EG6BQ4NgsDzWUdtDsQU3wzhgBPIlyFUEg6TzzyzMubyJBIYsj47sD6LyuO1EaBAc2B3ZxTxnyGOsNmi+CP7ajykeNclMgCDYlwG0GdS4Co1tJuiwy6vK6rMc9GBRQNjGnA0sZa9hYBuZspO8WnJnF5Hmt9vl4I5tM7hq9cVjrECoxI/RsJouXLuOolP+RFR2QgEI1joXzdx6kjWh4LTYP9UeUN5q2uUtD9mW/FzOpUVUijt/8ZbbYDpoUNlm4odoiITSY+t3NmlWjDKJvcPpiVsvTtvvm9Z1nEkthu0lIaSBo+LPKbYPtRZUY4hT5tURzCyn2crWkQGA1Cf1qNL9o88V2HT+xCop8xpQONyP5vV2Lep/8w//XLyJgC96Ix3fSRCb3bcPRaF5vWn8J74F8SA5fkppnQxNWp1K/AwZ1hYb7YHngUPZJ zM0eqVep pK69Qr0PUPraQD/fQr96lZkarPUXsUnu3rFnOi0HmawYMkGBE6DaICh9ye4yas2FOmY2fkqepwtVqLiEvhQMoUy3wstwZG7mz/RtdUnwesHjVgfWoGxthXAc7G2teiKeYmJlOab4gi6g0xzeJI31+q3IsPFf4pQYlxM5GkNA+CVTaYFAA5HtmooEgZ894SbyXXl06DHQcMaQd5FgxA8tS3JjP8FDebokMSCdQRVpgudKgrPNeRA2KxTPwyt+PBMBMJdMnntaZiU50oed/PBPY08Dqs2ju5VN4rChwvt8TWABcouJ77ocmYA91nYpDzPQchZPZpuzA4UEc1Q57bwBr3PINJvWmR0RJXIcHPet76IylfcjjFXA0ltJTmPZu68ZSJUKbnW8O3yDdbWrZ4PsMPp2GdW2AIeHW4Jr9NVazBbRXsXPkAb13gFN/FSmkfBBpYifMrAjG1Cd2i8bimMrSXgDQSw== 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)); }