2022-07-26 13:08:07

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH] mm: use is_zone_movable_page() helper

Use is_zone_movable_page() helper to simplify code.

Signed-off-by: Kefeng Wang <[email protected]>
---
drivers/virtio/virtio_mem.c | 6 ++----
mm/memory_hotplug.c | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
index e07486f01999..0c2892ec6817 100644
--- a/drivers/virtio/virtio_mem.c
+++ b/drivers/virtio/virtio_mem.c
@@ -862,8 +862,7 @@ static void virtio_mem_sbm_notify_online(struct virtio_mem *vm,
unsigned long mb_id,
unsigned long start_pfn)
{
- const bool is_movable = page_zonenum(pfn_to_page(start_pfn)) ==
- ZONE_MOVABLE;
+ const bool is_movable = is_zone_movable_page(pfn_to_page(start_pfn));
int new_state;

switch (virtio_mem_sbm_get_mb_state(vm, mb_id)) {
@@ -1158,8 +1157,7 @@ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages)
*/
static int virtio_mem_fake_offline(unsigned long pfn, unsigned long nr_pages)
{
- const bool is_movable = page_zonenum(pfn_to_page(pfn)) ==
- ZONE_MOVABLE;
+ const bool is_movable = is_zone_movable_page(pfn_to_page(pfn));
int rc, retry_count;

/*
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 1213d0c67a53..0f5914964a32 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -936,7 +936,7 @@ static struct zone *auto_movable_zone_for_pfn(int nid,
if (!page)
continue;
/* If anything is !MOVABLE online the rest !MOVABLE. */
- if (page_zonenum(page) != ZONE_MOVABLE)
+ if (!is_zone_movable_page(page))
goto kernel_zone;
online_pages += PAGES_PER_SECTION;
}
--
2.35.3


2022-07-26 13:08:52

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH] mm: use is_zone_movable_page() helper

On 26.07.22 15:11, Kefeng Wang wrote:
> Use is_zone_movable_page() helper to simplify code.
>
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> drivers/virtio/virtio_mem.c | 6 ++----
> mm/memory_hotplug.c | 2 +-
> 2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
> index e07486f01999..0c2892ec6817 100644
> --- a/drivers/virtio/virtio_mem.c
> +++ b/drivers/virtio/virtio_mem.c
> @@ -862,8 +862,7 @@ static void virtio_mem_sbm_notify_online(struct virtio_mem *vm,
> unsigned long mb_id,
> unsigned long start_pfn)
> {
> - const bool is_movable = page_zonenum(pfn_to_page(start_pfn)) ==
> - ZONE_MOVABLE;
> + const bool is_movable = is_zone_movable_page(pfn_to_page(start_pfn));
> int new_state;
>
> switch (virtio_mem_sbm_get_mb_state(vm, mb_id)) {
> @@ -1158,8 +1157,7 @@ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages)
> */
> static int virtio_mem_fake_offline(unsigned long pfn, unsigned long nr_pages)
> {
> - const bool is_movable = page_zonenum(pfn_to_page(pfn)) ==
> - ZONE_MOVABLE;
> + const bool is_movable = is_zone_movable_page(pfn_to_page(pfn));
> int rc, retry_count;
>
> /*
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 1213d0c67a53..0f5914964a32 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -936,7 +936,7 @@ static struct zone *auto_movable_zone_for_pfn(int nid,
> if (!page)
> continue;
> /* If anything is !MOVABLE online the rest !MOVABLE. */
> - if (page_zonenum(page) != ZONE_MOVABLE)
> + if (!is_zone_movable_page(page))
> goto kernel_zone;
> online_pages += PAGES_PER_SECTION;
> }


Reviewed-by: David Hildenbrand <[email protected]>

--
Thanks,

David / dhildenb

2022-07-27 05:20:05

by Jason Wang

[permalink] [raw]
Subject: Re: [PATCH] mm: use is_zone_movable_page() helper

On Tue, Jul 26, 2022 at 9:05 PM Kefeng Wang <[email protected]> wrote:
>
> Use is_zone_movable_page() helper to simplify code.
>
> Signed-off-by: Kefeng Wang <[email protected]>

Acked-by: Jason Wang <[email protected]>

> ---
> drivers/virtio/virtio_mem.c | 6 ++----
> mm/memory_hotplug.c | 2 +-
> 2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
> index e07486f01999..0c2892ec6817 100644
> --- a/drivers/virtio/virtio_mem.c
> +++ b/drivers/virtio/virtio_mem.c
> @@ -862,8 +862,7 @@ static void virtio_mem_sbm_notify_online(struct virtio_mem *vm,
> unsigned long mb_id,
> unsigned long start_pfn)
> {
> - const bool is_movable = page_zonenum(pfn_to_page(start_pfn)) ==
> - ZONE_MOVABLE;
> + const bool is_movable = is_zone_movable_page(pfn_to_page(start_pfn));
> int new_state;
>
> switch (virtio_mem_sbm_get_mb_state(vm, mb_id)) {
> @@ -1158,8 +1157,7 @@ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages)
> */
> static int virtio_mem_fake_offline(unsigned long pfn, unsigned long nr_pages)
> {
> - const bool is_movable = page_zonenum(pfn_to_page(pfn)) ==
> - ZONE_MOVABLE;
> + const bool is_movable = is_zone_movable_page(pfn_to_page(pfn));
> int rc, retry_count;
>
> /*
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 1213d0c67a53..0f5914964a32 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -936,7 +936,7 @@ static struct zone *auto_movable_zone_for_pfn(int nid,
> if (!page)
> continue;
> /* If anything is !MOVABLE online the rest !MOVABLE. */
> - if (page_zonenum(page) != ZONE_MOVABLE)
> + if (!is_zone_movable_page(page))
> goto kernel_zone;
> online_pages += PAGES_PER_SECTION;
> }
> --
> 2.35.3
>

2022-07-27 05:36:34

by Pankaj Gupta

[permalink] [raw]
Subject: Re: [PATCH] mm: use is_zone_movable_page() helper

> Use is_zone_movable_page() helper to simplify code.
>
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> drivers/virtio/virtio_mem.c | 6 ++----
> mm/memory_hotplug.c | 2 +-
> 2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
> index e07486f01999..0c2892ec6817 100644
> --- a/drivers/virtio/virtio_mem.c
> +++ b/drivers/virtio/virtio_mem.c
> @@ -862,8 +862,7 @@ static void virtio_mem_sbm_notify_online(struct virtio_mem *vm,
> unsigned long mb_id,
> unsigned long start_pfn)
> {
> - const bool is_movable = page_zonenum(pfn_to_page(start_pfn)) ==
> - ZONE_MOVABLE;
> + const bool is_movable = is_zone_movable_page(pfn_to_page(start_pfn));
> int new_state;
>
> switch (virtio_mem_sbm_get_mb_state(vm, mb_id)) {
> @@ -1158,8 +1157,7 @@ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages)
> */
> static int virtio_mem_fake_offline(unsigned long pfn, unsigned long nr_pages)
> {
> - const bool is_movable = page_zonenum(pfn_to_page(pfn)) ==
> - ZONE_MOVABLE;
> + const bool is_movable = is_zone_movable_page(pfn_to_page(pfn));
> int rc, retry_count;
>
> /*
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 1213d0c67a53..0f5914964a32 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -936,7 +936,7 @@ static struct zone *auto_movable_zone_for_pfn(int nid,
> if (!page)
> continue;
> /* If anything is !MOVABLE online the rest !MOVABLE. */
> - if (page_zonenum(page) != ZONE_MOVABLE)
> + if (!is_zone_movable_page(page))
> goto kernel_zone;
> online_pages += PAGES_PER_SECTION;
> }

Reviewed-by: Pankaj Gupta <[email protected]>