The patch titled
new TSC-based delay_tsc()
has been added to the -mm tree. Its filename is
new-tsc-based-delay_tsc.patch
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this
------------------------------------------------------
Subject: new TSC-based delay_tsc()
From: Marin Mitov <[EMAIL PROTECTED]>
A patch based on Ingo's idea/patch to track delay_tsc() migration to
another cpu by comparing smp_processor_id().
What is different:
1. Using unsigned (instead of long) to unify for i386/x86_64.
2. Minimal preempt_disable/enable() critical sections
(more room for preemption)
3. some statements have been rearranged, to account for
possible under/overflow of left/TSC
Signed-off-by: Marin Mitov <[EMAIL PROTECTED]>
Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
Cc: Thomas Gleixner <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---
arch/x86/lib/delay_32.c | 35 +++++++++++++++++++++++++++++------
arch/x86/lib/delay_64.c | 36 ++++++++++++++++++++++++++++++------
2 files changed, 59 insertions(+), 12 deletions(-)
diff -puN arch/x86/lib/delay_32.c~new-tsc-based-delay_tsc
arch/x86/lib/delay_32.c
--- a/arch/x86/lib/delay_32.c~new-tsc-based-delay_tsc
+++ a/arch/x86/lib/delay_32.c
@@ -38,18 +38,41 @@ static void delay_loop(unsigned long loo
:"0" (loops));
}
-/* TSC based delay: */
+/* TSC based delay:
+ *
+ * We are careful about preemption as TSC's are per-CPU.
+ */
static void delay_tsc(unsigned long loops)
{
- unsigned long bclock, now;
+ unsigned prev, now;
+ unsigned left = loops;
+ unsigned prev_cpu, cpu;
+
+ preempt_disable();
+ rdtscl(prev);
+ prev_cpu = smp_processor_id();
+ preempt_enable();
+ now = prev;
- preempt_disable(); /* TSC's are per-cpu */
- rdtscl(bclock);
do {
rep_nop();
+
+ left -= now - prev;
+ prev = now;
+
+ preempt_disable();
rdtscl(now);
- } while ((now-bclock) < loops);
- preempt_enable();
+ cpu = smp_processor_id();
+ preempt_enable();
+
+ if (prev_cpu != cpu){
+ /*
+ * We have migrated, we skip this small amount of time:
+ */
+ prev = now;
+ prev_cpu = cpu;
+ }
+ } while ((now-prev) < left);
}
/*
diff -puN arch/x86/lib/delay_64.c~new-tsc-based-delay_tsc
arch/x86/lib/delay_64.c
--- a/arch/x86/lib/delay_64.c~new-tsc-based-delay_tsc
+++ a/arch/x86/lib/delay_64.c
@@ -26,18 +26,42 @@ int read_current_timer(unsigned long *ti
return 0;
}
+/* TSC based delay:
+ *
+ * We are careful about preemption as TSC's are per-CPU.
+ */
void __delay(unsigned long loops)
{
- unsigned bclock, now;
+ unsigned prev, now;
+ unsigned left = loops;
+ unsigned prev_cpu, cpu;
+
+ preempt_disable();
+ rdtscl(prev);
+ prev_cpu = smp_processor_id();
+ preempt_enable();
+ now = prev;
- preempt_disable(); /* TSC's are pre-cpu */
- rdtscl(bclock);
do {
- rep_nop();
+ rep_nop();
+
+ left -= now - prev;
+ prev = now;
+
+ preempt_disable();
rdtscl(now);
+ cpu = smp_processor_id();
+ preempt_enable();
+
+ if (prev_cpu != cpu){
+ /*
+ * We have migrated, we skip this small amount of time:
+ */
+ prev = now;
+ prev_cpu = cpu;
+ }
}
- while ((now-bclock) < loops);
- preempt_enable();
+ while ((now-prev) < left);
}
EXPORT_SYMBOL(__delay);
_
Patches currently in -mm which might be from [EMAIL PROTECTED] are
new-tsc-based-delay_tsc.patch
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html