mm/vmalloc: replace BUG_ON to a simple if statement
Subsystems (2)
PATCH v4 1/1 mm/vmalloc: replace BUG_ON to a simple if statement
As per the coding standards, in the event of an abnormal condition that should not occur under normal circumstances, the kernel should attempt recovery and proceed with execution, rather than halting the machine.
Specifically, in the alloc_vmap_area() function, use a simple if() instead of using BUG_ON() halting the machine.
---v1->v2 : Add commit descriptionv2->v3 : Change WARN_ON() to if()v3->v4 : Use only one if() for three conditions
--- mm/vmalloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
mm/vmalloc.c +2 -3
@@ -1587,9 +1587,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,int purged =0 ;int ret; -BUG_ON (!size); -BUG_ON (offset_in_page (size)); -BUG_ON (!is_power_of_2 (align)); +if (unlikely (!size ||offset_in_page (size) || !is_power_of_2 (align))) +return ERR_PTR (-EINVAL );if (unlikely (!vmap_initialized))return ERR_PTR (-EBUSY );
Signature · 1 line
2.25.1
Le 01/02/2023 à 12:51, Hyunmin Lee a écrit :
Quoted 7 lines
As per the coding standards, in the event of an abnormal condition that should not occur under normal circumstances, the kernel should attempt recovery and proceed with execution, rather than halting the machine.
Specifically, in the
alloc_vmap_area()function, use a simpleif()instead of usingBUG_ON()halting the machine.
Quoted 8 lines
Co-Developed-by Gwan-gyeong Mun <[email protected]>Co-Developed-by Jeungwoo Yoo <[email protected]>Co-Developed-by Sangyun Kim <[email protected]>Signed-off-by Hyunmin Lee <[email protected]>Signed-off-by Gwan-gyeong Mun <[email protected]>Signed-off-by Jeungwoo Yoo <[email protected]>Signed-off-by Sangyun Kim <[email protected]>Cc Hyeonggon Yoo <[email protected]>
Quoted 24 lines
---
v1->v2: Add commit descriptionv2->v3: ChangeWARN_ON()toif()v3->v4: Use only oneif()for three conditions--- mm/vmalloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)mm/vmalloc.c +2
-3@@ -1587,9 +1587,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,int purged =0 ;int ret; -BUG_ON (!size); -BUG_ON (offset_in_page (size)); -BUG_ON (!is_power_of_2 (align)); +if (unlikely (!size ||offset_in_page (size) || !is_power_of_2 (align))) +return ERR_PTR (-EINVAL );if (unlikely (!vmap_initialized))return ERR_PTR (-EBUSY );
Quoted 29 lines · Hyunmin Lee
As per the coding standards, in the event of an abnormal condition that should not occur under normal circumstances, the kernel should attempt recovery and proceed with execution, rather than halting the machine.
Specifically, in the
alloc_vmap_area()function, use a simpleif()instead of usingBUG_ON()halting the machine.Co-Developed-by Gwan-gyeong Mun <[email protected]>Co-Developed-by Jeungwoo Yoo <[email protected]>Co-Developed-by Sangyun Kim <[email protected]>Signed-off-by Hyunmin Lee <[email protected]>Signed-off-by Gwan-gyeong Mun <[email protected]>Signed-off-by Jeungwoo Yoo <[email protected]>Signed-off-by Sangyun Kim <[email protected]>Cc Hyeonggon Yoo <[email protected]>---
v1->v2: Add commit descriptionv2->v3: ChangeWARN_ON()toif()v3->v4: Use only oneif()for three conditions--- mm/vmalloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)mm/vmalloc.c +0
-0@@ -1587,9 +1587,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,int purged =0 ;
mm/vmalloc.c static struct vmap_area *alloc_vmap_area(unsigned long size, · line 1594
Quoted 10 lines
mm/vmalloc.c +2
-3int ret; -BUG_ON (!size); -BUG_ON (offset_in_page (size)); -BUG_ON (!is_power_of_2 (align)); +if (unlikely (!size ||offset_in_page (size) || !is_power_of_2 (align))) +return ERR_PTR (-EINVAL );if (unlikely (!vmap_initialized))return ERR_PTR (-EBUSY );
Thanks!
Quoted 2 lines
Signature · 1 line
2.25.1
Regards,
Hyeonggon
Quoted 7 lines · Hyunmin Lee
As per the coding standards, in the event of an abnormal condition that should not occur under normal circumstances, the kernel should attempt recovery and proceed with execution, rather than halting the machine.
Specifically, in the
alloc_vmap_area()function, use a simpleif()instead of usingBUG_ON()halting the machine.
Quoted 8 lines
Co-Developed-by Gwan-gyeong Mun <[email protected]>Co-Developed-by Jeungwoo Yoo <[email protected]>Co-Developed-by Sangyun Kim <[email protected]>Signed-off-by Hyunmin Lee <[email protected]>Signed-off-by Gwan-gyeong Mun <[email protected]>Signed-off-by Jeungwoo Yoo <[email protected]>Signed-off-by Sangyun Kim <[email protected]>Cc Hyeonggon Yoo <[email protected]>
Quoted 27 lines
---
v1->v2: Add commit descriptionv2->v3: ChangeWARN_ON()toif()v3->v4: Use only oneif()for three conditions--- mm/vmalloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)mm/vmalloc.c +2
-3@@ -1587,9 +1587,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,int purged =0 ;int ret; -BUG_ON (!size); -BUG_ON (offset_in_page (size)); -BUG_ON (!is_power_of_2 (align)); +if (unlikely (!size ||offset_in_page (size) || !is_power_of_2 (align))) +return ERR_PTR (-EINVAL );if (unlikely (!vmap_initialized))return ERR_PTR (-EBUSY );Signature · 1 line
2.25.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 42 lines · Hyunmin Lee
As per the coding standards, in the event of an abnormal condition that should not occur under normal circumstances, the kernel should attempt recovery and proceed with execution, rather than halting the machine.
Specifically, in the
alloc_vmap_area()function, use a simpleif()instead of usingBUG_ON()halting the machine.Co-Developed-by Gwan-gyeong Mun <[email protected]>Co-Developed-by Jeungwoo Yoo <[email protected]>Co-Developed-by Sangyun Kim <[email protected]>Signed-off-by Hyunmin Lee <[email protected]>Signed-off-by Gwan-gyeong Mun <[email protected]>Signed-off-by Jeungwoo Yoo <[email protected]>Signed-off-by Sangyun Kim <[email protected]>Cc Hyeonggon Yoo <[email protected]>---
v1->v2: Add commit descriptionv2->v3: ChangeWARN_ON()toif()v3->v4: Use only oneif()for three conditions--- mm/vmalloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)mm/vmalloc.c +2
-3@@ -1587,9 +1587,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,int purged =0 ;int ret; -BUG_ON (!size); -BUG_ON (offset_in_page (size)); -BUG_ON (!is_power_of_2 (align)); +if (unlikely (!size ||offset_in_page (size) || !is_power_of_2 (align))) +return ERR_PTR (-EINVAL );if (unlikely (!vmap_initialized))return ERR_PTR (-EBUSY );Signature · 1 line
2.25.1
Makes sense to me.
--
Uladzislau Rezki