Skip to contentSkip to conversation

for "BUG: using smp_processor_id() in preemptible" in 2.6.17.rc6.mm2

PATCH New srinivasa 1 participant 1 message Jun 21, 2006 MM core

lore
Share & tools
lore

srinivasa

author
#0 lore raw

PATCH 1/1 for "BUG: using smp_processor_id() in preemptible" in 2.6.17.rc6.mm2

Hi all
I saw a stack trace while booting the 2.6.17-rc6-mm2 kernel. Which looks
like this

BUG: using smp_processor_id() in preemptible [00000001] code: init/1
caller is __handle_mm_fault+0x22/0x248
 [<c010334c>] show_trace+0x27/0x29
 [<c0103486>] dump_stack+0x26/0x28
 [<c02e4d6f>] debug_smp_processor_id+0x9f/0xb0
 [<c0157a98>] __handle_mm_fault+0x22/0x248
 [<c01140b2>] do_page_fault+0x17e/0x605
 [<c01030b9>] error_code+0x39/0x40
 [<c0198eef>] padzero+0x2c/0x37
 [<c0199ff5>] load_elf_binary+0x6e2/0xcfc
 [<c0174e14>] search_binary_handler+0x96/0x201
 [<c017510e>] do_execve+0x18f/0x243
 [<c010152b>] sys_execve+0x3c/0x81
 [<c04a9c93>] syscall_call+0x7/0xb

Cause for the bug is a set of functions count_vm_event(),
count_vm_events() and get_cpu_vm_events() calling smp_processor_id() in preemptible context without disabling irq's

So I developed patch for this problem,attaching the patch here

include/linux/page-flags.h +11 -1
diff -Naurp linux-orig/include/linux/page-flags.h linux-mod/include/linux/page-flags.h
@@ -141,17 +141,27 @@ DECLARE_PER_CPU(struct vm_event_state, v
 
 static inline unsigned long get_cpu_vm_events(enum vm_event_item item)
 {
-	return __get_cpu_var(vm_event_states).event[item];
+	unsigned long flags, res;
+	local_irq_save(flags); 
+	res = __get_cpu_var(vm_event_states).event[item];
+	local_irq_restore(flags);
+	return res;
 }
 
 static inline void count_vm_event(enum vm_event_item item)
 {
+	unsigned long flags;
+	local_irq_save(flags);
 	__get_cpu_var(vm_event_states).event[item]++;
+	local_irq_restore(flags);
 }
 
 static inline void count_vm_events(enum vm_event_item item, long delta)
 {
+	unsigned long flags;
+	local_irq_save(flags);
 	__get_cpu_var(vm_event_states).event[item] += delta;
+	local_irq_restore(flags);
 }
 
 extern void all_vm_events(unsigned long *);