Message ID | 20230727080502.77895-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 CFE47C0015E for <linux-mm@archiver.kernel.org>; Thu, 27 Jul 2023 08:07:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 747806B0082; Thu, 27 Jul 2023 04:07:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F6396B0083; Thu, 27 Jul 2023 04:07:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 597D26B0085; Thu, 27 Jul 2023 04:07:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4AB336B0082 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 04:07:17 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 19085C1099 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:07:17 +0000 (UTC) X-FDA: 81056661714.24.B54439A Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf22.hostedemail.com (Postfix) with ESMTP id 32773C0003 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 08:07:14 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=krf0rRSB; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf22.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.179 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=1690445235; 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=YQ2nJ797AaeiRC4tEbuFSwr/qroaEGD64TBkJX9gwcc=; b=YVtnDRGV6R+1r9teacEb4IEVEzP9Y9uyf6fNu52hoj3wqHGcEjGDWevJPkqVEmZvQb6Ti9 wd5XdarWEvbStE9cH5SHz6UiOIofqz5ZxBK+QwvJn8dQLstfu3FYrlbd+Ai/ypwHtUofm6 6VOeVlkD8RJlo3ZwUvt1ryq36CgVOmQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=krf0rRSB; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf22.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690445235; a=rsa-sha256; cv=none; b=Q9fBcBD0qSPNP4VSdCvv6ts/cdd+RqM0qn37PbfmIAnnbrGmLg710Fqtdj52LMZ5SCkS5/ kqP8t1Fa0sIyTY70cvBMuT7UGgtL06R5AHdpwmKvfKfJtlmdqFRbOvIOphco21izgAXjv8 5Zs9Z8Yi3+P62/6lDvdCQUNuAOBMIms= Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6862d4a1376so188438b3a.0 for <linux-mm@kvack.org>; Thu, 27 Jul 2023 01:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445234; x=1691050034; 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=YQ2nJ797AaeiRC4tEbuFSwr/qroaEGD64TBkJX9gwcc=; b=krf0rRSBuACihGG0HOfvmWM3fExNQmmDQBZSFypO9OF26g2F9IRQXNjarXAj+rDJ2F j6wi8ORGszAJ8F4/2B5RfozFOO9c5wQvkPuwF+U0dnMIFYzI2u+dIV518lO0Mey/M0g+ DAIhAFbNX4boMgnEYCrLvSqMruXRlIM+AwHL8QP9OXWtql9jawORm8JA9K2pNt2CM3by 1AI1wCMU2elwBWzc8zmddDhb5S57BlUFVrs7Qpu26KSs608fAqSWn4u6Hcxn6Nu/AYp6 eAYr/PxpZmg2LEli6lhHn6OsT6FdGj3gL7SNMtigAeYxmILx7EQ2Lx+oYLfIsw664x5Q hi2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445234; x=1691050034; 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=YQ2nJ797AaeiRC4tEbuFSwr/qroaEGD64TBkJX9gwcc=; b=NG5+N+Pk851FcYM8ae64O/synnqLRBTgUfRyKh3bSPqqmxH3y+7EDPHou3khj4M5nt F3SNY/C8t/XAVgMJEyMZlFWO9vti7lPRPgtIaxIWfMNZ5aq8t24/h7P7mSdMTTNWG7sn OcDcSlJOj7cdYHUnOVctxMGsXHzZDhpxJQUED2oc1OY3n8dlfxIwTFZBXc4y7YCnXANy 4r75YsTB3g5/VzZTbFp2ya5EmbDvBbMVI+gcYOessxkUSV/vT+7o2QFRQ71dCmm0jNUM G3TjQ2qYwvzxxPQYkqPYOhwV4hnDH1wbY4TygsQnRq8lhMlIEgQ7gV3puTyjBEdi/GqR oOmA== X-Gm-Message-State: ABy/qLZcOtokQCvKsPHeI6iKhgL0QhgvF949IRlmxt6QH/bH9zptT4te jgRYyL4WbkFmfAlFVJwFymkETw== X-Google-Smtp-Source: APBJJlExJjCwBoW4B5netumBOqdfs5+SJLDXxiJ/1dno6haNjCE+wUan/A+nwEsop7KuM9iLlMTgjA== X-Received: by 2002:a05:6a20:918e:b0:11a:dbb3:703b with SMTP id v14-20020a056a20918e00b0011adbb3703bmr5540739pzd.6.1690445233998; Thu, 27 Jul 2023 01:07:13 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:07:13 -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> Subject: [PATCH v3 07/49] binder: dynamically allocate the android-binder shrinker Date: Thu, 27 Jul 2023 16:04:20 +0800 Message-Id: <20230727080502.77895-8-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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7BVDQOPujj0R8Ytt2fN5BPiI9fMRNZoAFWN0d4Cs7IU1idmh9HrpK2 z713rY9q 7Kvybkn734kJPQUTM9u1xgQPAOOJRnVYj3A2ariLleDbLEc7m1MZ091SEeWVYiFfXdueakwMzxtAyu7iHuNqLQp9Ll9UqTXAYVQi7vAbuoYnMY6BqaL3CYATBB7Ekhd9vUeBZw+A5X3fus3zLpFYDqfTLOy7ddsly3t+3zIzv5ESgHqc9E0jvTAtQj+RgQOZC4mH+YBRPL1uSLI8aehrj1SInrzbpq7H+Uu9H31hucplpV2Lwrmaib0pZXiSMlu/7EwToASeTVWL2SoJrzWnnvPrZGNUmi5AmpJAAYvHXTHpMYHwrljiJ7ws8l2OgH2h5AB4XhupNetQIOnMaVQtQuJwbcdeuv1WSQdJ5FsJe7l5cFGziCn5AQMCm1eDtI6rMY3Hwk8TAUHa8WIrVOIS3x3xgkzdmMgfuwB+0 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/android/binder_alloc.c b/drivers/android/binder_alloc.c index e3db8297095a..62675cedd38e 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -1053,11 +1053,7 @@ binder_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) NULL, sc->nr_to_scan); } -static struct shrinker binder_shrinker = { - .count_objects = binder_shrink_count, - .scan_objects = binder_shrink_scan, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *binder_shrinker; /** * binder_alloc_init() - called by binder_open() for per-proc initialization @@ -1077,19 +1073,30 @@ void binder_alloc_init(struct binder_alloc *alloc) int binder_alloc_shrinker_init(void) { - int ret = list_lru_init(&binder_alloc_lru); + int ret; - if (ret == 0) { - ret = register_shrinker(&binder_shrinker, "android-binder"); - if (ret) - list_lru_destroy(&binder_alloc_lru); + ret = list_lru_init(&binder_alloc_lru); + if (ret) + return ret; + + binder_shrinker = shrinker_alloc(0, "android-binder"); + if (!binder_shrinker) { + list_lru_destroy(&binder_alloc_lru); + return -ENOMEM; } - return ret; + + binder_shrinker->count_objects = binder_shrink_count; + binder_shrinker->scan_objects = binder_shrink_scan; + binder_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(binder_shrinker); + + return 0; } void binder_alloc_shrinker_exit(void) { - unregister_shrinker(&binder_shrinker); + shrinker_free(binder_shrinker); list_lru_destroy(&binder_alloc_lru); }
Use new APIs to dynamically allocate the android-binder shrinker. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- drivers/android/binder_alloc.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)