Skip to contentSkip to conversation

common/page_alloc: Drop BOOT_BUG_ON()

PATCH In review Andrew Cooper 3 participants 4 messages Aug 8, 2017 – Aug 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/page_alloc: Drop BOOT_BUG_ON()

Regular BUG_ON()'s work fine by this point on all architectures, so drop the custom infrastructure. Substitute BUG_ON(1) for BUG().

---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>

---
 xen/common/page_alloc.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
xen/common/page_alloc.c +4 -12
index 8bcef6a..64fe951 100644
@@ -203,12 +203,6 @@ struct scrub_region {
 static struct scrub_region __initdata region[MAX_NUMNODES];
 static unsigned long __initdata chunk_size;
 
-static void __init boot_bug(int line)
-{
-    panic("Boot BUG at %s:%d", __FILE__, line);
-}
-#define BOOT_BUG_ON(p) if ( p ) boot_bug(__LINE__);
-
 static void __init bootmem_region_add(unsigned long s, unsigned long e)
 {
     unsigned int i;
@@ -223,9 +217,8 @@ static void __init bootmem_region_add(unsigned long s, unsigned long e)
         if ( s < bootmem_region_list[i].e )
             break;
 
-    BOOT_BUG_ON((i < nr_bootmem_regions) && (e > bootmem_region_list[i].s));
-    BOOT_BUG_ON(nr_bootmem_regions ==
-                (PAGE_SIZE / sizeof(struct bootmem_region)));
+    BUG_ON((i < nr_bootmem_regions) && (e > bootmem_region_list[i].s));
+    BUG_ON(nr_bootmem_regions == (PAGE_SIZE / sizeof(struct bootmem_region)));
 
     memmove(&bootmem_region_list[i+1], &bootmem_region_list[i],
             (nr_bootmem_regions - i) * sizeof(*bootmem_region_list));
@@ -328,7 +321,7 @@ unsigned long __init alloc_boot_pages(
     unsigned long pg, _e;
     unsigned int i = nr_bootmem_regions;
 
-    BOOT_BUG_ON(!nr_bootmem_regions);
+    BUG_ON(!nr_bootmem_regions);
 
     while ( i-- )
     {
@@ -362,8 +355,7 @@ unsigned long __init alloc_boot_pages(
         return pg;
     }
 
-    BOOT_BUG_ON(1);
-    return 0;
+    BUG();
 }
 
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 08.08.17 at 19:28, <[email protected]> wrote:

Regular BUG_ON()'s work fine by this point on all architectures, so drop the custom infrastructure. Substitute BUG_ON(1) for BUG().

with one question:

xen/common/page_alloc.c unsigned long __init alloc_boot_pages( · line 359

Quoted 8 lines
xen/common/page_alloc.c +1 -2
@@ -362,8 +355,7 @@ unsigned long __init alloc_boot_pages(
         return pg;
     }
 
-    BOOT_BUG_ON(1);
-    return 0;
+    BUG();
 }

Are all versions of gcc we formally support happy with the dropped return?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 12 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 08.08.17 at 19:28, <[email protected]> wrote:

Regular BUG_ON()'s work fine by this point on all architectures, so drop the custom infrastructure. Substitute BUG_ON(1) for BUG().

with one question:

Quoted 4 lines
xen/common/page_alloc.c +0 -0
@@ -362,8 +355,7 @@ unsigned long __init alloc_boot_pages(
         return pg;
     }
 
Quoted 6 lines

xen/common/page_alloc.c unsigned long __init alloc_boot_pages( · line 359

Quoted 4 lines
xen/common/page_alloc.c +1 -2
-    BOOT_BUG_ON(1);
-    return 0;
+    BUG();
 }

Are all versions of gcc we formally support happy with the dropped return?

BUG() has an unreachable() at the end of it, which is do {} while (1) for older compilers.

We already have constructs like this sporadically over the code, oos_snapshot_lookup() as an example.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v1 1/1
#3 lore raw
In reply to Andrew Cooper

Hi Andrew,

Quoted 4 lines · Andrew Cooper

Regular BUG_ON()'s work fine by this point on all architectures, so drop the custom infrastructure. Substitute BUG_ON(1) for BUG().

FWIW:

Cheers,

Quoted 57 lines

---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>

---
 xen/common/page_alloc.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
xen/common/page_alloc.c +4 -12
index 8bcef6a..64fe951 100644
@@ -203,12 +203,6 @@ struct scrub_region {
 static struct scrub_region __initdata region[MAX_NUMNODES];
 static unsigned long __initdata chunk_size;
 
-static void __init boot_bug(int line)
-{
-    panic("Boot BUG at %s:%d", __FILE__, line);
-}
-#define BOOT_BUG_ON(p) if ( p ) boot_bug(__LINE__);
-
 static void __init bootmem_region_add(unsigned long s, unsigned long e)
 {
     unsigned int i;
@@ -223,9 +217,8 @@ static void __init bootmem_region_add(unsigned long s, unsigned long e)
         if ( s < bootmem_region_list[i].e )
             break;
 
-    BOOT_BUG_ON((i < nr_bootmem_regions) && (e > bootmem_region_list[i].s));
-    BOOT_BUG_ON(nr_bootmem_regions ==
-                (PAGE_SIZE / sizeof(struct bootmem_region)));
+    BUG_ON((i < nr_bootmem_regions) && (e > bootmem_region_list[i].s));
+    BUG_ON(nr_bootmem_regions == (PAGE_SIZE / sizeof(struct bootmem_region)));
 
     memmove(&bootmem_region_list[i+1], &bootmem_region_list[i],
             (nr_bootmem_regions - i) * sizeof(*bootmem_region_list));
@@ -328,7 +321,7 @@ unsigned long __init alloc_boot_pages(
     unsigned long pg, _e;
     unsigned int i = nr_bootmem_regions;
 
-    BOOT_BUG_ON(!nr_bootmem_regions);
+    BUG_ON(!nr_bootmem_regions);
 
     while ( i-- )
     {
@@ -362,8 +355,7 @@ unsigned long __init alloc_boot_pages(
         return pg;
     }
 
-    BOOT_BUG_ON(1);
-    return 0;
+    BUG();
 }
 
 
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel