Re: [PATCH] mm/page_alloc: simplify page_is_buddy() for better code readability

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

 



>
> From: chenqiwu <chenqiwu@xxxxxxxxxx>
>
> Simplify page_is_buddy() to reduce the redundant code for better
> code readability.
>
> Signed-off-by: chenqiwu <chenqiwu@xxxxxxxxxx>
> ---
>  mm/page_alloc.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 79e950d..c6eef38 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -797,16 +797,8 @@ static inline void set_page_order(struct page *page, unsigned int order)
>  static inline int page_is_buddy(struct page *page, struct page *buddy,
>                                                         unsigned int order)
>  {
> -       if (page_is_guard(buddy) && page_order(buddy) == order) {
> -               if (page_zone_id(page) != page_zone_id(buddy))
> -                       return 0;
> -
> -               VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy);
> -
> -               return 1;
> -       }
> -
> -       if (PageBuddy(buddy) && page_order(buddy) == order) {
> +       if ((page_is_guard(buddy) || PageBuddy(buddy))
> +            && page_order(buddy) == order) {
>                 /*
>                  * zone check is done late to avoid uselessly
>                  * calculating zone/node ids for pages that could
> @@ -819,6 +811,7 @@ static inline int page_is_buddy(struct page *page, struct page *buddy,
>
>                 return 1;
>         }
> +
>         return 0;
>  }

Looks good to me.
Acked-by: Pankaj Gupta <pankaj.gupta.linux@xxxxxxxxx>

>
> --
> 1.9.1
>
>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux