public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: marcelo@conectiva.com.br
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] 2.4: BUG_ON (2/2)
Date: 02 Apr 2002 22:03:11 -0500	[thread overview]
Message-ID: <1017802992.2940.602.camel@phantasy> (raw)

Marcelo,

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. ;)

Patch is against 2.4.19-pre5, please apply.

	Robert Love

diff -urN linux-2.4.19-pre5/arch/i386/kernel/smp.c linux/arch/i386/kernel/smp.c
--- linux-2.4.19-pre5/arch/i386/kernel/smp.c	Sat Mar 30 18:27:32 2002
+++ linux/arch/i386/kernel/smp.c	Sat Mar 30 18:34:07 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-pre5/kernel/exit.c linux/kernel/exit.c
--- linux-2.4.19-pre5/kernel/exit.c	Sat Mar 30 18:26:41 2002
+++ linux/kernel/exit.c	Sat Mar 30 18:34:07 2002
@@ -316,7 +316,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-pre5/kernel/fork.c linux/kernel/fork.c
--- linux-2.4.19-pre5/kernel/fork.c	Sat Mar 30 18:26:41 2002
+++ linux/kernel/fork.c	Sat Mar 30 18:34:07 2002
@@ -251,7 +251,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-pre5/kernel/sched.c linux/kernel/sched.c
--- linux-2.4.19-pre5/kernel/sched.c	Sat Mar 30 18:26:41 2002
+++ linux/kernel/sched.c	Sat Mar 30 18:34:07 2002
@@ -556,7 +556,7 @@
 
 	spin_lock_prefetch(&runqueue_lock);
 
-	if (!current->active_mm) BUG();
+	BUG_ON(!current->active_mm);
 need_resched_back:
 	prev = current;
 	this_cpu = prev->processor;
@@ -675,12 +675,12 @@
 		struct mm_struct *mm = next->mm;
 		struct mm_struct *oldmm = prev->active_mm;
 		if (!mm) {
-			if (next->active_mm) BUG();
+			BUG_ON(next->active_mm);
 			next->active_mm = oldmm;
 			atomic_inc(&oldmm->mm_count);
 			enter_lazy_tlb(oldmm, next, this_cpu);
 		} else {
-			if (next->active_mm != mm) BUG();
+			BUG_ON(next->active_mm != mm);
 			switch_mm(oldmm, mm, next, this_cpu);
 		}
 
diff -urN linux-2.4.19-pre5/mm/slab.c linux/mm/slab.c
--- linux-2.4.19-pre5/mm/slab.c	Sat Mar 30 18:26:41 2002
+++ linux/mm/slab.c	Sat Mar 30 18:34:07 2002
@@ -665,8 +665,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);
diff -urN linux-2.4.19-pre5/mm/vmscan.c linux/mm/vmscan.c
--- linux-2.4.19-pre5/mm/vmscan.c	Sat Mar 30 18:26:41 2002
+++ linux/mm/vmscan.c	Sat Mar 30 18:34:07 2002
@@ -233,8 +233,7 @@
 	pgdir = pgd_offset(mm, address);
 
 	end = vma->vm_end;
-	if (address >= end)
-		BUG();
+	BUG_ON(address >= end);
 	do {
 		count = swap_out_pgd(mm, vma, pgdir, address, end, count, classzone);
 		if (!count)
@@ -353,10 +352,8 @@
 
 		page = list_entry(entry, struct page, lru);
 
-		if (unlikely(!PageLRU(page)))
-			BUG();
-		if (unlikely(PageActive(page)))
-			BUG();
+		BUG_ON(!PageLRU(page));
+		BUG_ON(PageActive(page));
 
 		list_del(entry);
 		list_add(entry, &inactive_list);




             reply	other threads:[~2002-04-03  3:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-03  3:03 Robert Love [this message]
2002-04-03 23:09 ` [PATCH] 2.4: BOOTPC /proc info Craig
2002-04-03 23:51   ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2002-03-21  0:16 [PATCH] 2.4: BUG_ON (2/2) Robert Love
2002-03-21  0:40 ` Alan Cox
2002-03-21  0:52   ` Robert Love

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1017802992.2940.602.camel@phantasy \
    --to=rml@tech9.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox