From nobody Sat May 18 05:04:49 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; 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=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644591703097748.667553163625; Fri, 11 Feb 2022 07:01:43 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.270531.464845 (Exim 4.92) (envelope-from ) id 1nIXPs-00077E-Uw; Fri, 11 Feb 2022 15:00:56 +0000 Received: by outflank-mailman (output) from mailman id 270531.464845; Fri, 11 Feb 2022 15:00:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nIXPs-000777-Rf; Fri, 11 Feb 2022 15:00:56 +0000 Received: by outflank-mailman (input) for mailman id 270531; Fri, 11 Feb 2022 15:00:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nIXPs-000771-Dg for xen-devel@lists.xenproject.org; Fri, 11 Feb 2022 15:00:56 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 68c05bdd-8b4b-11ec-8f75-fffcc8bd4f1a; Fri, 11 Feb 2022 16:00:54 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 604D4106F; Fri, 11 Feb 2022 07:00:53 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.195.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 82EC93F718; Fri, 11 Feb 2022 07:00:52 -0800 (PST) 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: 68c05bdd-8b4b-11ec-8f75-fffcc8bd4f1a From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis Subject: [RFC PATCH] arm/vgic-v3: provide custom callbacks for pend_lpi_tree radix tree Date: Fri, 11 Feb 2022 15:00:42 +0000 Message-Id: <20220211150042.11972-1-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 X-ZM-MESSAGEID: 1644591714603100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" pend_lpi_tree is a radix tree used to store pending irqs, the tree is protected by a lock for read/write operations. Currently the radix tree default function to free items uses the RCU mechanism, calling call_rcu and deferring the operation. However every access to the structure is protected by the lock so we can avoid using the default free function that, by using RCU, increases memory usage and impacts the predictability of the system. This commit provides custom callbacks to alloc/free items of the radix tree and the free function doesn't use the RCU mechanism. Signed-off-by: Luca Fancellu --- xen/arch/arm/vgic-v3.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 65bb7991a69b..970747a72012 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1650,6 +1650,18 @@ static inline unsigned int vgic_v3_max_rdist_count(s= truct domain *d) GUEST_GICV3_RDIST_REGIONS; } =20 +static struct radix_tree_node *vgic_v3_radix_tree_node_alloc(void *arg) +{ + struct radix_tree_node *node =3D xmalloc(struct radix_tree_node); + + return node ? node : NULL; +} + +static void vgic_v3_radix_tree_node_free(struct radix_tree_node *elem, voi= d *arg) +{ + xfree(elem); +} + static int vgic_v3_domain_init(struct domain *d) { struct vgic_rdist_region *rdist_regions; @@ -1668,6 +1680,14 @@ static int vgic_v3_domain_init(struct domain *d) rwlock_init(&d->arch.vgic.pend_lpi_tree_lock); radix_tree_init(&d->arch.vgic.pend_lpi_tree); =20 + /* + * pend_lpi_tree is protected by rwlock, so don't use lockless RCU def= ault + * management for it and provide callbacks to alloc/free elements. + */ + radix_tree_set_alloc_callbacks(&d->arch.vgic.pend_lpi_tree, + vgic_v3_radix_tree_node_alloc, + vgic_v3_radix_tree_node_free, NULL); + /* * Domain 0 gets the hardware address. * Guests get the virtual platform layout. --=20 2.17.1