From nobody Wed Nov 27 21:41:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1690445268; cv=none; d=zohomail.com; s=zohoarc; b=ETlra32JQe1RWOISmHkWdBjfFilFbUWLlxkT/sCcpHBPd/oVYnCFyAOTXQ50ryr0L5enBySH2AKs2Kjd0yVFrHO3YHdb2bBnKekkhduPNfotDK82ahftUb93/IAMpqdlUuPXzJnHKXAmE2c3pSEUhS5ACTeOvV2X24wDLU/WB/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690445268; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YQ2nJ797AaeiRC4tEbuFSwr/qroaEGD64TBkJX9gwcc=; b=YjI0P8RRIpvtzmxGkvBPr7PgT3BwYAHZKBt9bCQEcYHDzQ7WCJrjZyGvGCt/vgceW3tz6fTlL0jdXDEla1rIx4Dun45qf58THE1DVEEe5qrBRkSwpPiM1SYGRVvJySiykvLEpb8ePq0hPIe+AqUc8Et2Br6Kh+McNAOEywtoyqg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1690445268194461.82119632972956; Thu, 27 Jul 2023 01:07:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.570845.893128 (Exim 4.92) (envelope-from ) id 1qOw1k-0003uM-Rx; Thu, 27 Jul 2023 08:07:16 +0000 Received: by outflank-mailman (output) from mailman id 570845.893128; Thu, 27 Jul 2023 08:07:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw1k-0003uA-OR; Thu, 27 Jul 2023 08:07:16 +0000 Received: by outflank-mailman (input) for mailman id 570845; Thu, 27 Jul 2023 08:07:15 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qOw1j-0001DS-U7 for xen-devel@lists.xenproject.org; Thu, 27 Jul 2023 08:07:15 +0000 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [2607:f8b0:4864:20::433]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 98a60b38-2c54-11ee-b247-6b7b168915f2; Thu, 27 Jul 2023 10:07:15 +0200 (CEST) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6748a616e17so182492b3a.1 for ; Thu, 27 Jul 2023 01:07:15 -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) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 98a60b38-2c54-11ee-b247-6b7b168915f2 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=X95cG6rPCP0rstvpjT0/lw88JgM0VDu1zU0JCXR+GtTfYb2O++85M9QC0Pgz/17vyx F6Bs1d33mETYjGbd+mqUGoy0v98+mxcwK1NunT2naYtdNlAwSMXa4u22OLRjWgTYKsVr yApVFGdlx59fPZf6hC8uNzqrT9Q/Yo4GR6cfe3a5ZxqZoN4rwzMvVYq649bbeNd72rTl xDKC1/RAxht3OKxBz291kp/pkP93T59lXpju5OaidV/E0Vo6ROULugi+VN0erQhTuOBs aYFiBLdMAJ6XgglBGxDkrnaSZdkZU4+S25UF/pnGbp8IqqEH6FWNqk2eIE/tqRyZ8bOh QSoA== X-Gm-Message-State: ABy/qLaUIvyGEks/kLRvpa+trkCGO+ajiDQEKqyXBqHxQgpIEGKEp57z Qk5H4mXilpjFHnDKhCuYycEfGw== 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) From: Qi Zheng 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 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: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1690445270089100003 Content-Type: text/plain; charset="utf-8" Use new APIs to dynamically allocate the android-binder shrinker. Signed-off-by: Qi Zheng --- drivers/android/binder_alloc.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) 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 s= hrink_control *sc) NULL, sc->nr_to_scan); } =20 -static struct shrinker binder_shrinker =3D { - .count_objects =3D binder_shrink_count, - .scan_objects =3D binder_shrink_scan, - .seeks =3D DEFAULT_SEEKS, -}; +static struct shrinker *binder_shrinker; =20 /** * binder_alloc_init() - called by binder_open() for per-proc initializati= on @@ -1077,19 +1073,30 @@ void binder_alloc_init(struct binder_alloc *alloc) =20 int binder_alloc_shrinker_init(void) { - int ret =3D list_lru_init(&binder_alloc_lru); + int ret; =20 - if (ret =3D=3D 0) { - ret =3D register_shrinker(&binder_shrinker, "android-binder"); - if (ret) - list_lru_destroy(&binder_alloc_lru); + ret =3D list_lru_init(&binder_alloc_lru); + if (ret) + return ret; + + binder_shrinker =3D shrinker_alloc(0, "android-binder"); + if (!binder_shrinker) { + list_lru_destroy(&binder_alloc_lru); + return -ENOMEM; } - return ret; + + binder_shrinker->count_objects =3D binder_shrink_count; + binder_shrinker->scan_objects =3D binder_shrink_scan; + binder_shrinker->seeks =3D DEFAULT_SEEKS; + + shrinker_register(binder_shrinker); + + return 0; } =20 void binder_alloc_shrinker_exit(void) { - unregister_shrinker(&binder_shrinker); + shrinker_free(binder_shrinker); list_lru_destroy(&binder_alloc_lru); } =20 --=20 2.30.2