powerpc/mm: move warning from resize_hpt_for_hotplug()
PATCH v2 1/1 powerpc/mm: move warning from resize_hpt_for_hotplug()
resize_hpt_for_hotplug() reports a warning when it cannot resize the hash page table ("Unable to resize hash page table to target order") but in some cases it's not a problem and can make user thinks something has not worked properly.
This patch moves the warning to arch_remove_memory() to only report the problem when it is needed.
--- arch/powerpc/include/asm/sparsemem.h | 4 ++-- arch/powerpc/mm/hash_utils_64.c | 17 ++++++----------- arch/powerpc/mm/mem.c | 3 ++- arch/powerpc/platforms/pseries/lpar.c | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-)
arch/powerpc/include/asm/sparsemem.h +2 -2
@@ -17,9 +17,9 @@ extern int create_section_mapping(unsigned long start, unsigned long end, int niextern int remove_section_mapping (unsigned long start,unsigned long end);#ifdef CONFIG_PPC_BOOK3S_64 -extern void resize_hpt_for_hotplug (unsigned long new_mem_size); +extern int resize_hpt_for_hotplug (unsigned long new_mem_size);#else -static inline void resize_hpt_for_hotplug (unsigned long new_mem_size) { } +static inline int resize_hpt_for_hotplug (unsigned long new_mem_size) {return 0 ; }#endif #ifdef CONFIG_NUMA
arch/powerpc/mm/hash_utils_64.c +6 -11
@@ -755,12 +755,12 @@ static unsigned long __init htab_get_table_size(void) }#ifdef CONFIG_MEMORY_HOTPLUG -void resize_hpt_for_hotplug (unsigned long new_mem_size) +int resize_hpt_for_hotplug (unsigned long new_mem_size) {unsigned target_hpt_shift;if (!mmu_hash_ops.resize_hpt) -return ; +return 0 ; target_hpt_shift =htab_shift_for_mem_size (new_mem_size);
@@ -773,15 +773,10 @@ void resize_hpt_for_hotplug(unsigned long new_mem_size)* current shift */ if ((target_hpt_shift > ppc64_pft_size) - || (target_hpt_shift < (ppc64_pft_size -1 ))) { -int rc; - - rc = mmu_hash_ops.resize_hpt (target_hpt_shift); -if (rc && (rc != -ENODEV )) -printk (KERN_WARNING -"Unable to resize hash page table to target order %d: %d\n" , - target_hpt_shift, rc); - } + || (target_hpt_shift < (ppc64_pft_size -1 ))) +return mmu_hash_ops.resize_hpt (target_hpt_shift); + +return 0 ; }int hash__create_section_mapping (unsigned long start,unsigned long end,int nid)
arch/powerpc/mm/mem.c +2 -1
@@ -169,7 +169,8 @@ int __meminit arch_remove_memory(int nid, u64 start, u64 size,*/ vm_unmap_aliases (); -resize_hpt_for_hotplug (memblock_phys_mem_size ()); +if (resize_hpt_for_hotplug (memblock_phys_mem_size ()) == -ENOSPC ) +pr_warn ("Hash collision while resizing HPT\n" );return ret; }
arch/powerpc/platforms/pseries/lpar.c +2 -1
@@ -901,8 +901,10 @@ static int pseries_lpar_resize_hpt(unsigned long shift)break ;case H_PARAMETER : +pr_warn ("Invalid argument from H_RESIZE_HPT_PREPARE\n" );return -EINVAL ;case H_RESOURCE : +pr_warn ("Operation not permitted from H_RESIZE_HPT_PREPARE\n" );return -EPERM ;default :pr_warn ("Unexpected error %d from H_RESIZE_HPT_PREPARE\n" , rc);
@@ -918,7 +920,6 @@ static int pseries_lpar_resize_hpt(unsigned long shift)if (rc !=0 ) {switch (state.commit_rc) {case H_PTEG_FULL : -pr_warn ("Hash collision while resizing HPT\n" );return -ENOSPC ;default :
Signature · 1 line
2.20.1
I forgot the version change note:
v2: add warning messages for H_PARAMETER and H_RESOURCE
Thanks,
Laurent
Quoted 109 lines · Laurent Vivier
resize_hpt_for_hotplug()reports a warning when it cannot resize the hash page table ("Unable to resize hash page table to target order") but in some cases it's not a problem and can make user thinks something has not worked properly.This patch moves the warning to
arch_remove_memory()to only report the problem when it is needed.Signed-off-by Laurent Vivier <[email protected]>--- arch/powerpc/include/asm/sparsemem.h | 4 ++-- arch/powerpc/mm/hash_utils_64.c | 17 ++++++----------- arch/powerpc/mm/mem.c | 3 ++- arch/powerpc/platforms/pseries/lpar.c | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-)arch/powerpc/include/asm/sparsemem.h +2
-2@@ -17,9 +17,9 @@ extern int create_section_mapping(unsigned long start, unsigned long end, int niextern int remove_section_mapping (unsigned long start,unsigned long end);#ifdef CONFIG_PPC_BOOK3S_64 -extern void resize_hpt_for_hotplug (unsigned long new_mem_size); +extern int resize_hpt_for_hotplug (unsigned long new_mem_size);#else -static inline void resize_hpt_for_hotplug (unsigned long new_mem_size) { } +static inline int resize_hpt_for_hotplug (unsigned long new_mem_size) {return 0 ; }#endif #ifdef CONFIG_NUMA arch/powerpc/mm/hash_utils_64.c +6
-11@@ -755,12 +755,12 @@ static unsigned long __init htab_get_table_size(void) }#ifdef CONFIG_MEMORY_HOTPLUG -void resize_hpt_for_hotplug (unsigned long new_mem_size) +int resize_hpt_for_hotplug (unsigned long new_mem_size) {unsigned target_hpt_shift;if (!mmu_hash_ops.resize_hpt) -return ; +return 0 ; target_hpt_shift =htab_shift_for_mem_size (new_mem_size);@@ -773,15 +773,10 @@ void resize_hpt_for_hotplug(unsigned long new_mem_size)* current shift */ if ((target_hpt_shift > ppc64_pft_size) - || (target_hpt_shift < (ppc64_pft_size -1 ))) { -int rc; - - rc = mmu_hash_ops.resize_hpt (target_hpt_shift); -if (rc && (rc != -ENODEV )) -printk (KERN_WARNING -"Unable to resize hash page table to target order %d: %d\n" , - target_hpt_shift, rc); - } + || (target_hpt_shift < (ppc64_pft_size -1 ))) +return mmu_hash_ops.resize_hpt (target_hpt_shift); + +return 0 ; }int hash__create_section_mapping (unsigned long start,unsigned long end,int nid)arch/powerpc/mm/mem.c +2
-1@@ -169,7 +169,8 @@ int __meminit arch_remove_memory(int nid, u64 start, u64 size,*/ vm_unmap_aliases (); -resize_hpt_for_hotplug (memblock_phys_mem_size ()); +if (resize_hpt_for_hotplug (memblock_phys_mem_size ()) == -ENOSPC ) +pr_warn ("Hash collision while resizing HPT\n" );return ret; }arch/powerpc/platforms/pseries/lpar.c +2
-1@@ -901,8 +901,10 @@ static int pseries_lpar_resize_hpt(unsigned long shift)break ;case H_PARAMETER : +pr_warn ("Invalid argument from H_RESIZE_HPT_PREPARE\n" );return -EINVAL ;case H_RESOURCE : +pr_warn ("Operation not permitted from H_RESIZE_HPT_PREPARE\n" );return -EPERM ;default :pr_warn ("Unexpected error %d from H_RESIZE_HPT_PREPARE\n" , rc);@@ -918,7 +920,6 @@ static int pseries_lpar_resize_hpt(unsigned long shift)if (rc !=0 ) {switch (state.commit_rc) {case H_PTEG_FULL : -pr_warn ("Hash collision while resizing HPT\n" );return -ENOSPC ;default :
Quoted 9 lines · Laurent Vivier
resize_hpt_for_hotplug()reports a warning when it cannot resize the hash page table ("Unable to resize hash page table to target order") but in some cases it's not a problem and can make user thinks something has not worked properly.This patch moves the warning to
arch_remove_memory()to only report the problem when it is needed.Signed-off-by Laurent Vivier <[email protected]>
Quoted 99 lines
--- arch/powerpc/include/asm/sparsemem.h | 4 ++-- arch/powerpc/mm/hash_utils_64.c | 17 ++++++----------- arch/powerpc/mm/mem.c | 3 ++- arch/powerpc/platforms/pseries/lpar.c | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-)arch/powerpc/include/asm/sparsemem.h +2
-2@@ -17,9 +17,9 @@ extern int create_section_mapping(unsigned long start, unsigned long end, int niextern int remove_section_mapping (unsigned long start,unsigned long end);#ifdef CONFIG_PPC_BOOK3S_64 -extern void resize_hpt_for_hotplug (unsigned long new_mem_size); +extern int resize_hpt_for_hotplug (unsigned long new_mem_size);#else -static inline void resize_hpt_for_hotplug (unsigned long new_mem_size) { } +static inline int resize_hpt_for_hotplug (unsigned long new_mem_size) {return 0 ; }#endif #ifdef CONFIG_NUMA arch/powerpc/mm/hash_utils_64.c +6
-11@@ -755,12 +755,12 @@ static unsigned long __init htab_get_table_size(void) }#ifdef CONFIG_MEMORY_HOTPLUG -void resize_hpt_for_hotplug (unsigned long new_mem_size) +int resize_hpt_for_hotplug (unsigned long new_mem_size) {unsigned target_hpt_shift;if (!mmu_hash_ops.resize_hpt) -return ; +return 0 ; target_hpt_shift =htab_shift_for_mem_size (new_mem_size);@@ -773,15 +773,10 @@ void resize_hpt_for_hotplug(unsigned long new_mem_size)* current shift */ if ((target_hpt_shift > ppc64_pft_size) - || (target_hpt_shift < (ppc64_pft_size -1 ))) { -int rc; - - rc = mmu_hash_ops.resize_hpt (target_hpt_shift); -if (rc && (rc != -ENODEV )) -printk (KERN_WARNING -"Unable to resize hash page table to target order %d: %d\n" , - target_hpt_shift, rc); - } + || (target_hpt_shift < (ppc64_pft_size -1 ))) +return mmu_hash_ops.resize_hpt (target_hpt_shift); + +return 0 ; }int hash__create_section_mapping (unsigned long start,unsigned long end,int nid)arch/powerpc/mm/mem.c +2
-1@@ -169,7 +169,8 @@ int __meminit arch_remove_memory(int nid, u64 start, u64 size,*/ vm_unmap_aliases (); -resize_hpt_for_hotplug (memblock_phys_mem_size ()); +if (resize_hpt_for_hotplug (memblock_phys_mem_size ()) == -ENOSPC ) +pr_warn ("Hash collision while resizing HPT\n" );return ret; }arch/powerpc/platforms/pseries/lpar.c +2
-1@@ -901,8 +901,10 @@ static int pseries_lpar_resize_hpt(unsigned long shift)break ;case H_PARAMETER : +pr_warn ("Invalid argument from H_RESIZE_HPT_PREPARE\n" );return -EINVAL ;case H_RESOURCE : +pr_warn ("Operation not permitted from H_RESIZE_HPT_PREPARE\n" );return -EPERM ;default :pr_warn ("Unexpected error %d from H_RESIZE_HPT_PREPARE\n" , rc);@@ -918,7 +920,6 @@ static int pseries_lpar_resize_hpt(unsigned long shift)if (rc !=0 ) {switch (state.commit_rc) {case H_PTEG_FULL : -pr_warn ("Hash collision while resizing HPT\n" );return -ENOSPC ;default :
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Le 08/03/2019 à 11:54, Laurent Vivier a écrit :
Quoted 55 lines
resize_hpt_for_hotplug()reports a warning when it cannot resize the hash page table ("Unable to resize hash page table to target order") but in some cases it's not a problem and can make user thinks something has not worked properly.This patch moves the warning to
arch_remove_memory()to only report the problem when it is needed.Signed-off-by Laurent Vivier <[email protected]>--- arch/powerpc/include/asm/sparsemem.h | 4 ++-- arch/powerpc/mm/hash_utils_64.c | 17 ++++++----------- arch/powerpc/mm/mem.c | 3 ++- arch/powerpc/platforms/pseries/lpar.c | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-)arch/powerpc/include/asm/sparsemem.h +2
-2@@ -17,9 +17,9 @@ extern int create_section_mapping(unsigned long start, unsigned long end, int niextern int remove_section_mapping (unsigned long start,unsigned long end);#ifdef CONFIG_PPC_BOOK3S_64 -extern void resize_hpt_for_hotplug (unsigned long new_mem_size); +extern int resize_hpt_for_hotplug (unsigned long new_mem_size);#else -static inline void resize_hpt_for_hotplug (unsigned long new_mem_size) { } +static inline int resize_hpt_for_hotplug (unsigned long new_mem_size) {return 0 ; }#endif #ifdef CONFIG_NUMA arch/powerpc/mm/hash_utils_64.c +2
-2@@ -755,12 +755,12 @@ static unsigned long __init htab_get_table_size(void) }#ifdef CONFIG_MEMORY_HOTPLUG -void resize_hpt_for_hotplug (unsigned long new_mem_size) +int resize_hpt_for_hotplug (unsigned long new_mem_size) {unsigned target_hpt_shift;if (!mmu_hash_ops.resize_hpt) -return ; +return 0 ; target_hpt_shift =htab_shift_for_mem_size (new_mem_size);@@ -773,15 +773,10 @@ void resize_hpt_for_hotplug(unsigned long new_mem_size)* current shift */ if ((target_hpt_shift > ppc64_pft_size)
arch/powerpc/mm/hash_utils_64.c void resize_hpt_for_hotplug(unsigned long new_mem_size) · line 776
Quoted 10 lines
arch/powerpc/mm/hash_utils_64.c +1
-9- || (target_hpt_shift < (ppc64_pft_size - 1))) { -int rc; - - rc = mmu_hash_ops.resize_hpt (target_hpt_shift); -if (rc && (rc != -ENODEV )) -printk (KERN_WARNING -"Unable to resize hash page table to target order %d: %d\n" , - target_hpt_shift, rc); - } + || (target_hpt_shift < (ppc64_pft_size - 1)))
The || should go on the line above and the two (target_hpt... should be aligned, and the () after the < are superflous.
And indeed, we should (in another patch) rename 'target_hpt_shift' with a shorter name, this would avoid multiple lines.
Ref https://www.kernel.org/doc/html/latest/process/coding-style.html#naming :
LOCAL variable names should be short, and to the point. If you have some random integer loop counter, it should probably be called i. Calling it loop_counter is non-productive, if there is no chance of it being mis-understood. Similarly, tmp can be just about any type of variable that is used to hold a temporary value.
If you are afraid to mix up your local variable names, you have another problem, which is called the function-growth-hormone-imbalance syndrome. See chapter 6 (Functions).
Christophe
Quoted 44 lines
arch/powerpc/mm/hash_utils_64.c +3
-0+return mmu_hash_ops.resize_hpt (target_hpt_shift); + +return 0 ; }int hash__create_section_mapping (unsigned long start,unsigned long end,int nid)arch/powerpc/mm/mem.c +2
-1@@ -169,7 +169,8 @@ int __meminit arch_remove_memory(int nid, u64 start, u64 size,*/ vm_unmap_aliases (); -resize_hpt_for_hotplug (memblock_phys_mem_size ()); +if (resize_hpt_for_hotplug (memblock_phys_mem_size ()) == -ENOSPC ) +pr_warn ("Hash collision while resizing HPT\n" );return ret; }arch/powerpc/platforms/pseries/lpar.c +2
-1@@ -901,8 +901,10 @@ static int pseries_lpar_resize_hpt(unsigned long shift)break ;case H_PARAMETER : +pr_warn ("Invalid argument from H_RESIZE_HPT_PREPARE\n" );return -EINVAL ;case H_RESOURCE : +pr_warn ("Operation not permitted from H_RESIZE_HPT_PREPARE\n" );return -EPERM ;default :pr_warn ("Unexpected error %d from H_RESIZE_HPT_PREPARE\n" , rc);@@ -918,7 +920,6 @@ static int pseries_lpar_resize_hpt(unsigned long shift)if (rc !=0 ) {switch (state.commit_rc) {case H_PTEG_FULL : -pr_warn ("Hash collision while resizing HPT\n" );return -ENOSPC ;default :
Quoted 87 lines · Christophe Leroy
Le 08/03/2019 à 11:54, Laurent Vivier a écrit :
Quoted 60 lines
resize_hpt_for_hotplug()reports a warning when it cannot resize the hash page table ("Unable to resize hash page table to target order") but in some cases it's not a problem and can make user thinks something has not worked properly.This patch moves the warning to
arch_remove_memory()to only report the problem when it is needed.Signed-off-by Laurent Vivier <[email protected]>---
arch/powerpc/include/asm/sparsemem.h | 4 ++-- arch/powerpc/mm/hash_utils_64.c | 17 ++++++----------- arch/powerpc/mm/mem.c | 3 ++-arch/powerpc/platforms/pseries/lpar.c| 3 ++-4 files changed, 12 insertions(+), 15 deletions(-)arch/powerpc/include/asm/sparsemem.h +0
-0@@ -17,9 +17,9 @@ extern int create_section_mapping(unsigned longstart, unsigned long end, int ni
extern intremove_section_mapping(unsigned long start, unsigned long end);
#ifdefCONFIG_PPC_BOOK3S_64arch/powerpc/include/asm/sparsemem.h +1
-1-extern void resize_hpt_for_hotplug (unsigned long new_mem_size); +extern int resize_hpt_for_hotplug (unsigned long new_mem_size);#else
-static inline voidresize_hpt_for_hotplug(unsigned long new_mem_size){ }
+static inline intresize_hpt_for_hotplug(unsigned long new_mem_size){ return 0; }
#endif
#ifdefCONFIG_NUMAarch/powerpc/mm/hash_utils_64.c +2
-2@@ -755,12 +755,12 @@ static unsigned long __init htab_get_table_size(void) } #ifdef CONFIG_MEMORY_HOTPLUG -void resize_hpt_for_hotplug (unsigned long new_mem_size) +int resize_hpt_for_hotplug (unsigned long new_mem_size) { unsigned target_hpt_shift; if (!mmu_hash_ops.resize_hpt) - return; + return 0; target_hpt_shift = htab_shift_for_mem_size(new_mem_size);@@ -773,15 +773,10 @@ void
resize_hpt_for_hotplug(unsigned long new_mem_size)
* current shift
*/
if ((target_hpt_shift>ppc64_pft_size)
- || (target_hpt_shift< (ppc64_pft_size- 1))) { - int rc;
-Quoted 8 lines
- rc =
mmu_hash_ops.resize_hpt(target_hpt_shift);
- if (rc && (rc !=-ENODEV))
- printk(KERN_WARNING
- "Unable to resize hash page table to target order %d: %d\n",
-target_hpt_shift, rc);
- }
+ || (target_hpt_shift< (ppc64_pft_size- 1)))The || should go on the line above and the two (
target_hpt... should be aligned, and the () after the < are superflous.And indeed, we should (in another patch) rename '
target_hpt_shift' with a shorter name, this would avoid multiple lines.Ref
https://www.kernel.org/doc/html/latest/process/coding-style.html#naming :LOCAL variable names should be short, and to the point. If you have some random integer loop counter, it should probably be called i. Calling it
loop_counteris non-productive, if there is no chance of it being mis-understood. Similarly, tmp can be just about any type of variable that is used to hold a temporary value.
Quoted 4 lines
If you are afraid to mix up your local variable names, you have another problem, which is called the function-growth-hormone-imbalance syndrome. See chapter 6 (Functions).
I'm only removing a warning. Do we really need to rewrite all the code around for that?
Thanks,
Laurent
Le 13/03/2019 à 09:01, Laurent Vivier a écrit :
Quoted 88 lines · Christophe Leroy
Quoted 87 lines
Le 08/03/2019 à 11:54, Laurent Vivier a écrit :
Quoted 60 lines
resize_hpt_for_hotplug()reports a warning when it cannot resize the hash page table ("Unable to resize hash page table to target order") but in some cases it's not a problem and can make user thinks something has not worked properly.This patch moves the warning to
arch_remove_memory()to only report the problem when it is needed.Signed-off-by Laurent Vivier <[email protected]>--- arch/powerpc/include/asm/sparsemem.h | 4 ++-- arch/powerpc/mm/hash_utils_64.c | 17 ++++++----------- arch/powerpc/mm/mem.c | 3 ++- arch/powerpc/platforms/pseries/lpar.c | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-)arch/powerpc/include/asm/sparsemem.h +0
-0@@ -17,9 +17,9 @@ extern int create_section_mapping(unsigned longstart, unsigned long end, int ni
extern int remove_section_mapping(unsigned long start, unsigned long
end);
#ifdefCONFIG_PPC_BOOK3S_64arch/powerpc/include/asm/sparsemem.h +1
-2-extern void resize_hpt_for_hotplug (unsigned long new_mem_size); +extern int resize_hpt_for_hotplug (unsigned long new_mem_size); #else -static inline void resize_hpt_for_hotplug (unsigned long new_mem_size){ }
+static inline intresize_hpt_for_hotplug(unsigned long new_mem_size){ return 0; }
#endif
#ifdefCONFIG_NUMAarch/powerpc/mm/hash_utils_64.c +2
-2@@ -755,12 +755,12 @@ static unsigned long __init htab_get_table_size(void) } #ifdef CONFIG_MEMORY_HOTPLUG -void resize_hpt_for_hotplug (unsigned long new_mem_size) +int resize_hpt_for_hotplug (unsigned long new_mem_size) { unsigned target_hpt_shift; if (!mmu_hash_ops.resize_hpt) - return; + return 0; target_hpt_shift = htab_shift_for_mem_size(new_mem_size); @@ -773,15 +773,10 @@ void resize_hpt_for_hotplug(unsigned long new_mem_size) * current shift*/
if ((target_hpt_shift>ppc64_pft_size)
- || (target_hpt_shift< (ppc64_pft_size- 1))) { - int rc;
-Quoted 8 lines
- rc =
mmu_hash_ops.resize_hpt(target_hpt_shift);
- if (rc && (rc !=-ENODEV))
- printk(KERN_WARNING
- "Unable to resize hash page table to target order %d: %d\n",
-target_hpt_shift, rc);
- }
+ || (target_hpt_shift< (ppc64_pft_size- 1)))The || should go on the line above and the two (
target_hpt... should be aligned, and the () after the < are superflous.And indeed, we should (in another patch) rename '
target_hpt_shift' with a shorter name, this would avoid multiple lines.Ref
https://www.kernel.org/doc/html/latest/process/coding-style.html#naming :LOCAL variable names should be short, and to the point. If you have some random integer loop counter, it should probably be called i. Calling it
loop_counteris non-productive, if there is no chance of it being mis-understood. Similarly, tmp can be just about any type of variable that is used to hold a temporary value.
Quoted 7 lines
Quoted 4 lines
If you are afraid to mix up your local variable names, you have another problem, which is called the function-growth-hormone-imbalance syndrome. See chapter 6 (Functions).
I'm only removing a warning. Do we really need to rewrite all the code around for that?
No, and that's the reason why I said it could be done in another (future) patch.
Anyway, your patch should be clean regarding checkpatch
See https://patchwork.ozlabs.org/patch/1052984/
And https://openpower.xyz/job/snowpatch/job/snowpatch-linux-checkpatch/3298//artifact/linux/checkpatch.log
CHECK:AVOID_EXTERNS: extern prototypes should be avoided in .h files #31: FILE: arch/powerpc/include/asm/sparsemem.h:20:
+extern int resize_hpt_for_hotplug(unsigned long new_mem_size);
CHECK:LOGICAL_CONTINUATIONS: Logical continuations should be on the previous line #70: FILE: arch/powerpc/mm/hash_utils_64.c:776:
if ((target_hpt_shift > ppc64_pft_size)
+ || (target_hpt_shift < (ppc64_pft_size - 1)))
total: 0 errors, 0 warnings, 2 checks, 60 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or
--fix-inplace.
the.patch has style problems, please review.
NOTE: Ignored message types: ARCH_INCLUDE_LINUX BIT_MACRO COMPARISON_TO_NULL DT_SPLIT_BINDING_PATCH EMAIL_SUBJECT FILE_PATH_CHANGES GLOBAL_INITIALISERS LINE_SPACING MULTIPLE_ASSIGNMENTS
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
Christophe
Quoted 4 lines
Thanks,
Laurent
Quoted 114 lines · Christophe Leroy
Le 13/03/2019 à 09:01, Laurent Vivier a écrit :
Quoted 89 lines · Christophe Leroy
Quoted 88 lines
Le 08/03/2019 à 11:54, Laurent Vivier a écrit :
Quoted 60 lines
resize_hpt_for_hotplug()reports a warning when it cannot resize the hash page table ("Unable to resize hash page table to target order") but in some cases it's not a problem and can make user thinks something has not worked properly.This patch moves the warning to
arch_remove_memory()to only report the problem when it is needed.Signed-off-by Laurent Vivier <[email protected]>---
arch/powerpc/include/asm/sparsemem.h | 4 ++-- arch/powerpc/mm/hash_utils_64.c | 17 ++++++----------- arch/powerpc/mm/mem.c | 3 ++-arch/powerpc/platforms/pseries/lpar.c| 3 ++-4 files changed, 12 insertions(+), 15 deletions(-)arch/powerpc/include/asm/sparsemem.h +0
-0@@ -17,9 +17,9 @@ extern int create_section_mapping(unsigned longstart, unsigned long end, int ni
extern intremove_section_mapping(unsigned long start, unsigned long end);
#ifdefCONFIG_PPC_BOOK3S_64arch/powerpc/include/asm/sparsemem.h +1
-1-extern void resize_hpt_for_hotplug (unsigned long new_mem_size); +extern int resize_hpt_for_hotplug (unsigned long new_mem_size);#else
-static inline voidresize_hpt_for_hotplug(unsigned long new_mem_size){ }
+static inline intresize_hpt_for_hotplug(unsigned long new_mem_size){ return 0; }
#endif
#ifdefCONFIG_NUMAarch/powerpc/mm/hash_utils_64.c +2
-2@@ -755,12 +755,12 @@ static unsigned long __init htab_get_table_size(void) } #ifdef CONFIG_MEMORY_HOTPLUG -void resize_hpt_for_hotplug (unsigned long new_mem_size) +int resize_hpt_for_hotplug (unsigned long new_mem_size) { unsigned target_hpt_shift; if (!mmu_hash_ops.resize_hpt) - return; + return 0; target_hpt_shift = htab_shift_for_mem_size(new_mem_size);@@ -773,15 +773,10 @@ void
resize_hpt_for_hotplug(unsigned long new_mem_size)
* current shift
*/
if ((target_hpt_shift>ppc64_pft_size)
- || (target_hpt_shift< (ppc64_pft_size- 1))) { - int rc;
-Quoted 8 lines
- rc =
mmu_hash_ops.resize_hpt(target_hpt_shift);
- if (rc && (rc !=-ENODEV))
- printk(KERN_WARNING
- "Unable to resize hash page table to target order %d: %d\n",
-target_hpt_shift, rc);
- }
+ || (target_hpt_shift< (ppc64_pft_size- 1)))The || should go on the line above and the two (
target_hpt... should be aligned, and the () after the < are superflous.And indeed, we should (in another patch) rename '
target_hpt_shift' with a shorter name, this would avoid multiple lines.Ref
https://www.kernel.org/doc/html/latest/process/coding-style.html#naming
:LOCAL variable names should be short, and to the point. If you have some random integer loop counter, it should probably be called i. Calling it
loop_counteris non-productive, if there is no chance of it being mis-understood. Similarly, tmp can be just about any type of variable that is used to hold a temporary value.Quoted 7 lines
Quoted 4 lines
If you are afraid to mix up your local variable names, you have another problem, which is called the function-growth-hormone-imbalance syndrome. See chapter 6 (Functions).
I'm only removing a warning. Do we really need to rewrite all the code around for that?
No, and that's the reason why I said it could be done in another (future) patch.
Anyway, your patch should be clean regarding checkpatch
See https://patchwork.ozlabs.org/patch/1052984/
And
https://openpower.xyz/job/snowpatch/job/snowpatch-linux-checkpatch/3298//artifact/linux/checkpatch.logCHECK:AVOID_EXTERNS: extern prototypes should be avoided in .h files #31: FILE:
arch/powerpc/include/asm/sparsemem.h:20:
+extern intresize_hpt_for_hotplug(unsigned long new_mem_size);
Quoted 6 lines
CHECK:LOGICAL_CONTINUATIONS: Logical continuations should be on the previous line
#70: FILE:arch/powerpc/mm/hash_utils_64.c:776:
if ((target_hpt_shift>ppc64_pft_size)
+ || (target_hpt_shift< (ppc64_pft_size- 1)))
It's really strange, from linux directory:
./scripts/checkpatch.pl 0001-powerpc-mm-move-warning-from-resize_hpt_for_hotplug.patch
doesn't output this error [1]. Why linux-ppc doesn't use the same script as in the kernel directory?
Anyway, I send a v3.
Thanks,
Laurent
[1] only:
WARNING: line over 80 characters
#34: FILE: arch/powerpc/include/asm/sparsemem.h:22:
+static inline int resize_hpt_for_hotplug(unsigned long new_mem_size) { return 0; }
total: 0 errors, 1 warnings, 70 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
0001-powerpc-mm-move-warning-from-resize_hpt_for_hotplug.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
But I think it's cleaner to keep the over 80 characters line for the inline.
Le 13/03/2019 à 09:50, Laurent Vivier a écrit :
Quoted 122 lines · Christophe Leroy
Quoted 114 lines
Le 13/03/2019 à 09:01, Laurent Vivier a écrit :
Quoted 89 lines · Christophe Leroy
Quoted 88 lines
Le 08/03/2019 à 11:54, Laurent Vivier a écrit :
Quoted 60 lines
resize_hpt_for_hotplug()reports a warning when it cannot resize the hash page table ("Unable to resize hash page table to target order") but in some cases it's not a problem and can make user thinks something has not worked properly.This patch moves the warning to
arch_remove_memory()to only report the problem when it is needed.Signed-off-by Laurent Vivier <[email protected]>--- arch/powerpc/include/asm/sparsemem.h | 4 ++-- arch/powerpc/mm/hash_utils_64.c | 17 ++++++----------- arch/powerpc/mm/mem.c | 3 ++- arch/powerpc/platforms/pseries/lpar.c | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-)arch/powerpc/include/asm/sparsemem.h +0
-0@@ -17,9 +17,9 @@ extern int create_section_mapping(unsigned longstart, unsigned long end, int ni
extern int remove_section_mapping(unsigned long start, unsigned long
end);
#ifdefCONFIG_PPC_BOOK3S_64arch/powerpc/include/asm/sparsemem.h +1
-2-extern void resize_hpt_for_hotplug (unsigned long new_mem_size); +extern int resize_hpt_for_hotplug (unsigned long new_mem_size); #else -static inline void resize_hpt_for_hotplug (unsigned long new_mem_size){ }
+static inline intresize_hpt_for_hotplug(unsigned long new_mem_size){ return 0; }
#endif
#ifdefCONFIG_NUMAarch/powerpc/mm/hash_utils_64.c +2
-2@@ -755,12 +755,12 @@ static unsigned long __init htab_get_table_size(void) } #ifdef CONFIG_MEMORY_HOTPLUG -void resize_hpt_for_hotplug (unsigned long new_mem_size) +int resize_hpt_for_hotplug (unsigned long new_mem_size) { unsigned target_hpt_shift; if (!mmu_hash_ops.resize_hpt) - return; + return 0; target_hpt_shift = htab_shift_for_mem_size(new_mem_size); @@ -773,15 +773,10 @@ void resize_hpt_for_hotplug(unsigned long new_mem_size) * current shift*/
if ((target_hpt_shift>ppc64_pft_size)
- || (target_hpt_shift< (ppc64_pft_size- 1))) { - int rc;
-Quoted 8 lines
- rc =
mmu_hash_ops.resize_hpt(target_hpt_shift);
- if (rc && (rc !=-ENODEV))
- printk(KERN_WARNING
- "Unable to resize hash page table to target order %d: %d\n",
-target_hpt_shift, rc);
- }
+ || (target_hpt_shift< (ppc64_pft_size- 1)))The || should go on the line above and the two (
target_hpt... should be aligned, and the () after the < are superflous.And indeed, we should (in another patch) rename '
target_hpt_shift' with a shorter name, this would avoid multiple lines.Ref
https://www.kernel.org/doc/html/latest/process/coding-style.html#naming
:LOCAL variable names should be short, and to the point. If you have some random integer loop counter, it should probably be called i. Calling it
loop_counteris non-productive, if there is no chance of it being mis-understood. Similarly, tmp can be just about any type of variable that is used to hold a temporary value.Quoted 7 lines
Quoted 4 lines
If you are afraid to mix up your local variable names, you have another problem, which is called the function-growth-hormone-imbalance syndrome. See chapter 6 (Functions).
I'm only removing a warning. Do we really need to rewrite all the code around for that?
No, and that's the reason why I said it could be done in another (future) patch.
Anyway, your patch should be clean regarding checkpatch
See https://patchwork.ozlabs.org/patch/1052984/
And
https://openpower.xyz/job/snowpatch/job/snowpatch-linux-checkpatch/3298//artifact/linux/checkpatch.logCHECK:AVOID_EXTERNS: extern prototypes should be avoided in .h files #31: FILE:
arch/powerpc/include/asm/sparsemem.h:20:
+extern intresize_hpt_for_hotplug(unsigned long new_mem_size);Quoted 6 lines
CHECK:LOGICAL_CONTINUATIONS: Logical continuations should be on the previous line
#70: FILE:arch/powerpc/mm/hash_utils_64.c:776:
if ((target_hpt_shift>ppc64_pft_size)
+ || (target_hpt_shift< (ppc64_pft_size- 1)))
Quoted 3 lines
It's really strange, from linux directory:
./scripts/checkpatch.pl0001-powerpc-mm-move-warning-from-resize_hpt_for_hotplug.patch
Try with --strict
Quoted 2 lines
doesn't output this error [1]. Why linux-ppc doesn't use the same script as in the kernel directory?
linux-ppc used it but with dedicated options, see arch/powerpc/tools/checkpatch.sh
Quoted 11 lines
Anyway, I send a v3.
Thanks,
Laurent[1] only:
WARNING: line over 80 characters
#34: FILE:arch/powerpc/include/asm/sparsemem.h:22:
+static inline intresize_hpt_for_hotplug(unsigned long new_mem_size){ return 0; }
linux-ppc allows 90 characters.
Quoted 6 lines
total: 0 errors, 1 warnings, 70 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
Quoted 8 lines
0001-powerpc-mm-move-warning-from-resize_hpt_for_hotplug.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH inMAINTAINERS.But I think it's cleaner to keep the over 80 characters line for the inline.
Christophe