diff mbox series

[1/2] rangeset: add RANGESETF_no_print flag

Message ID 20211122092825.2502306-1-andr2000@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] rangeset: add RANGESETF_no_print flag | expand

Commit Message

Oleksandr Andrushchenko Nov. 22, 2021, 9:28 a.m. UTC
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

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.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
---
 xen/common/rangeset.c      | 3 +++
 xen/include/xen/rangeset.h | 3 +++
 2 files changed, 6 insertions(+)

Comments

Oleksandr Andrushchenko Nov. 22, 2021, 11:27 a.m. UTC | #1
On 22.11.21 11:28, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
> 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.
>
> Suggested-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> ---
>   xen/common/rangeset.c      | 3 +++
>   xen/include/xen/rangeset.h | 3 +++
>   2 files changed, 6 insertions(+)
>
> diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
> index 885b6b15c229..939883a1d145 100644
> --- a/xen/common/rangeset.c
> +++ b/xen/common/rangeset.c
> @@ -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");
> diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
> index 135f33f6066f..543540a88b6f 100644
> --- a/xen/include/xen/rangeset.h
> +++ b/xen/include/xen/rangeset.h
> @@ -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:
diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 939883a1d145..ea27d651723b 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -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
Jan Beulich Nov. 23, 2021, 7:38 a.m. UTC | #2
On 22.11.2021 10:28, Oleksandr Andrushchenko wrote:
> --- a/xen/include/xen/rangeset.h
> +++ b/xen/include/xen/rangeset.h
> @@ -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 ...

> +#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
Oleksandr Andrushchenko Nov. 23, 2021, 7:49 a.m. UTC | #3
On 23.11.21 09:38, Jan Beulich wrote:
> On 22.11.2021 10:28, Oleksandr Andrushchenko wrote:
>> --- a/xen/include/xen/rangeset.h
>> +++ b/xen/include/xen/rangeset.h
>> @@ -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 ...
>
>> +#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?
>
> Jan
>
Thank you,
Oleksandr
Jan Beulich Nov. 23, 2021, 8:01 a.m. UTC | #4
On 23.11.2021 08:49, Oleksandr Andrushchenko wrote:
> 
> 
> On 23.11.21 09:38, Jan Beulich wrote:
>> On 22.11.2021 10:28, Oleksandr Andrushchenko wrote:
>>> --- a/xen/include/xen/rangeset.h
>>> +++ b/xen/include/xen/rangeset.h
>>> @@ -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 ...
>>
>>> +#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?

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
Oleksandr Andrushchenko Nov. 23, 2021, 8:04 a.m. UTC | #5
On 23.11.21 10:01, Jan Beulich wrote:
> On 23.11.2021 08:49, Oleksandr Andrushchenko wrote:
>>
>> On 23.11.21 09:38, Jan Beulich wrote:
>>> On 22.11.2021 10:28, Oleksandr Andrushchenko wrote:
>>>> --- a/xen/include/xen/rangeset.h
>>>> +++ b/xen/include/xen/rangeset.h
>>>> @@ -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 ...
>>>
>>>> +#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?
> Clearly the former.
I am fine with this too, so I'll use it
>   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
diff mbox series

Patch

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 885b6b15c229..939883a1d145 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -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");
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index 135f33f6066f..543540a88b6f 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -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);