diff mbox series

[06/15] rangeset: Move struct range and struct rangeset to headerfile

Message ID 20240424033449.168398-7-xin.wang2@amd.com (mailing list archive)
State Superseded
Headers show
Series Remaining patches for dynamic node programming using overlay dtbo | expand

Commit Message

Henry Wang April 24, 2024, 3:34 a.m. UTC
From: Vikram Garhwal <vikram.garhwal@amd.com>

Move struct range, rangeset and removed static from first_range and next_range().
IRQs and IOMEMs for nodes are stored as rangeset in the dynamic node addition
part. While removing the nodes we need to access every IRQ and IOMEM ranges to
unmap IRQ and IOMEM from the domain.

Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
Signed-off-by: Henry Wang <xin.wang2@amd.com>
---
 xen/common/rangeset.c      | 31 ++-----------------------------
 xen/include/xen/rangeset.h | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 30 deletions(-)

Comments

Jan Beulich April 24, 2024, 6:22 a.m. UTC | #1
On 24.04.2024 05:34, Henry Wang wrote:
> From: Vikram Garhwal <vikram.garhwal@amd.com>
> 
> Move struct range, rangeset and removed static from first_range and next_range().

NAK, for going against what we do elsewhere (limiting exposure of internals).
At least as long as the justification isn't any better than ...

> IRQs and IOMEMs for nodes are stored as rangeset in the dynamic node addition
> part. While removing the nodes we need to access every IRQ and IOMEM ranges to
> unmap IRQ and IOMEM from the domain.

... this. You're aware of rangeset_report_ranges() and rangeset_consume_ranges(),
aren't you? If neither is suitable for your purpose, can you explain what you
need in addition?

Jan
Henry Wang April 25, 2024, 12:47 a.m. UTC | #2
Hi Jan,

On 4/24/2024 2:22 PM, Jan Beulich wrote:
> On 24.04.2024 05:34, Henry Wang wrote:
>> From: Vikram Garhwal <vikram.garhwal@amd.com>
>>
>> Move struct range, rangeset and removed static from first_range and next_range().
> NAK, for going against what we do elsewhere (limiting exposure of internals).
> At least as long as the justification isn't any better than ...
>
>> IRQs and IOMEMs for nodes are stored as rangeset in the dynamic node addition
>> part. While removing the nodes we need to access every IRQ and IOMEM ranges to
>> unmap IRQ and IOMEM from the domain.
> ... this. You're aware of rangeset_report_ranges() and rangeset_consume_ranges(),
> aren't you? If neither is suitable for your purpose, can you explain what you
> need in addition?

I understand your concern. I will check if I can refactor this patch 
using the suggested helpers. Thanks!

Kind regards,
Henry


>
> Jan
diff mbox series

Patch

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index b75590f907..d3f4297e41 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -12,31 +12,6 @@ 
 #include <xen/rangeset.h>
 #include <xsm/xsm.h>
 
-/* An inclusive range [s,e] and pointer to next range in ascending order. */
-struct range {
-    struct list_head list;
-    unsigned long s, e;
-};
-
-struct rangeset {
-    /* Owning domain and threaded list of rangesets. */
-    struct list_head rangeset_list;
-    struct domain   *domain;
-
-    /* Ordered list of ranges contained in this set, and protecting lock. */
-    struct list_head range_list;
-
-    /* Number of ranges that can be allocated */
-    long             nr_ranges;
-    rwlock_t         lock;
-
-    /* Pretty-printing name. */
-    char             name[32];
-
-    /* RANGESETF flags. */
-    unsigned int     flags;
-};
-
 /*****************************
  * Private range functions hide the underlying linked-list implemnetation.
  */
@@ -57,8 +32,7 @@  static struct range *find_range(
     return x;
 }
 
-/* Return the lowest range in the set r, or NULL if r is empty. */
-static struct range *first_range(
+struct range *first_range(
     struct rangeset *r)
 {
     if ( list_empty(&r->range_list) )
@@ -66,8 +40,7 @@  static struct range *first_range(
     return list_entry(r->range_list.next, struct range, list);
 }
 
-/* Return range following x in ascending order, or NULL if x is the highest. */
-static struct range *next_range(
+struct range *next_range(
     struct rangeset *r, struct range *x)
 {
     if ( x->list.next == &r->range_list )
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index 96c9180825..cd80fd9179 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -13,7 +13,37 @@ 
 #include <xen/types.h>
 
 struct domain;
-struct rangeset;
+
+struct rangeset {
+    /* Owning domain and threaded list of rangesets. */
+    struct list_head rangeset_list;
+    struct domain   *domain;
+
+    /* Ordered list of ranges contained in this set, and protecting lock. */
+    struct list_head range_list;
+
+    /* Number of ranges that can be allocated */
+    long             nr_ranges;
+    rwlock_t         lock;
+
+    /* Pretty-printing name. */
+    char             name[32];
+
+    /* RANGESETF flags. */
+    unsigned int     flags;
+};
+
+/* An inclusive range [s,e] and pointer to next range in ascending order. */
+struct range {
+    struct list_head list;
+    unsigned long s, e;
+};
+
+/* Return the lowest range in the set r, or NULL if r is empty. */
+struct range *first_range(struct rangeset *r);
+
+/* Return range following x in ascending order, or NULL if x is the highest. */
+struct range *next_range(struct rangeset *r, struct range *x);
 
 /*
  * Initialise/destroy per-domain rangeset information.