Skip to contentSkip to conversation

PREEMPT BUG: using smp_processor_id() in preemptible

PATCH [email protected] 1 participant 1 message Jun 17, 2009 MIPS

lore
Share & tools
lore
#0 lore raw

Ralf,

We saw the using smp_processor_id() in preemptible and thought this my be a good correction.

mips/include/asm/r4kcache.h renamed from mips/include/asm/r4kcache.h_org +18 -12
@@ -344,14 +344,17 @@
 static inline void blast_##pfx##cache##lsize(void)			\
 {									\
 	unsigned long start = INDEX_BASE;				\
-	unsigned long end = start + current_cpu_data.desc.waysize;	\
-	unsigned long ws_inc = 1UL << current_cpu_data.desc.waybit;	\
-	unsigned long ws_end = current_cpu_data.desc.ways <<		\
-	                       current_cpu_data.desc.waybit;		\
-	unsigned long ws, addr;						\
+	unsigned long end, ws_inc, ws_end, ws, addr;			\
 									\
 	__##pfx##flush_prologue						\
 									\
+	preempt_disable();						\
+	end = start + current_cpu_data.desc.waysize;			\
+	ws_inc = 1UL << current_cpu_data.desc.waybit;			\
+	ws_end = current_cpu_data.desc.ways <<				\
+			current_cpu_data.desc.waybit;			\
+	preempt_enable();						\
+									\
 	for (ws = 0; ws < ws_end; ws += ws_inc)				\
 		for (addr = start; addr < end; addr += lsize * 32)	\
 			cache##lsize##_unroll32(addr|ws, indexop);	\
@@ -376,16 +379,19 @@
 									\
 static inline void blast_##pfx##cache##lsize##_page_indexed(unsigned long page) \
 {									\
-	unsigned long indexmask = current_cpu_data.desc.waysize - 1;	\
-	unsigned long start = INDEX_BASE + (page & indexmask);		\
-	unsigned long end = start + PAGE_SIZE;				\
-	unsigned long ws_inc = 1UL << current_cpu_data.desc.waybit;	\
-	unsigned long ws_end = current_cpu_data.desc.ways <<		\
-	                       current_cpu_data.desc.waybit;		\
-	unsigned long ws, addr;						\
+	unsigned long indexmask, ws_inc, ws_end, ws, addr, start, end;	\
 									\
 	__##pfx##flush_prologue						\
 									\
+	preempt_disable();						\
+	indexmask = current_cpu_data.desc.waysize - 1;			\
+	start = INDEX_BASE + (page & indexmask);			\
+	end = start + PAGE_SIZE;					\
+	ws_inc = 1UL << current_cpu_data.desc.waybit;			\
+	ws_end = current_cpu_data.desc.ways <<				\
+			current_cpu_data.desc.waybit;			\
+	preempt_enable();						\
+									\
 	for (ws = 0; ws < ws_end; ws += ws_inc)				\
 		for (addr = start; addr < end; addr += lsize * 32)	\
 			cache##lsize##_unroll32(addr|ws, indexop);	\