Message ID | 20230724094354.90817-6-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 88FBBC04FE2 for <linux-mm@archiver.kernel.org>; Mon, 24 Jul 2023 09:46:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BB0A280003; Mon, 24 Jul 2023 05:46:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06B5E6B0078; Mon, 24 Jul 2023 05:46:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E74F1280003; Mon, 24 Jul 2023 05:46:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DB40D6B0075 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 05:46:09 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B3F511A0A13 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 09:46:09 +0000 (UTC) X-FDA: 81046024458.25.3F195B6 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf07.hostedemail.com (Postfix) with ESMTP id CB04F40028 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 09:46:07 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=ZITiOrrW; spf=pass (imf07.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690191967; 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=vu9DfqGDIkVtY7CS+mn/8y6VlhAfp+/Q2ofuaCWar5Q=; b=kydD5r8R37wYa+WaM97onkfnJQ7nZ0zaqgdV6rbwVgiEmQjl+eP1zIMF9qoKky0EEGo55f slTMUUDhPEMh3sR/xGs8frIshey0NO2V754tx33JUAEvWisKKJiB85B4oaCeqCXhxlVmjx rRLKm+kPcLRfXcDxtTgbRqsHA/v11Jc= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=ZITiOrrW; spf=pass (imf07.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690191967; a=rsa-sha256; cv=none; b=kZwf5pCl8uwpHTYRcUK1FP16p1paH8ZcN8of1LyF8pxkCtpk356aEe3boDodcI3Ep0ilpN oYp0ncCMKE524Md4Em6XBojaOF8zwZtRlMUUmxdS3MPjhlbTYotT5fV84skOAsH4lnQ17u 2KIhdDtZ/FhNQJvfH4FF1/PfeHN1wLM= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1b867f9198dso8893985ad.0 for <linux-mm@kvack.org>; Mon, 24 Jul 2023 02:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690191967; x=1690796767; 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=vu9DfqGDIkVtY7CS+mn/8y6VlhAfp+/Q2ofuaCWar5Q=; b=ZITiOrrWh+FheWM3chZFCAM8bc3YrsEgqzfm5Am/axy3dDhyTEHWaCIE6CxJlUheOx RF45EA9aOXE5By7kx/OP7STghpSD/KEB/oF3GrXK+Myxe/+Fwg6k+PP3FURA3cxLYMYy QPmEGcQxgz/g2uZ3I+YFETVsDVpSfeGJ/6AYCWm2OW7IkIAxCPa+wrGdNlr2psYdQiso l4rMdXxvPMn1WtqWv/dfO7wx6DqTx5ztQcgxaNLtyw9DkIVWCy3gu8FnfH++DQ/RAVD5 IA2z6EzP9oeF3tWiBWkf5RokEJVb120E1SPLRv9Xx8rFVupecJKnGVj8I/3khxvVhjBZ QV2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690191967; x=1690796767; 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=vu9DfqGDIkVtY7CS+mn/8y6VlhAfp+/Q2ofuaCWar5Q=; b=KzKVepcPIxYamXe7OiGyR0lEQ4tuXRmBbu8qPaYrm5aqQrZ/6MvsUbT/k5JfPsose8 DDWedQzPF8+mmII1qZ7uwFvIFou06cJE24poWjvEYnEr7xOKJGUCt4qrQpSuZy69Qi6c 3DpgTJe8hVI++/eLBWHbFuu8mca1z7qf8de0seT+bgNXm0fDhHo8cTMnm8L/XoydGcOm opPgKLob1m2WJIXRPYEhYTz/Y+5BxyH3qMGIHEtVj8hUXljyos7/c6fZ3iAJxuxn5Kum stjZ+aDFE0TelCyFHiie+Ph/IuHCPGNfwE1vPqijfa44G5QDMrqHH4ogCey53JiiC4ls JPqQ== X-Gm-Message-State: ABy/qLYiqXKngarThBs6zXTct41ogpRJFakGdzSykQp8XChFc2qSzSBm R8XFnGIeXkhThVswwJj5z6haiQ== X-Google-Smtp-Source: APBJJlGrsdFKJ71ukJT79kDa1W+M4ztJszdSUa3mf2ArYfnWEb5YwD/wtpSbLXe4wEi7ibAUftTBwg== X-Received: by 2002:a17:902:ecd2:b0:1b8:b4f6:1327 with SMTP id a18-20020a170902ecd200b001b8b4f61327mr12288935plh.6.1690191966684; Mon, 24 Jul 2023 02:46:06 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d5-20020a170902c18500b001bb20380bf2sm8467233pld.13.2023.07.24.02.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 02:46:06 -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 v2 05/47] binder: dynamically allocate the android-binder shrinker Date: Mon, 24 Jul 2023 17:43:12 +0800 Message-Id: <20230724094354.90817-6-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230724094354.90817-1-zhengqi.arch@bytedance.com> References: <20230724094354.90817-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CB04F40028 X-Rspam-User: X-Stat-Signature: w3z5os5yd947rgnhnnkw8545cxrzz1zi X-Rspamd-Server: rspam01 X-HE-Tag: 1690191967-145429 X-HE-Meta: U2FsdGVkX1+9iH+OoconJlMosRBm0O5rYOM+5kWilHJ5MqA4b6QYBjgq/baIa0y3tEnPFLzeopVQUKyR/uQZjBBDFyZIS6onT9FcMm/CQeJa4vwDwQgt/TQ9Gil85/mZxt+Jbqmr/C85EEpiIokzsG22xMSJ2clkJ3EwQqTyj5lrtO9WtRS1PH/hVpX+EOY9hjc+dcY8TPw41/5eECv2hu3irUJWpwmrxvdB+3rO4oXN3HsXM3RWRLqhx84lZcow+Lu3f8uQ7cSt+khVS4aziTdHpYJLnm77Jxxf/SQOp/2apxKDAriLNwNJEz9UFkD5RTtQipOyHN43mAwNEW0qmmOgXtHEaPrXaYQNNI9UypmpNSEGiVmgKt1kLBi6O2fwrMzfcR34bnHOxW/ariyOF1QyK1rU+ccjlP4VzxxROascFPOXLM/VdQ3jpxY6lQ8xZ6hGXg7x+22N3WOTObRbTyfLIqChXcDmK+ZrSydCcEja7cG0yCGUkJN+CqxQ9xsIzvjHR0Rf1Byq+ABLlncR7asCGE1lpmZnIynbZDVMvscCm8YscqzyNu5n44aUGaguYZAtk8glUX/UPeKPo+7UwfcYW/LXMVP24wYw+oTxG3dUgrdQf9p/XxqitlEItmOKl8JW7q0Q6XPfmoSP88u2ITSqrO8zBB44LicQ0insFosRbmWeWCcScoxbtLkgyBbD02VEdBr4O6nwMUZfbuwuTbPuKhp2Hfr3IIdO4DlJpm+CsBWm1q2BO3gnxr+bKQ9YIqTPC5pB0Qnw9807Cb5ArR/SLs/ho58lJLbv6q+x2LJZoQj8J+cUf23TokaaI18XMsn4fbdPruw2hE14VY/IPgx6xe7Vw/rA/w/U1fq/37pwBh57P9BBN4mR1o2EIr+CNNROXyao4/MI5cyBa+xd7qK4x8oiGna6n+PsFGxcAQ/C0/iS7P/mXa4QLJbN2eVQHQDFBkFAXd0xo+q2kDH JjdOKSf+ q/gxf662r6M/7fwGyEuxCJ+PNnI8Lp7c9AGsFwl08rJc6JAY1wCaTgTsfr6OsBM5iKQUmRg8r5CmYp8jHC2Kd95UnUKlpZcmlKoBJwuuKfSQTz5O2QHE+88dQhytzEWBD6U+GNPcSKWsBpOf7+M1Ejh1/2bV6QhmvZngcuxz7Xl3RavBnbLpSGcteXtItZ/aZgJeHYOjdxU61E4oPg6Z5FI615nBvKzW1CZ2UIRqSP1QRexuHtHU548A+DIWjKhPtbmSsOJZ5rzkcSY15Q1kgOXz8jNYpDnUf0DzFmpoDMqUUIrKVGXSDFCTZg8i4kpAFK8E9HnnZiRA34jBwsI9I58m6gb/No0uFziSxVnejD51bAh/rncaEdje6+B7XbDdpe9Rl8+zi355JGtNA3PETFZctmbh/k6pU1MfA 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
|
This patch depends on the patch: https://lore.kernel.org/lkml/20230625154937.64316-1-qi.zheng@linux.dev/
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index e3db8297095a..019981d65e1e 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_unregister(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(-)