Patchwork boot panic after oops from sysfs_new_dirent

login
register
mail settings
Submitter Tejun Heo
Date Sept. 1, 2009, 7:58 a.m.
Message ID <4A9CD41C.8060604@kernel.org>
Download mbox | patch
Permalink /patch/32727/
State RFC
Delegated to: David Miller
Headers show

Comments

Tejun Heo - Sept. 1, 2009, 7:58 a.m.
Meelis Roos wrote:
>> Ummm.... one more question.  Is cpu0 missing?  Can you please post the
>> output of "cat /proc/cpuinfo"?
> 
> Yes, there's no CPU numbered 0, the numbers come from hardware slots on 
> backplane.

Aha...  Does the following patch fix the problem?
Meelis Roos - Sept. 1, 2009, 11:48 a.m.
> Aha...  Does the following patch fix the problem?

Yes, yesterdays 2.6.31-rc8-git plus this patch seems to work fine, no 
warnings/oopses/panics. It is happily churning on debian unstable 
upgrade now.

Patch

diff --git a/mm/percpu.c b/mm/percpu.c
index 5fe3784..3311c89 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -197,7 +197,12 @@  static unsigned long pcpu_chunk_addr(struct pcpu_chunk *chunk,
 static bool pcpu_chunk_page_occupied(struct pcpu_chunk *chunk,
 				     int page_idx)
 {
-	return *pcpu_chunk_pagep(chunk, 0, page_idx) != NULL;
+	/*
+	 * Any possible cpu id can be used here, so there's no need to
+	 * worry about preemption or cpu hotplug.
+	 */
+	return *pcpu_chunk_pagep(chunk, raw_smp_processor_id(),
+				 page_idx) != NULL;
 }

 /* set the pointer to a chunk in a page struct */
@@ -297,6 +302,14 @@  static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
 		return pcpu_first_chunk;
 	}

+	/*
+	 * The address is relative to unit0 which might be unused and
+	 * thus unmapped.  Offset the address to the unit space of the
+	 * current processor before looking it up in the vmalloc
+	 * space.  Note that any possible cpu id can be used here, so
+	 * there's no need to worry about preemption or cpu hotplug.
+	 */
+	addr += raw_smp_processor_id() * pcpu_unit_size;
 	return pcpu_get_page_chunk(vmalloc_to_page(addr));
 }