2013-09-06 08:55:30

by Xishi Qiu

[permalink] [raw]
Subject: [PATCH] mm/hotplug: rename the function is_memblock_offlined_cb()

Function is_memblock_offlined() return 1 means memory block is offlined,
but is_memblock_offlined_cb() return 1 means memory block is not offlined,
this will confuse somebody, so rename the function.
Another, use "pfn_to_nid(pfn)" instead of "page_to_nid(pfn_to_page(pfn))".

Signed-off-by: Xishi Qiu <[email protected]>
---
mm/memory_hotplug.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index ca1dd3a..a95dd28 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -937,7 +937,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
arg.nr_pages = nr_pages;
node_states_check_changes_online(nr_pages, zone, &arg);

- nid = page_to_nid(pfn_to_page(pfn));
+ nid = pfn_to_nid(pfn);

ret = memory_notify(MEM_GOING_ONLINE, &arg);
ret = notifier_to_errno(ret);
@@ -1657,7 +1657,7 @@ int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn,
}

#ifdef CONFIG_MEMORY_HOTREMOVE
-static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)
+static int check_memblock_offlined_cb(struct memory_block *mem, void *arg)
{
int ret = !is_memblock_offlined(mem);

@@ -1794,7 +1794,7 @@ void __ref remove_memory(int nid, u64 start, u64 size)
* if this is not the case.
*/
ret = walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), NULL,
- is_memblock_offlined_cb);
+ check_memblock_offlined_cb);
if (ret) {
unlock_memory_hotplug();
BUG();
--
1.7.1


2013-09-09 00:53:09

by Yasuaki Ishimatsu

[permalink] [raw]
Subject: Re: [PATCH] mm/hotplug: rename the function is_memblock_offlined_cb()

(2013/09/06 17:54), Xishi Qiu wrote:
> Function is_memblock_offlined() return 1 means memory block is offlined,
> but is_memblock_offlined_cb() return 1 means memory block is not offlined,
> this will confuse somebody, so rename the function.
> Another, use "pfn_to_nid(pfn)" instead of "page_to_nid(pfn_to_page(pfn))".
>
> Signed-off-by: Xishi Qiu <[email protected]>
> ---

It looks good to me. But I have one comment.
Please see below.

> mm/memory_hotplug.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index ca1dd3a..a95dd28 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -937,7 +937,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
> arg.nr_pages = nr_pages;
> node_states_check_changes_online(nr_pages, zone, &arg);
>

> - nid = page_to_nid(pfn_to_page(pfn));
> + nid = pfn_to_nid(pfn);

Please split the cleanup from this patch since the cleanup has
nothing to do with the description of this patch.

Thanks,
Yasuaki Ishimatsu

>
> ret = memory_notify(MEM_GOING_ONLINE, &arg);
> ret = notifier_to_errno(ret);
> @@ -1657,7 +1657,7 @@ int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn,
> }
>
> #ifdef CONFIG_MEMORY_HOTREMOVE
> -static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)
> +static int check_memblock_offlined_cb(struct memory_block *mem, void *arg)
> {
> int ret = !is_memblock_offlined(mem);
>
> @@ -1794,7 +1794,7 @@ void __ref remove_memory(int nid, u64 start, u64 size)
> * if this is not the case.
> */
> ret = walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), NULL,
> - is_memblock_offlined_cb);
> + check_memblock_offlined_cb);
> if (ret) {
> unlock_memory_hotplug();
> BUG();
>