x86/mm/64: Rename the register_page_bootmem_memmap() 'size' parameter to 'nr_pages'
PATCH v2 1/1 x86/mm/64: Rename the register_page_bootmem_memmap() 'size' parameter to 'nr_pages'
register_page_bootmem_memmap()'s 3rd 'size' parameter is named in a somewhat misleading fashion - rename it to 'nr_pages' which makes the units of it much clearer.
And also rename the existing local variable 'nr_pages' to 'pages'. Otherwise building error will be reported since these two variables are different type though both represent number of pages. Take 'nr_pages' as register_page_bootmem_memmap()'s parameter name since it has more specific meaning, can make better function interface.
---v1->v2:
Code change in v1 is incomplete, caused build failure. Change it after Ingo pointed it out.
And Ingo helped rewrite the change log of v1. I also add description about the local variable change.
arch/x86/mm/init_64.c | 10 +++++----- include/linux/mm.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/mm/init_64.c +5 -5
@@ -1426,16 +1426,16 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node)#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE ) && defined(CONFIG_HAVE_BOOTMEM_INFO_NODE )void register_page_bootmem_memmap (unsigned long section_nr, -struct page *start_page,unsigned long size) +struct page *start_page,unsigned long nr_pages) {unsigned long addr = (unsigned long )start_page; -unsigned long end = (unsigned long )(start_page + size); +unsigned long end = (unsigned long )(start_page + nr_pages);unsigned long next;pgd_t *pgd;p4d_t *p4d;pud_t *pud;pmd_t *pmd; -unsigned int nr_pages; +unsigned int pages;struct page *page;for (; addr < end; addr = next) {
@@ -1482,9 +1482,9 @@ void register_page_bootmem_memmap(unsigned long section_nr,if (pmd_none (*pmd))continue ; - nr_pages =1 << (get_order (PMD_SIZE )); + pages =1 << (get_order (PMD_SIZE )); page =pmd_page (*pmd); -while (nr_pages--) +while (pages--)get_page_bootmem (section_nr, page++,SECTION_INFO ); }
include/linux/mm.h +1 -1
@@ -2495,7 +2495,7 @@ void vmemmap_populate_print_last(void);void vmemmap_free (unsigned long start,unsigned long end);#endif void register_page_bootmem_memmap (unsigned long section_nr,struct page *map, -unsigned long size); +unsigned long nr_pages);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,
Signature · 1 line
2.5.5
Quoted 54 lines · Baoquan He
register_page_bootmem_memmap()'s 3rd 'size' parameter is named in a somewhat misleading fashion - rename it to '
nr_pages' which makes the units of it much clearer.And also rename the existing local variable '
nr_pages' to 'pages'. Otherwise building error will be reported since these two variables are different type though both represent number of pages. Take 'nr_pages' as register_page_bootmem_memmap()'s parameter name since it has more specific meaning, can make better function interface.Signed-off-by Baoquan He <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Ingo Molnar <[email protected]>---
v1->v2:
Code change in v1 is incomplete, caused build failure. Change it after Ingo pointed it out.And Ingo helped rewrite the change log of v1. I also add description about the local variable change.
arch/x86/mm/init_64.c | 10 +++++----- include/linux/mm.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)arch/x86/mm/init_64.c +3
-3@@ -1426,16 +1426,16 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node)#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE ) && defined(CONFIG_HAVE_BOOTMEM_INFO_NODE )void register_page_bootmem_memmap (unsigned long section_nr, -struct page *start_page,unsigned long size) +struct page *start_page,unsigned long nr_pages) {unsigned long addr = (unsigned long )start_page; -unsigned long end = (unsigned long )(start_page + size); +unsigned long end = (unsigned long )(start_page + nr_pages);unsigned long next;pgd_t *pgd;p4d_t *p4d;pud_t *pud;pmd_t *pmd; -unsigned int nr_pages; +unsigned int pages;struct page *page;for (; addr < end; addr = next) {
arch/x86/mm/init_64.c void register_page_bootmem_memmap(unsigned long section_nr, · line 1485
Quoted 5 lines
arch/x86/mm/init_64.c +1
-1@@ -1482,9 +1482,9 @@ void register_page_bootmem_memmap(unsigned long section_nr,if (pmd_none (*pmd))continue ; - nr_pages =1 << (get_order (PMD_SIZE )); + pages =1 << (get_order (PMD_SIZE ));
Why is the get_order() call in extra parentheses?
Also, the 'pages' name sucks in a similar way 'size' sucks - in this context where we _already_ have a nr_pages variable it should be something more expressive like 'nr_pmd_pages' or so.
Thanks,
Ingo
Quoted 60 lines · Ingo Molnar
Quoted 57 lines · Baoquan He
register_page_bootmem_memmap()'s 3rd 'size' parameter is named in a somewhat misleading fashion - rename it to '
nr_pages' which makes the units of it much clearer.And also rename the existing local variable '
nr_pages' to 'pages'. Otherwise building error will be reported since these two variables are different type though both represent number of pages. Take 'nr_pages' as register_page_bootmem_memmap()'s parameter name since it has more specific meaning, can make better function interface.Signed-off-by Baoquan He <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Ingo Molnar <[email protected]>---
v1->v2:
Code change in v1 is incomplete, caused build failure. Change it after Ingo pointed it out.And Ingo helped rewrite the change log of v1. I also add description about the local variable change.
arch/x86/mm/init_64.c | 10 +++++----- include/linux/mm.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)arch/x86/mm/init_64.c +3
-3@@ -1426,16 +1426,16 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node)#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE ) && defined(CONFIG_HAVE_BOOTMEM_INFO_NODE )void register_page_bootmem_memmap (unsigned long section_nr, -struct page *start_page,unsigned long size) +struct page *start_page,unsigned long nr_pages) {unsigned long addr = (unsigned long )start_page; -unsigned long end = (unsigned long )(start_page + size); +unsigned long end = (unsigned long )(start_page + nr_pages);unsigned long next;pgd_t *pgd;p4d_t *p4d;pud_t *pud;pmd_t *pmd; -unsigned int nr_pages; +unsigned int pages;struct page *page;for (; addr < end; addr = next) {@@ -1482,9 +1482,9 @@ void register_page_bootmem_memmap(unsigned long section_nr,if (pmd_none (*pmd))continue ;
Quoted 4 lines
arch/x86/mm/init_64.c void register_page_bootmem_memmap(unsigned long section_nr, · line 1485
Quoted 2 lines
arch/x86/mm/init_64.c +1
-1- nr_pages =1 << (get_order (PMD_SIZE )); + pages =1 << (get_order (PMD_SIZE ));Why is the
get_order()call in extra parentheses?
Yeah, the extra parentheses makes no sense, will clean it up.
Quoted 4 lines
Also, the 'pages' name sucks in a similar way 'size' sucks - in this context where we _already_ have a
nr_pagesvariable it should be something more expressive like 'nr_pmd_pages' or so.
nr_pmd_pages looks better, will use it instead.
Thanks for reviewing and great suggestion!
Thanks
Baoquan