Skip to contentSkip to conversation

rangeset: add RANGESETF_no_print flag

PATCH In review Oleksandr Andrushchenko 4 participants 15 messages Nov 22, 2021 – Nov 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 rangeset: add RANGESETF_no_print flag

From: Oleksandr Andrushchenko <[email protected]>

There are range sets which should not be printed, so introduce a flag which allows marking those as such. Implement relevant logic to skip such entries while printing.

---
 xen/common/rangeset.c      | 3 +++
 xen/include/xen/rangeset.h | 3 +++
 2 files changed, 6 insertions(+)
xen/common/rangeset.c +3 -0
index 885b6b15c229..939883a1d145 100644
@@ -575,6 +575,9 @@ void rangeset_domain_printk(
 
     list_for_each_entry ( r, &d->rangesets, rangeset_list )
     {
+        if ( r->flags & RANGESETF_no_print )
+            continue;
+
         printk("    ");
         rangeset_printk(r);
         printk("\n");
xen/include/xen/rangeset.h +3 -0
index 135f33f6066f..543540a88b6f 100644
@@ -51,6 +51,9 @@ void rangeset_limit(
  /* Pretty-print range limits in hexadecimal. */
 #define _RANGESETF_prettyprint_hex 0
 #define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
+/* Do not print entries marked with this flag. */
+#define _RANGESETF_no_print 1
+#define RANGESETF_no_print  (1U << _RANGESETF_no_print)
 
 bool_t __must_check rangeset_is_empty(
     const struct rangeset *r);
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 vpci: use named rangeset for BARs

From: Oleksandr Andrushchenko <[email protected]>

Use a named range set instead of an anonymous one, but do not print it while dumping range sets for a domain.

---
 xen/drivers/vpci/header.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
xen/drivers/vpci/header.c +5 -1
index 40ff79c33f8f..82a3e50d6053 100644
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
 static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
 {
     struct vpci_header *header = &pdev->vpci->header;
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
     struct pci_dev *tmp, *dev = NULL;
     const struct vpci_msix *msix = pdev->vpci->msix;
     unsigned int i;
     int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);
+
     if ( !mem )
         return -ENOMEM;
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/2] vpci: use named rangeset for BARs

Quoted 19 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

Use a named range set instead of an anonymous one, but do not print it while dumping range sets for a domain.

---
 xen/drivers/vpci/header.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
xen/drivers/vpci/header.c +0 -0
index 40ff79c33f8f..82a3e50d6053 100644
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
 static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
 {
     struct vpci_header *header = &pdev->vpci->header;

xen/drivers/vpci/header.c static void defer_map(struct domain *d, struct pci_dev *pdev, · line 217

Quoted 10 lines
xen/drivers/vpci/header.c +4 -1
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
     struct pci_dev *tmp, *dev = NULL;
     const struct vpci_msix *msix = pdev->vpci->msix;
     unsigned int i;
     int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);

You are still not adding the rangeset to the domain list, as the first parameter passed here in NULL instead of a domain struct.

Given the current short living of the rangesets I'm not sure it makes much sense to link them to the domain ATM, but I guess this is kind of a preparatory change as other patches you have will have the rangesets permanent as long as the device is assigned to a domain.

Likely the above reasoning (or the appropriate one) should be added to the commit message.

Thanks, Roger.

#3 lore raw

Re: [PATCH 2/2] vpci: use named rangeset for BARs

Quoted 21 lines · Roger Pau Monné
Quoted 6 lines · Oleksandr Andrushchenko
xen/drivers/vpci/header.c +0 -0
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
 static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
 {
     struct vpci_header *header = &pdev->vpci->header;

xen/drivers/vpci/header.c static void defer_map(struct domain *d, struct pci_dev *pdev, · line 217

Quoted 10 lines
xen/drivers/vpci/header.c +4 -1
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
     struct pci_dev *tmp, *dev = NULL;
     const struct vpci_msix *msix = pdev->vpci->msix;
     unsigned int i;
     int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);

You are still not adding the rangeset to the domain list, as the first parameter passed here in NULL instead of a domain struct.

Quoted 7 lines

Given the current short living of the rangesets I'm not sure it makes much sense to link them to the domain ATM, but I guess this is kind of a preparatory change as other patches you have will have the rangesets permanent as long as the device is assigned to a domain.

Likely the above reasoning (or the appropriate one) should be added to the commit message.

Or, as also suggested as an option, them getting accounted to the domain could be folded into the patch making them long-lived.

Jan

#4 lore raw

Re: [PATCH 2/2] vpci: use named rangeset for BARs

Quoted 21 lines · Jan Beulich
Quoted 20 lines · Roger Pau Monné
Quoted 6 lines · Oleksandr Andrushchenko
xen/drivers/vpci/header.c +0 -0
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
  static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
  {
      struct vpci_header *header = &pdev->vpci->header;

xen/drivers/vpci/header.c static void defer_map(struct domain *d, struct pci_dev *pdev, · line 217

Quoted 10 lines
xen/drivers/vpci/header.c +4 -1
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
      struct pci_dev *tmp, *dev = NULL;
      const struct vpci_msix *msix = pdev->vpci->msix;
      unsigned int i;
      int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);

You are still not adding the rangeset to the domain list, as the first parameter passed here in NULL instead of a domain struct.

Quoted 7 lines
Quoted 7 lines

Given the current short living of the rangesets I'm not sure it makes much sense to link them to the domain ATM, but I guess this is kind of a preparatory change as other patches you have will have the rangesets permanent as long as the device is assigned to a domain.

Likely the above reasoning (or the appropriate one) should be added to the commit message.

If I fold then there is no reason to add the comment, right?

Quoted 2 lines

Or, as also suggested as an option, them getting accounted to the domain could be folded into the patch making them long-lived.

Ok, I can fold this patch and have:
@@ -95,10 +102,27 @@ int vpci_add_handlers(struct pci_dev *pdev)
     INIT_LIST_HEAD(&pdev->vpci->handlers); spin_lock_init(&pdev->vpci->lock);

+    header = &pdev->vpci->header;
+    for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
+    {
+        struct vpci_bar *bar = &header->bars[i];
+        char str[32];
+
+        snprintf(str, sizeof(str), "%pp:BAR%d", &pdev->sbdf, i); +        bar->mem = rangeset_new(pdev->domain, str, RANGESETF_no_print);

Quoted 3 lines

Jan

Thank you,
Oleksandr

#5 lore raw

Re: [PATCH 2/2] vpci: use named rangeset for BARs

Quoted 24 lines · Oleksandr Andrushchenko
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Roger Pau Monné
Quoted 6 lines · Oleksandr Andrushchenko
xen/drivers/vpci/header.c +0 -0
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
  static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
  {
      struct vpci_header *header = &pdev->vpci->header;

xen/drivers/vpci/header.c static void defer_map(struct domain *d, struct pci_dev *pdev, · line 217

Quoted 10 lines
xen/drivers/vpci/header.c +4 -1
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
      struct pci_dev *tmp, *dev = NULL;
      const struct vpci_msix *msix = pdev->vpci->msix;
      unsigned int i;
      int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);

You are still not adding the rangeset to the domain list, as the first parameter passed here in NULL instead of a domain struct.

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

Given the current short living of the rangesets I'm not sure it makes much sense to link them to the domain ATM, but I guess this is kind of a preparatory change as other patches you have will have the rangesets permanent as long as the device is assigned to a domain.

Likely the above reasoning (or the appropriate one) should be added to the commit message.

If I fold then there is no reason to add the comment, right?

I find detailed log messages never hurt, so in the patch where you squash the chunk below I would add that as part of making the rangesets permanent they are also linked to the domain struct in order to properly track them.

Thanks, Roger.

#6 lore raw

Re: [PATCH 2/2] vpci: use named rangeset for BARs

In reply to Oleksandr Andrushchenko
Quoted 24 lines · Oleksandr Andrushchenko
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Roger Pau Monné
Quoted 6 lines · Oleksandr Andrushchenko
xen/drivers/vpci/header.c +0 -0
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
  static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
  {
      struct vpci_header *header = &pdev->vpci->header;

xen/drivers/vpci/header.c static void defer_map(struct domain *d, struct pci_dev *pdev, · line 217

Quoted 10 lines
xen/drivers/vpci/header.c +4 -1
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
      struct pci_dev *tmp, *dev = NULL;
      const struct vpci_msix *msix = pdev->vpci->msix;
      unsigned int i;
      int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);

You are still not adding the rangeset to the domain list, as the first parameter passed here in NULL instead of a domain struct.

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

Given the current short living of the rangesets I'm not sure it makes much sense to link them to the domain ATM, but I guess this is kind of a preparatory change as other patches you have will have the rangesets permanent as long as the device is assigned to a domain.

Likely the above reasoning (or the appropriate one) should be added to the commit message.

If I fold then there is no reason to add the comment, right?

I'd say you still want to justify the change from "anonymous" to "named and accounted".

Jan

#7 lore raw

Re: [PATCH 2/2] vpci: use named rangeset for BARs

Quoted 29 lines · Jan Beulich
Quoted 28 lines · Oleksandr Andrushchenko
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Roger Pau Monné
Quoted 6 lines · Oleksandr Andrushchenko
xen/drivers/vpci/header.c +0 -0
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
   static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
   {
       struct vpci_header *header = &pdev->vpci->header;

xen/drivers/vpci/header.c static void defer_map(struct domain *d, struct pci_dev *pdev, · line 217

Quoted 10 lines
xen/drivers/vpci/header.c +4 -1
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
       struct pci_dev *tmp, *dev = NULL;
       const struct vpci_msix *msix = pdev->vpci->msix;
       unsigned int i;
       int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);

You are still not adding the rangeset to the domain list, as the first parameter passed here in NULL instead of a domain struct.

Given the current short living of the rangesets I'm not sure it makes much sense to link them to the domain ATM, but I guess this is kind of a preparatory change as other patches you have will have the rangesets permanent as long as the device is assigned to a domain.

Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Likely the above reasoning (or the appropriate one) should be added to the commit message.

If I fold then there is no reason to add the comment, right?

I'd say you still want to justify the change from "anonymous" to "named and accounted".

"Make the range sets permanent, e.g. create them when a PCI device is added and destroy when it is removed. Also make the range sets named and accounted."

Will this work in the commit message?

Quoted 4 lines

Jan

Thank you,
Oleksandr

#8 lore raw

Re: [PATCH 2/2] vpci: use named rangeset for BARs

Quoted 30 lines · Oleksandr Andrushchenko
Quoted 29 lines · Jan Beulich
Quoted 28 lines · Oleksandr Andrushchenko
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Roger Pau Monné
Quoted 6 lines · Oleksandr Andrushchenko
xen/drivers/vpci/header.c +0 -0
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
   static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
   {
       struct vpci_header *header = &pdev->vpci->header;

xen/drivers/vpci/header.c static void defer_map(struct domain *d, struct pci_dev *pdev, · line 217

Quoted 10 lines
xen/drivers/vpci/header.c +4 -1
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
       struct pci_dev *tmp, *dev = NULL;
       const struct vpci_msix *msix = pdev->vpci->msix;
       unsigned int i;
       int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);

You are still not adding the rangeset to the domain list, as the first parameter passed here in NULL instead of a domain struct.

Given the current short living of the rangesets I'm not sure it makes much sense to link them to the domain ATM, but I guess this is kind of a preparatory change as other patches you have will have the rangesets permanent as long as the device is assigned to a domain.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Likely the above reasoning (or the appropriate one) should be added to the commit message.

If I fold then there is no reason to add the comment, right?

I'd say you still want to justify the change from "anonymous" to "named and accounted".

"Make the range sets permanent, e.g. create them when a PCI device is added and destroy when it is removed. Also make the range sets named and accounted."

Making them permanent is a requirement of your change iirc, so I'd start with "Because the range sets now become permanent, make them ...".

Jan

#9 lore raw

Re: [PATCH 2/2] vpci: use named rangeset for BARs

Quoted 32 lines · Jan Beulich
Quoted 31 lines · Oleksandr Andrushchenko
Quoted 30 lines · Jan Beulich
Quoted 29 lines · Oleksandr Andrushchenko
Quoted 28 lines · Jan Beulich
Quoted 27 lines · Roger Pau Monné
Quoted 6 lines · Oleksandr Andrushchenko
xen/drivers/vpci/header.c +0 -0
@@ -206,12 +206,16 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
    static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
    {
        struct vpci_header *header = &pdev->vpci->header;

xen/drivers/vpci/header.c static void defer_map(struct domain *d, struct pci_dev *pdev, · line 217

Quoted 10 lines
xen/drivers/vpci/header.c +4 -1
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
+    struct rangeset *mem;
+    char str[32];
        struct pci_dev *tmp, *dev = NULL;
        const struct vpci_msix *msix = pdev->vpci->msix;
        unsigned int i;
        int rc;
 
+    snprintf(str, sizeof(str), "%pp", &pdev->sbdf);
+    mem = rangeset_new(NULL, str, RANGESETF_no_print);

You are still not adding the rangeset to the domain list, as the first parameter passed here in NULL instead of a domain struct.

Given the current short living of the rangesets I'm not sure it makes much sense to link them to the domain ATM, but I guess this is kind of a preparatory change as other patches you have will have the rangesets permanent as long as the device is assigned to a domain.

Likely the above reasoning (or the appropriate one) should be added to the commit message.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

If I fold then there is no reason to add the comment, right?

I'd say you still want to justify the change from "anonymous" to "named and accounted".

"Make the range sets permanent, e.g. create them when a PCI device is added and destroy when it is removed. Also make the range sets named and accounted."

Making them permanent is a requirement of your change iirc, so I'd start with "Because the range sets now become permanent, make them ...".

"As the range sets are now created when a PCI device is added and destroyed when it is removed so make them named and accounted."

Quoted 4 lines

Jan

Thank you,
Oleksandr

#10 lore raw
In reply to Oleksandr Andrushchenko
Quoted 32 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

There are range sets which should not be printed, so introduce a flag which allows marking those as such. Implement relevant logic to skip such entries while printing.

---
  xen/common/rangeset.c      | 3 +++
  xen/include/xen/rangeset.h | 3 +++
  2 files changed, 6 insertions(+)
xen/common/rangeset.c +3 -0
index 885b6b15c229..939883a1d145 100644
@@ -575,6 +575,9 @@ void rangeset_domain_printk(
 
      list_for_each_entry ( r, &d->rangesets, rangeset_list )
      {
+        if ( r->flags & RANGESETF_no_print )
+            continue;
+
          printk("    ");
          rangeset_printk(r);
          printk("\n");
xen/include/xen/rangeset.h +0 -0
index 135f33f6066f..543540a88b6f 100644

xen/include/xen/rangeset.h void rangeset_limit( · line 59

Quoted 9 lines
xen/include/xen/rangeset.h +3 -0
@@ -51,6 +51,9 @@ void rangeset_limit(
   /* Pretty-print range limits in hexadecimal. */
  #define _RANGESETF_prettyprint_hex 0
  #define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
+/* Do not print entries marked with this flag. */
+#define _RANGESETF_no_print 1
+#define RANGESETF_no_print  (1U << _RANGESETF_no_print)
 
  bool_t __must_check rangeset_is_empty(
      const struct rangeset *r);

This will also require:

xen/common/rangeset.c +1 -1
index 939883a1d145..ea27d651723b 100644
@@ -433,7 +433,7 @@ struct rangeset *rangeset_new(
      INIT_LIST_HEAD(&r->range_list);
      r->nr_ranges = -1;
 
-    BUG_ON(flags & ~RANGESETF_prettyprint_hex);
+    BUG_ON(flags & ~(RANGESETF_prettyprint_hex | RANGESETF_no_print));
      r->flags = flags;
 

Or we just remove BUG_ON now

Thank you,
Oleksandr

#11 lore raw
In reply to Oleksandr Andrushchenko

xen/include/xen/rangeset.h void rangeset_limit( · line 55

Quoted 8 lines · Oleksandr Andrushchenko
xen/include/xen/rangeset.h +2 -0
@@ -51,6 +51,9 @@ void rangeset_limit(
  /* Pretty-print range limits in hexadecimal. */
 #define _RANGESETF_prettyprint_hex 0
 #define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
+/* Do not print entries marked with this flag. */
+#define _RANGESETF_no_print 1

There's no need for this, so I'd like to ask that you add ...

xen/include/xen/rangeset.h void rangeset_limit( · line 56

Quoted 1 line
xen/include/xen/rangeset.h +1 -0
+#define RANGESETF_no_print  (1U << _RANGESETF_no_print)

... just this. In due course we should do away with _RANGESETF_prettyprint_hex as well (unless you want to do so right at this occasion).

Jan

#12 lore raw
Quoted 11 lines · Jan Beulich

xen/include/xen/rangeset.h void rangeset_limit( · line 55

Quoted 8 lines · Oleksandr Andrushchenko
xen/include/xen/rangeset.h +2 -0
@@ -51,6 +51,9 @@ void rangeset_limit(
   /* Pretty-print range limits in hexadecimal. */
  #define _RANGESETF_prettyprint_hex 0
  #define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
+/* Do not print entries marked with this flag. */
+#define _RANGESETF_no_print 1

There's no need for this, so I'd like to ask that you add ...

Quoted 4 lines

xen/include/xen/rangeset.h void rangeset_limit( · line 56

Quoted 1 line
xen/include/xen/rangeset.h +1 -0
+#define RANGESETF_no_print  (1U << _RANGESETF_no_print)

... just this. In due course we should do away with _RANGESETF_prettyprint_hex as well (unless you want to do so right at this occasion).

Ok, I can remove "#define _RANGESETF_prettyprint_hex 0" as well and have both flags defined as
 /* Pretty-print range limits in hexadecimal. */
#define RANGESETF_prettyprint_hex  (1U << 0)
/* Do not print entries marked with this flag. */ #define RANGESETF_no_print         (1U << 1)

Or we can use BIT macro here:

/* Pretty-print range limits in hexadecimal. */
#define RANGESETF_prettyprint_hex  BIT(0, U)
/* Do not print entries marked with this flag. */
#define RANGESETF_no_print         BIT(1, U)

What's your preference here?

Quoted 3 lines

Jan

Thank you,
Oleksandr

#13 lore raw
Quoted 25 lines · Oleksandr Andrushchenko
Quoted 11 lines · Jan Beulich

xen/include/xen/rangeset.h void rangeset_limit( · line 55

Quoted 8 lines · Oleksandr Andrushchenko
xen/include/xen/rangeset.h +2 -0
@@ -51,6 +51,9 @@ void rangeset_limit(
   /* Pretty-print range limits in hexadecimal. */
  #define _RANGESETF_prettyprint_hex 0
  #define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
+/* Do not print entries marked with this flag. */
+#define _RANGESETF_no_print 1

There's no need for this, so I'd like to ask that you add ...

Quoted 4 lines

xen/include/xen/rangeset.h void rangeset_limit( · line 56

Quoted 1 line
xen/include/xen/rangeset.h +1 -0
+#define RANGESETF_no_print  (1U << _RANGESETF_no_print)

... just this. In due course we should do away with _RANGESETF_prettyprint_hex as well (unless you want to do so right at this occasion).

Ok, I can remove "#define _RANGESETF_prettyprint_hex 0" as well and have both flags defined as
 /* Pretty-print range limits in hexadecimal. */
#define RANGESETF_prettyprint_hex  (1U << 0)
/* Do not print entries marked with this flag. */ #define RANGESETF_no_print         (1U << 1)

Quoted 8 lines

Or we can use BIT macro here:

/* Pretty-print range limits in hexadecimal. */
#define RANGESETF_prettyprint_hex  BIT(0, U)
/* Do not print entries marked with this flag. */
#define RANGESETF_no_print         BIT(1, U)

What's your preference here?

Clearly the former. But this may not be everybody's view. I'm hesitant towards further uses at least as long as its generalization, GENMASK(), isn't ready for easy use. It was some time ago that we had a discussion about that one, supporting my reservations voiced back at the time when it was introduced into our code base. Iirc there was more than one issue with it; the immediately obvious one is that it silently does the wrong thing when the arguments get specified the wrong way round, when it really would be relatively easy to support either ordering.

Jan

#14 lore raw
Quoted 27 lines · Jan Beulich
Quoted 26 lines · Oleksandr Andrushchenko
Quoted 11 lines · Jan Beulich

xen/include/xen/rangeset.h void rangeset_limit( · line 55

Quoted 8 lines · Oleksandr Andrushchenko
xen/include/xen/rangeset.h +2 -0
@@ -51,6 +51,9 @@ void rangeset_limit(
    /* Pretty-print range limits in hexadecimal. */
   #define _RANGESETF_prettyprint_hex 0
   #define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
+/* Do not print entries marked with this flag. */
+#define _RANGESETF_no_print 1

There's no need for this, so I'd like to ask that you add ...

Quoted 4 lines

xen/include/xen/rangeset.h void rangeset_limit( · line 56

Quoted 1 line
xen/include/xen/rangeset.h +1 -0
+#define RANGESETF_no_print  (1U << _RANGESETF_no_print)

... just this. In due course we should do away with _RANGESETF_prettyprint_hex as well (unless you want to do so right at this occasion).

Ok, I can remove "#define _RANGESETF_prettyprint_hex 0" as well and have both flags defined as
 /* Pretty-print range limits in hexadecimal. */
#define RANGESETF_prettyprint_hex  (1U << 0)
/* Do not print entries marked with this flag. */ #define RANGESETF_no_print         (1U << 1)

Or we can use BIT macro here:

Quoted 7 lines
Quoted 6 lines

/* Pretty-print range limits in hexadecimal. */
#define RANGESETF_prettyprint_hex  BIT(0, U)
/* Do not print entries marked with this flag. */
#define RANGESETF_no_print         BIT(1, U)

What's your preference here?

Clearly the former.

I am fine with this too, so I'll use it

Quoted 11 lines

But this may not be everybody's view. I'm hesitant
towards further uses at least as long as its generalization, GENMASK(), isn't ready for easy use. It was some time ago that we had a discussion about that one, supporting my reservations voiced back at the time when it was introduced into our code base. Iirc there was more than one issue with it; the immediately obvious one is that it silently does the wrong thing when the arguments get specified the wrong way round, when it really would be relatively easy to support either ordering.

Jan

Thank you,
Oleksandr