public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.4-ac: BUG_ON (2/2)
@ 2002-04-03  3:03 Robert Love
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Love @ 2002-04-03  3:03 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel

Alan,

This patch, which requires the previous BUG_ON part 1 patch, changes a
few uses of BUG -> BUG_ON in fast paths in the kernel, partly to
demonstrate readability, partly for the optimization, mostly to give a
reason to take part 1. ;)

This is a separate patch from the Marcelo variant as part 2 does not
apply cleanly to your tree due to various changes.

Patch is against 2.4.19-pre4-ac3, please apply.

	Robert Love

diff -urN linux-2.4.19-pre4-ac3/arch/i386/kernel/smp.c linux/arch/i386/kernel/smp.c
--- linux-2.4.19-pre4-ac3/arch/i386/kernel/smp.c	Sat Mar 30 18:48:32 2002
+++ linux/arch/i386/kernel/smp.c	Sat Mar 30 18:49:22 2002
@@ -301,8 +301,7 @@
  */
 static void inline leave_mm (unsigned long cpu)
 {
-	if (cpu_tlbstate[cpu].state == TLBSTATE_OK)
-		BUG();
+	BUG_ON(cpu_tlbstate[cpu].state == TLBSTATE_OK);
 	clear_bit(cpu, &cpu_tlbstate[cpu].active_mm->cpu_vm_mask);
 }
 
diff -urN linux-2.4.19-pre4-ac3/kernel/exit.c linux/kernel/exit.c
--- linux-2.4.19-pre4-ac3/kernel/exit.c	Sat Mar 30 18:47:40 2002
+++ linux/kernel/exit.c	Sat Mar 30 18:49:22 2002
@@ -362,7 +362,7 @@
 	mm_release();
 	if (mm) {
 		atomic_inc(&mm->mm_count);
-		if (mm != tsk->active_mm) BUG();
+		BUG_ON(mm != tsk->active_mm);
 		/* more a memory barrier than a real lock */
 		task_lock(tsk);
 		tsk->mm = NULL;
diff -urN linux-2.4.19-pre4-ac3/kernel/fork.c linux/kernel/fork.c
--- linux-2.4.19-pre4-ac3/kernel/fork.c	Sat Mar 30 18:47:40 2002
+++ linux/kernel/fork.c	Sat Mar 30 18:49:22 2002
@@ -275,7 +275,7 @@
  */
 inline void __mmdrop(struct mm_struct *mm)
 {
-	if (mm == &init_mm) BUG();
+	BUG_ON(mm == &init_mm);
 	pgd_free(mm->pgd);
 	destroy_context(mm);
 	free_mm(mm);
diff -urN linux-2.4.19-pre4-ac3/kernel/sched.c linux/kernel/sched.c
--- linux-2.4.19-pre4-ac3/kernel/sched.c	Sat Mar 30 18:47:40 2002
+++ linux/kernel/sched.c	Sat Mar 30 18:49:22 2002
@@ -749,8 +749,8 @@
 	list_t *queue;
 	int idx;
 
-	if (unlikely(in_interrupt()))
-		BUG();
+	BUG_ON(in_interrupt());
+
 	release_kernel_lock(prev, smp_processor_id());
 	prev->sleep_timestamp = jiffies;
 	spin_lock_irq(&rq->lock);
diff -urN linux-2.4.19-pre4-ac3/mm/rmap.c linux/mm/rmap.c
--- linux-2.4.19-pre4-ac3/mm/rmap.c	Sat Mar 30 18:47:40 2002
+++ linux/mm/rmap.c	Sat Mar 30 18:49:22 2002
@@ -136,8 +136,7 @@
 {
 	struct pte_chain * pc, * prev_pc = NULL;
 
-	if (!page || !ptep)
-		BUG();
+	BUG_ON(!page || !ptep);
 	if (!VALID_PAGE(page) || PageReserved(page))
 		return;
 
@@ -186,8 +185,7 @@
 	pte_t pte;
 	int ret;
 
-	if (!mm)
-		BUG();
+	BUG_ON(!mm);
 
 	/*
 	 * We need the page_table_lock to protect us from page faults,
@@ -255,13 +253,10 @@
 	int ret = SWAP_SUCCESS;
 
 	/* This page should not be on the pageout lists. */
-	if (!VALID_PAGE(page) || PageReserved(page))
-		BUG();
-	if (!PageLocked(page))
-		BUG();
+	BUG_ON(!VALID_PAGE(page) || PageReserved(page));
+	BUG_ON(!PageLocked(page));
 	/* We need backing store to swap out a page. */
-	if (!page->mapping)
-		BUG();
+	BUG_ON(!page->mapping);
 
 	for (pc = page->pte_chain; pc; pc = next_pc) {
 		next_pc = pc->next;
diff -urN linux-2.4.19-pre4-ac3/mm/slab.c linux/mm/slab.c
--- linux-2.4.19-pre4-ac3/mm/slab.c	Sat Mar 30 18:47:40 2002
+++ linux/mm/slab.c	Sat Mar 30 18:49:22 2002
@@ -666,8 +666,7 @@
 	 * Always checks flags, a caller might be expecting debug
 	 * support which isn't available.
 	 */
-	if (flags & ~CREATE_MASK)
-		BUG();
+	BUG_ON(flags & ~CREATE_MASK);
 
 	/* Get cache's description obj. */
 	cachep = (kmem_cache_t *) kmem_cache_alloc(&cache_cache, SLAB_KERNEL);




^ permalink raw reply	[flat|nested] 2+ messages in thread
* [PATCH] 2.4-ac: BUG_ON (2/2)
@ 2002-03-21  0:16 Robert Love
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Love @ 2002-03-21  0:16 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel

Alan,

This patch, which requires the previous BUG_ON part 1 patch, changes a
few uses of BUG -> BUG_ON in fast paths in the kernel.

This is a separate patch from the Marcelo variant as part 2 does not
apply cleanly to your tree due to various changes.

Patch is against 2.4.19-pre3-ac4.  Alan, please apply.

	Robert Love

diff -urN linux-2.4.19-pre3-ac4/arch/i386/kernel/smp.c linux/arch/i386/kernel/smp.c
--- linux-2.4.19-pre3-ac4/arch/i386/kernel/smp.c	Wed Mar 20 18:56:39 2002
+++ linux/arch/i386/kernel/smp.c	Wed Mar 20 18:49:51 2002
@@ -301,8 +301,7 @@
  */
 static void inline leave_mm (unsigned long cpu)
 {
-	if (cpu_tlbstate[cpu].state == TLBSTATE_OK)
-		BUG();
+	BUG_ON(cpu_tlbstate[cpu].state == TLBSTATE_OK);
 	clear_bit(cpu, &cpu_tlbstate[cpu].active_mm->cpu_vm_mask);
 }
 
diff -urN linux-2.4.19-pre3-ac4/kernel/exit.c linux/kernel/exit.c
--- linux-2.4.19-pre3-ac4/kernel/exit.c	Wed Mar 20 18:56:51 2002
+++ linux/kernel/exit.c	Wed Mar 20 18:49:51 2002
@@ -362,7 +362,7 @@
 	mm_release();
 	if (mm) {
 		atomic_inc(&mm->mm_count);
-		if (mm != tsk->active_mm) BUG();
+		BUG_ON(mm != tsk->active_mm);
 		/* more a memory barrier than a real lock */
 		task_lock(tsk);
 		tsk->mm = NULL;
diff -urN linux-2.4.19-pre3-ac4/kernel/fork.c linux/kernel/fork.c
--- linux-2.4.19-pre3-ac4/kernel/fork.c	Wed Mar 20 18:56:51 2002
+++ linux/kernel/fork.c	Wed Mar 20 18:49:51 2002
@@ -275,7 +275,7 @@
  */
 inline void __mmdrop(struct mm_struct *mm)
 {
-	if (mm == &init_mm) BUG();
+	BUG_ON(mm == &init_mm);
 	pgd_free(mm->pgd);
 	destroy_context(mm);
 	free_mm(mm);
diff -urN linux-2.4.19-pre3-ac4/kernel/sched.c linux/kernel/sched.c
--- linux-2.4.19-pre3-ac4/kernel/sched.c	Wed Mar 20 18:56:51 2002
+++ linux/kernel/sched.c	Wed Mar 20 18:50:23 2002
@@ -749,8 +749,8 @@
 	list_t *queue;
 	int idx;
 
-	if (unlikely(in_interrupt()))
-		BUG();
+	BUG_ON(in_interrupt());
+
 	release_kernel_lock(prev, smp_processor_id());
 	prev->sleep_timestamp = jiffies;
 	spin_lock_irq(&rq->lock);
diff -urN linux-2.4.19-pre3-ac4/mm/rmap.c linux/mm/rmap.c
--- linux-2.4.19-pre3-ac4/mm/rmap.c	Wed Mar 20 18:56:52 2002
+++ linux/mm/rmap.c	Wed Mar 20 18:52:16 2002
@@ -136,8 +136,7 @@
 {
 	struct pte_chain * pc, * prev_pc = NULL;
 
-	if (!page || !ptep)
-		BUG();
+	BUG_ON(!page || !ptep);
 	if (!VALID_PAGE(page) || PageReserved(page))
 		return;
 
@@ -186,8 +185,7 @@
 	pte_t pte;
 	int ret;
 
-	if (!mm)
-		BUG();
+	BUG_ON(!mm);
 
 	/*
 	 * We need the page_table_lock to protect us from page faults,
@@ -255,13 +253,10 @@
 	int ret = SWAP_SUCCESS;
 
 	/* This page should not be on the pageout lists. */
-	if (!VALID_PAGE(page) || PageReserved(page))
-		BUG();
-	if (!PageLocked(page))
-		BUG();
+	BUG_ON(!VALID_PAGE(page) || PageReserved(page));
+	BUG_ON(!PageLocked(page));
 	/* We need backing store to swap out a page. */
-	if (!page->mapping)
-		BUG();
+	BUG_ON(!page->mapping);
 
 	for (pc = page->pte_chain; pc; pc = next_pc) {
 		next_pc = pc->next;
diff -urN linux-2.4.19-pre3-ac4/mm/slab.c linux/mm/slab.c
--- linux-2.4.19-pre3-ac4/mm/slab.c	Wed Mar 20 18:56:52 2002
+++ linux/mm/slab.c	Wed Mar 20 18:49:51 2002
@@ -666,8 +666,7 @@
 	 * Always checks flags, a caller might be expecting debug
 	 * support which isn't available.
 	 */
-	if (flags & ~CREATE_MASK)
-		BUG();
+	BUG_ON(flags & ~CREATE_MASK);
 
 	/* Get cache's description obj. */
 	cachep = (kmem_cache_t *) kmem_cache_alloc(&cache_cache, SLAB_KERNEL);



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-04-03  3:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-03  3:03 [PATCH] 2.4-ac: BUG_ON (2/2) Robert Love
  -- strict thread matches above, loose matches on Subject: below --
2002-03-21  0:16 Robert Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox