lkml.org 
[lkml]   [2004]   [Jul]   [12]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateMon, 12 Jul 2004 01:47:48 -0700
FromWilliam Lee Irwin III <>
SubjectRe: [PATCH] Instrumenting high latency
On Mon, Jul 12, 2004 at 10:29:40AM +0200, Arjan van de Ven wrote:
>> ... or reset the time(r) in need_resched() under the assumption that all
>> need_resched() callers will yield when it returns true...

On Mon, Jul 12, 2004 at 01:42:31AM -0700, William Lee Irwin III wrote:
> Might be a good enough approximation. Two examples and a counterexample...


Index: timing-2.6.7/include/linux/sched.h
===================================================================
--- timing-2.6.7.orig/include/linux/sched.h	2004-06-15 22:18:57.000000000 -0700
+++ timing-2.6.7/include/linux/sched.h	2004-07-12 01:45:08.000000000 -0700
@@ -1000,7 +1000,8 @@
 	return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
 }
   
-static inline int need_resched(void)
+#define need_resched()	({ touch_preempt_timing(); __need_resched(); })
+static inline int __need_resched(void)
 {
 	return unlikely(test_thread_flag(TIF_NEED_RESCHED));
 }
Index: timing-2.6.7/include/linux/preempt.h
===================================================================
--- timing-2.6.7.orig/include/linux/preempt.h	2004-07-11 04:33:55.000000000 -0700
+++ timing-2.6.7/include/linux/preempt.h	2004-07-12 01:18:17.000000000 -0700
@@ -12,7 +12,9 @@
 #ifdef CONFIG_PREEMPT_TIMING
 void __inc_preempt_count(void);
 void __dec_preempt_count(void);
+void touch_preempt_timing(void);
 #else
+#define touch_preempt_timing()	do { } while (0)
 #ifdef CONFIG_PREEMPT
 #define __inc_preempt_count()	do { preempt_count()++; } while (0)
 #define __dec_preempt_count()	do { preempt_count()--; } while (0)
Index: timing-2.6.7/arch/i386/kernel/traps.c
===================================================================
--- timing-2.6.7.orig/arch/i386/kernel/traps.c	2004-07-12 00:10:27.000000000 -0700
+++ timing-2.6.7/arch/i386/kernel/traps.c	2004-07-12 01:34:58.000000000 -0700
@@ -969,14 +969,24 @@
 }
 __setup("preempt_thresh=", setup_preempt_thresh);
 
+static void __touch_preempt_timing(void *addr)
+{
+	rdtscll(__get_cpu_var(preempt_timings));
+	__get_cpu_var(preempt_entry) = (unsigned long)addr;
+}
+
+void touch_preempt_timing(void)
+{
+	if (preempt_count() == 1 && system_state == SYSTEM_RUNNING)
+		__touch_preempt_timing(__builtin_return_address(0));
+}
+EXPORT_SYMBOL(touch_preempt_timing);
+
 void __inc_preempt_count(void)
 {
 	preempt_count()++;
-	if (preempt_count() == 1 && system_state == SYSTEM_RUNNING) {
-		rdtscll(__get_cpu_var(preempt_timings));
-		__get_cpu_var(preempt_entry)
-				= (unsigned long)__builtin_return_address(0);
-	}
+	if (preempt_count() == 1 && system_state == SYSTEM_RUNNING)
+		__touch_preempt_timing(__builtin_return_address(0));
 }
 EXPORT_SYMBOL(__inc_preempt_count);
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:04    [from the cache]
©2003-2008