diff mbox series

[v2,1/3] xen: page_alloc: Don't open-code IS_ALIGNED()

Message ID 20220715170312.13931-2-julien@xen.org (mailing list archive)
State New, archived
Headers show
Series xen/mm: Optimize init_heap_pages() | expand

Commit Message

Julien Grall July 15, 2022, 5:03 p.m. UTC
From: Julien Grall <jgrall@amazon.com>

init_heap_pages() is using an open-code version of IS_ALIGNED(). Replace
it to improve the readability of the code.

No functional change intended.

Signed-off-by: Julien Grall <jgrall@amazon.com>

---

Changes in v2:
    - Patch added
---
 xen/common/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wei Chen July 18, 2022, 8:06 a.m. UTC | #1
Hi Julien,

On 2022/7/16 1:03, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> init_heap_pages() is using an open-code version of IS_ALIGNED(). Replace
> it to improve the readability of the code.
> 
> No functional change intended.
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>
> 
> ---
> 
> Changes in v2:
>      - Patch added
> ---
>   xen/common/page_alloc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
> index fe0e15429af3..078c2990041d 100644
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -1823,7 +1823,7 @@ static void init_heap_pages(
>               unsigned long s = mfn_x(page_to_mfn(pg + i));
>               unsigned long e = mfn_x(mfn_add(page_to_mfn(pg + nr_pages - 1), 1));
>               bool use_tail = (nid == phys_to_nid(pfn_to_paddr(e - 1))) &&
> -                            !(s & ((1UL << MAX_ORDER) - 1)) &&
> +                            IS_ALIGNED(s, 1UL << MAX_ORDER) &&
>                               (find_first_set_bit(e) <= find_first_set_bit(s));
>               unsigned long n;
>   

LGTM.

Reviewed-by: Wei Chen <Wei.Chen@arm.com>
Jan Beulich July 18, 2022, 8:11 a.m. UTC | #2
On 15.07.2022 19:03, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> init_heap_pages() is using an open-code version of IS_ALIGNED(). Replace
> it to improve the readability of the code.
> 
> No functional change intended.
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
diff mbox series

Patch

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index fe0e15429af3..078c2990041d 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -1823,7 +1823,7 @@  static void init_heap_pages(
             unsigned long s = mfn_x(page_to_mfn(pg + i));
             unsigned long e = mfn_x(mfn_add(page_to_mfn(pg + nr_pages - 1), 1));
             bool use_tail = (nid == phys_to_nid(pfn_to_paddr(e - 1))) &&
-                            !(s & ((1UL << MAX_ORDER) - 1)) &&
+                            IS_ALIGNED(s, 1UL << MAX_ORDER) &&
                             (find_first_set_bit(e) <= find_first_set_bit(s));
             unsigned long n;