[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH] arm/vgic-v3: provide custom callbacks for pend_lpi_tree radix tree



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 <luca.fancellu@xxxxxxx>
---
 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(struct domain *d)
                GUEST_GICV3_RDIST_REGIONS;
 }
 
+static struct radix_tree_node *vgic_v3_radix_tree_node_alloc(void *arg)
+{
+    struct radix_tree_node *node = xmalloc(struct radix_tree_node);
+
+    return node ? node : NULL;
+}
+
+static void vgic_v3_radix_tree_node_free(struct radix_tree_node *elem, void 
*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);
 
+    /*
+     * pend_lpi_tree is protected by rwlock, so don't use lockless RCU default
+     * 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.
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.