* [PATCH] preempt-safe load_LDT
@ 2002-07-20 20:21 Robert Love
2002-07-20 20:42 ` Linus Torvalds
0 siblings, 1 reply; 3+ messages in thread
From: Robert Love @ 2002-07-20 20:21 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel, mingo
Linus,
Attached patch makes load_LDT preempt-safe per our off-list discussion.
Header dependencies prevent use of the get_cpu()/put_cpu() methods so we
explicitly call disable/enable.
This is Ingo Molnar's version of the patch: I like how he broke up
load_LDT into two versions better.
Patch is against 2.5.27, please apply.
Robert Love
diff -urN linux-2.5.27/include/asm-i386/desc.h linux/include/asm-i386/desc.h
--- linux-2.5.27/include/asm-i386/desc.h Sat Jul 20 12:11:03 2002
+++ linux/include/asm-i386/desc.h Sat Jul 20 12:48:15 2002
@@ -90,9 +90,8 @@
/*
* load one particular LDT into the current CPU
*/
-static inline void load_LDT (mm_context_t *pc)
+static inline void load_LDT_no_preempt(mm_context_t *pc, int cpu)
{
- int cpu = smp_processor_id();
void *segments = pc->ldt;
int count = pc->size;
@@ -104,6 +103,14 @@
set_ldt_desc(cpu, segments, count);
__load_LDT(cpu);
}
+static inline void load_LDT(mm_context_t *pc)
+{
+ int cpu = smp_processor_id();
+
+ preempt_disable();
+ load_LDT_no_preempt(pc, cpu);
+ preempt_enable();
+}
#endif /* !__ASSEMBLY__ */
diff -urN linux-2.5.27/include/asm-i386/mmu_context.h linux/include/asm-i386/mmu_context.h
--- linux-2.5.27/include/asm-i386/mmu_context.h Sat Jul 20 12:11:04 2002
+++ linux/include/asm-i386/mmu_context.h Sat Jul 20 12:48:15 2002
@@ -44,7 +44,7 @@
* has a non-default LDT.
*/
if (next->context.size+prev->context.size)
- load_LDT(&next->context);
+ load_LDT_no_preempt(&next->context, cpu);
}
#ifdef CONFIG_SMP
else {
@@ -56,7 +56,7 @@
* tlb flush IPI delivery. We must reload %cr3.
*/
load_cr3(next->pgd);
- load_LDT(&next->context);
+ load_LDT_no_preempt(&next->context, cpu);
}
}
#endif
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] preempt-safe load_LDT
2002-07-20 20:21 [PATCH] preempt-safe load_LDT Robert Love
@ 2002-07-20 20:42 ` Linus Torvalds
2002-07-20 20:51 ` Ingo Molnar
0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2002-07-20 20:42 UTC (permalink / raw)
To: Robert Love; +Cc: linux-kernel, mingo
On 20 Jul 2002, Robert Love wrote:
>
> Attached patch makes load_LDT preempt-safe per our off-list discussion.
It's buggy. It calls smp_processor_id() outside the preemption window, see
"load_LDT()".
I'd suggest making it use get/put_cpu() and to avoid the header file
dependencies moving it away from desc.h and into ldt.c instead.
Linus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] preempt-safe load_LDT
2002-07-20 20:42 ` Linus Torvalds
@ 2002-07-20 20:51 ` Ingo Molnar
0 siblings, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2002-07-20 20:51 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Robert Love, linux-kernel
On Sat, 20 Jul 2002, Linus Torvalds wrote:
> It's buggy. It calls smp_processor_id() outside the preemption window,
> see "load_LDT()".
oops. Correct patch that uses get_cpu()/put_cpu() is attached, against
2.5.27. I was wrong when sending the initial fix: there are no header file
dependency issues in 2.5.27 anymore. It compiles & boots.
Ingo
--- linux/include/asm-i386/mmu_context.h.orig Sun Jun 9 07:26:26 2002
+++ linux/include/asm-i386/mmu_context.h Sat Jul 20 22:48:37 2002
@@ -44,7 +44,7 @@
* has a non-default LDT.
*/
if (next->context.size+prev->context.size)
- load_LDT(&next->context);
+ load_LDT_no_preempt(&next->context, cpu);
}
#ifdef CONFIG_SMP
else {
@@ -56,7 +56,7 @@
* tlb flush IPI delivery. We must reload %cr3.
*/
load_cr3(next->pgd);
- load_LDT(&next->context);
+ load_LDT_no_preempt(&next->context, cpu);
}
}
#endif
--- linux/include/asm-i386/desc.h.orig Sun Jun 9 07:26:24 2002
+++ linux/include/asm-i386/desc.h Sat Jul 20 22:49:04 2002
@@ -90,9 +90,8 @@
/*
* load one particular LDT into the current CPU
*/
-static inline void load_LDT (mm_context_t *pc)
+static inline void load_LDT_no_preempt (mm_context_t *pc, int cpu)
{
- int cpu = smp_processor_id();
void *segments = pc->ldt;
int count = pc->size;
@@ -103,6 +102,13 @@
set_ldt_desc(cpu, segments, count);
__load_LDT(cpu);
+}
+static inline void load_LDT (mm_context_t *pc)
+{
+ int cpu = get_cpu();
+
+ load_LDT_no_preempt(pc, cpu);
+ put_cpu();
}
#endif /* !__ASSEMBLY__ */
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-07-20 20:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-20 20:21 [PATCH] preempt-safe load_LDT Robert Love
2002-07-20 20:42 ` Linus Torvalds
2002-07-20 20:51 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®