Message ID | 20230911094444.68966-5-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 D5365EE57DF for <linux-mm@archiver.kernel.org>; Mon, 11 Sep 2023 09:45:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B08A6B019E; Mon, 11 Sep 2023 05:45:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 760B26B019F; Mon, 11 Sep 2023 05:45:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 628EB6B01A0; Mon, 11 Sep 2023 05:45:46 -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 506156B019E for <linux-mm@kvack.org>; Mon, 11 Sep 2023 05:45:46 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 288A9B3A13 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 09:45:46 +0000 (UTC) X-FDA: 81223834692.03.E0AC962 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf05.hostedemail.com (Postfix) with ESMTP id 4578810001A for <linux-mm@kvack.org>; Mon, 11 Sep 2023 09:45:44 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=hbFTNtZE; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 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=1694425544; 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=hCA0ApwXV5FyQtvOpmWRZ9XMHHHCgvXZoPv/VlrFSS0=; b=ls7eJsbLXqph0I8f8nlWP83PdRG+3Lm+7BzYewwPbva6ThSrh0jPqVAkHxUcjwp0saqydq 4EISQ5pDhjQr8wpk4daWcfLeqBTVU3YwCm50CuC9UrKlrq3EryeGSpKEGO7FpcJXJaOUnI s+uC7KRJI8t6bUc0deFiSmqis+CDufo= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=hbFTNtZE; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf05.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694425544; a=rsa-sha256; cv=none; b=JU/MLUtN9/OcTu2CAPz2NPdtqcgtiPOsD64oqpa1lyjAaahnXr4Il2MZ57cuwL6YsHYvU/ CsR8FZdnecxP8vps1DcbbhxnHHUmK/Bn0KM2/Rw4eBLYPJowNcNiLDHC+kmWioISBbhIfx TjpU86N2WJnsArpbLy8jf9ES1BX1ySc= Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1befe39630bso9363855ad.0 for <linux-mm@kvack.org>; Mon, 11 Sep 2023 02:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425543; x=1695030343; darn=kvack.org; 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=hCA0ApwXV5FyQtvOpmWRZ9XMHHHCgvXZoPv/VlrFSS0=; b=hbFTNtZEAJ8iCdH7gZG0k8TQujGOLvf0BN+4QlH8Mzfh1NcorCUqt054mqUmP/gosK PwS5/lbRhrNmY4xLYo3+0bEHFdMnv8Ik75/+DHKF5CEZZT974TtTCyhCauV4d9jT5XOC 0DPVZ4JEedvExbT7iSBFAzHc9PZ4W0FSMeU33XkqWdy9lN9Hw5zVTmnbUyAY2u1slDRb W+kkvtpXRSeRgF1hd53O5EtDgjgOVlq30Cp67waPCG1uoLJB9GuY2I2LqFrUHZiJedpx 2vCoQgFvMwwAG2BkqGJvvvW3UOdviuFdn7wnmfjgBnovCYY9OIWsa0C1EtFqo/SLG0kC M5DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425543; x=1695030343; 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=hCA0ApwXV5FyQtvOpmWRZ9XMHHHCgvXZoPv/VlrFSS0=; b=HPgC0agRmDKjDLKLyZe1TcGyPCViZJws09JRU09FcVp3GlSYO/VLsHtSn24Rd2C8aP E5jFw/fc124AFTZ11VGPv/iHD/Lt/2l+VErC4Qmn3myEx/VMswO3viEDI1E+hu1hCfSo +l3uVbquhjlv5aUwIigIPZL4tjHmGyDb3mJVQ+LI8EomWqJ3Oud5GTTyLVaoG4aQLqg9 ML7usmSBy0++K0W17k3M+JVYBm5XjKKbTx91jPuZEHbYYvD64SWpsrsji3mP5YhwDxXt Yp9ulr7P/M+TyHU8PKgjIEBNimqsjPnydnbJvPt+h1GhGVsab7zsRZHhWR/DQER3/qvu nLlA== X-Gm-Message-State: AOJu0YzPBFXOnXiuMbwtS1W1w7tccKybR7PWPjkijiOD5AD1xOrMntqd ZtACrie+KgtdUuIAO7DqQ6cYCw== X-Google-Smtp-Source: AGHT+IHdDCNX66HmyeFeumyllN+fvmvJwteuvjAREsMUnnfysYcrCUJrxwo3wRPJ4iCHNwAnAJyjKg== X-Received: by 2002:a17:902:ecd2:b0:1bb:ac37:384b with SMTP id a18-20020a170902ecd200b001bbac37384bmr11076107plh.6.1694425543157; Mon, 11 Sep 2023 02:45:43 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id az7-20020a170902a58700b001bdc2fdcf7esm5988188plb.129.2023.09.11.02.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:45:42 -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, linux-fsdevel@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com>, Muchun Song <songmuchun@bytedance.com>, Daniel Vetter <daniel.vetter@ffwll.ch>, Christian Koenig <christian.koenig@amd.com>, Huang Rui <ray.huang@amd.com>, David Airlie <airlied@gmail.com>, dri-devel@lists.freedesktop.org Subject: [PATCH v6 04/45] drm/ttm: dynamically allocate the drm-ttm_pool shrinker Date: Mon, 11 Sep 2023 17:44:03 +0800 Message-Id: <20230911094444.68966-5-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230911094444.68966-1-zhengqi.arch@bytedance.com> References: <20230911094444.68966-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4578810001A X-Stat-Signature: mdggm3kkeunyuiqixewazymho6p1c3jt X-HE-Tag: 1694425544-995204 X-HE-Meta: U2FsdGVkX19W1KCS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xFQCs4ceEdGXwY4RnUc3dn7Zl7FmiCXLXcLOkHxGMYtYi1PWQHSmEZJ0UxCvH6zzRIp458Ggr9H+BduspMavfQzq8rO1vgSZKVlMJMe0E9JoBzoZIFEVdUryKSIo/G2iQ9gNH9hh8ROnJFCba8k1xPDnLACGCp+NeK8kb2pj/hjgsdZ4HgVqi2VyKvs5bjOUEWrt8fSyEsqnYNztm69ZNgre/PJk0P4Ul2HZo8OvZtSIT8bZwZWECv0j01lK4d9ztqT+OGJ92v5LsObS68qLf9vULgxrUXyO15/MeJY3uEcW2sFhEW+YtcW/6S7rcAUcQ3ke2tTewdtUvv6J5V/gkaGGAwsB2gxDnbJ/dzHnP3/JiD5sSRN9otxcM6enLo+zqW0m6a7i3Z1TddOw4RmI6rQNXMZx9gwrlgvEj4Zvb4aOjP3AnZj8RPuLhp+IgQGT9b85lJDwIyHRnCf9RR1glodja 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 648ca70403a7..fe610a3cace0 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; static DECLARE_RWSEM(pool_shrink_rwsem); /* Allocate pages of size 1 << order with the given gfp_flags */ @@ -749,8 +749,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; @@ -794,10 +794,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; } /** @@ -817,6 +824,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)); }