Message ID | 20230807110936.21819-7-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 0B2B7C41513 for <linux-mm@archiver.kernel.org>; Mon, 7 Aug 2023 11:11:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E9586B0074; Mon, 7 Aug 2023 07:11:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BF846B0078; Mon, 7 Aug 2023 07:11:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 787668D0002; Mon, 7 Aug 2023 07:11:16 -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 6744D6B0074 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 07:11:16 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3C5A51C992F for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:11:16 +0000 (UTC) X-FDA: 81097042152.15.53C8575 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 62354C0015 for <linux-mm@kvack.org>; Mon, 7 Aug 2023 11:11:14 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=ln47b2De; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.172 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=1691406674; 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=BJmBEPk9497s/+ZgpA0ytICI5ylJldgwcBck4/PP85qQhEhWJT+E2OCu7D0WbR4VUOnbsC EEkgTAbysZaPqU6uM5vogPGWd0iOWIHlikcu9GR0Bsk3nOo7BygwMeJUu7UoqgfQgdlh0l 7m/BZpPFg6bbU3QEsmGlYK7T0Jl7koY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=ln47b2De; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691406674; a=rsa-sha256; cv=none; b=yKIpZ3PE7tqIbtHAdQRat3BzFKCAysJAPtZhSe8peFzu5tHrj7eAbUjVejXTRnqJyi4SDj gPxub3uqExYRzwG8Vjs1DFpOTw/blXj8hTo9MkpW+B4BhHXgvEWp7U2pCPaKlJsPTs/y1Z dNeqeQvA0DYR5AsHybm7eLQCzv5+v7E= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-51f64817809so359940a12.1 for <linux-mm@kvack.org>; Mon, 07 Aug 2023 04:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691406673; x=1692011473; 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=ln47b2De8WoaconN/yovNFIYkpyrSlbHjJ7O30AuN0v3fhaptV8Rv8p/uTgMw5ewUp ZG1baXWX3w4cWqVDXIBOemS0oLj2+PNkaGXC2OZVpKMXphkVdxVMTs/lnTAL5HQl/5sY XaAH/gxR2iJTsD9i1SGvIVeauJ8ohBUlyO6fZCAIfCsaCSqlNBgSWC3X4OcCTxOF8D8P aJ3rhIbrBRQ4RScgXu8Juii6sq5YNvbJw6x09Ixyfaq7t74WXRGryvfs7JEz6b0jZFwc ahGUwsb8fn5Z7b9T7/r6r1MmeGyYyDblu8RFgBNHHb0eaf9aJCBTyNjHYvmNxb3vGqrU A9hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406673; x=1692011473; 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=mIBH8ICdpAWojS1QC4sE0m3Nhup1wMuyRtpNmOGkjzaxsT6FS8kQVGEUuvarSn5+6j VzDYQRUx4TYcM2fv6TXywnTWKD0jB1lfKV73tsSAeqp3Erj8qrrJ/54xuO7DqE97kOtE y7kLBc343H9rsLhvaVzaea4ZUyU+b4yqCE0VKfpvkzZptw/QidYtANeRMn1EHTPyxAMC oGw9E4Z0ZTe+NKzUEsBmltYdLqGDnKUPE6mtFq7CihLp3MCB8UeIX+Rj+gpZIDrPSxZa 2ohL5XiuObt2Kms4skPZaE3DVp+htjir9XVBRHQhdWjJZxj6UlPudTy9zdnY6a+xoJKt CT7A== X-Gm-Message-State: ABy/qLZNBDH7A5lbYh7UJR3deMyHwjBgadXKr6SSNcqL5AZrSb3O3M+I AQlv6F74BZqI5gmao/eTmKU7Cw== X-Google-Smtp-Source: APBJJlHrBtuiCQCJiVcJQ0g2xFi5uTTiYi1uZvqZ47NJp4VxlVmrIr4dlBS1TaGO2GoKAlBNE4DJvw== X-Received: by 2002:a17:90a:53a3:b0:268:437:7bd9 with SMTP id y32-20020a17090a53a300b0026804377bd9mr23468663pjh.3.1691406672888; Mon, 07 Aug 2023 04:11:12 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:11:12 -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> Subject: [PATCH v4 06/48] binder: dynamically allocate the android-binder shrinker Date: Mon, 7 Aug 2023 19:08:54 +0800 Message-Id: <20230807110936.21819-7-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: rspam12 X-Rspamd-Queue-Id: 62354C0015 X-Stat-Signature: fd6w6g53r4u9rwg6kaagm3zqd3n75r8n X-HE-Tag: 1691406674-85565 X-HE-Meta: U2FsdGVkX18RHxZ2W6DlRzK4GiYzquu7pprnr7iZ6n241rnTu9wQx4BF4L6omKMqUke3GJA9K9M9OBq02+Sg/oXE+5mmPQCyMwfMCWyoAIY6yQ1LLGR61B/3RR/iOCVqZmFX9e1PNxWK7+HYWooVE8M4rEF1jhMZPN0797e8UsMi7+oT4EUVgYWZDJST9YDuTK/TgltzmY1lADtrt6M8kO/DVbh6lFhp+BdI7vumZKvhpwTdYeb7Es9k/JPqPHMhlTZvyv4ifZB1H/7be/t0WPvGTMDsdtPyiXxfxmE1VqgsDdAb0zct9eGiSkKDXqnS5TdxYJul+AdVJJMdk99o6GlAhcfyA0qq2DYrtdq7hCg6hQctSBNMi13MgcrhhgDuVHas/Dl/hXeV6ksxc+sYUHZccvcd82CSOzv6xx7Wl7a0OE/qVhDXCuV2WeGVfsMGg2TBPTfiE06Na+BFvVluH9niGjHNZhyL6KqalUVXyRjc0pzp0+ED0Ev0XMmKo9QZUYnHpDG5jualTD1ULj018wz8Jmxf0Y5xUvEs8Dh55a+sSVCcsCnIvczlHZmaH3VvIc4ulbo7/SqJ8caGhU55QCmy4eyX2HATy3Fs36d95Sxicmf2b46qn0mz7rIc8tuNL0dMiNzZehjgR2lhdSstwW0F4N5OlBYpv/UWwZN2va25jnDZsYbio2IMQ9gHULMto29mzxSN2DnxIxEYPTAWc+Vhg8ccpoX+xUx3Jz6UerHVOh9EjFLP7cyCJuCUkyl0Zr18kxktRdZwla2xMSdpddgRMCCRehN+yeudVH8j8VEBagRoyTDGNnmKpIDs4HFUoa3i08e6CtB0zcgcYEiNg/urP4RzR6kCtxxMPp6WuRUR/LiZQZT2UJPHUCORSqqV8JZd7oFJPJzS8OdQkwMvhMG7RhC5HGsP5ZUq9r916krC/Z/CSs/7tT4BcyYYzfnUJLjsCNl88kUcTPgxHAL IBLIJkgZ HOYKR83870wqeO9YLU+T5pjcrutkHh9Y65xFNBDsh6+Sv/otVYkYqnhnzuzO2EPSUiOq76G9TJP14EbP90OSoLQPka5e/RWxEoKjXS12DDvoqNW0Nloq7goYoP39A6noasma083wOo0VUkU090q9eKI9AYhIB5Gq7IAmKGyEU2wSEqVpBPgTeCVoz2SF0hFArUb1h9BcyaLHENTPXUZwoT+8gCnkXfIhOn7CDLc3O4pcPJMheY1SZ+ggzCIynIZnuB2at1aSHQ1kdIhn7zrAwS3qTynBU8BqlHXPTlwXhwgAdd/VWP56EdI4veEAwsZm7uQQg5JgZDJ7ELnVQhD22E9JzqlKbof0r+aPxDcVHc5yDhK6jdwZRD1avEkSA726339oYX0cbMefgZW/yk6O0GZ7PHEnBHv0la6sJ 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
|
> On Aug 7, 2023, at 19:08, Qi Zheng <zhengqi.arch@bytedance.com> wrote: > > Use new APIs to dynamically allocate the android-binder shrinker. > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com>
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(-)