Re: 2.6.14-rc4-rt7

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2005-10-26 at 18:52 -0700, john stultz wrote:
> On Wed, 2005-10-26 at 21:37 -0400, Steven Rostedt wrote:
> > On Wed, 2005-10-26 at 18:22 -0700, john stultz wrote:
> > 
> > > 
> > > I don't know if that would really fix it, because ideally you want to
> > > read the prev_mono_time at the same point you calculate the time inside
> > > the read lock'ed critical section.
> > 
> > Ideally yes, but this is just for debugging, so as long as prev is read
> > before now, this should prevent false positives due to ordering.  
> 
> Ah, you're right, good point! I was being overly paranoid.
> 
> So as long as the writing of the 64bit value is atomic (which it isn't,
> but that can be fixed) there shouldn't be ordering problems w/ your
> patch. 

Turning off IRQs should be good enough.

> 
> And sure enough, it seems to take care of the warnings on my box.

So I guess interrupts do call this. :-)

Thanks,

-- Steve

Here's a updated patch.

Index: linux-2.6.14-rc5-rt7/kernel/time/timeofday.c
===================================================================
--- linux-2.6.14-rc5-rt7.orig/kernel/time/timeofday.c	2005-10-26 16:57:03.000000000 -0400
+++ linux-2.6.14-rc5-rt7/kernel/time/timeofday.c	2005-10-26 22:10:32.000000000 -0400
@@ -232,6 +232,12 @@
 	unsigned long seq;
 	ktime_t prev, now;
 	nsec_t mc, prev_st, curr_st;
+	unsigned long flags;
+
+	raw_local_irq_save(flags);
+	prev = per_cpu(prev_mono_time, cpu);
+	prev_st = per_cpu(prev_system_time, cpu);
+	raw_local_irq_restore(flags);
 
 	/* atomically read __get_monotonic_clock_ns() */
 	do {
@@ -242,11 +248,7 @@
 	} while (read_seqretry(&system_time_lock, seq));
 
 	ns_to_timespec(ts, mc);
-
 	now = timespec_to_ktime(*ts);
-	prev = per_cpu(prev_mono_time, cpu);
-
-	prev_st = per_cpu(prev_system_time, cpu);
 	curr_st = system_time;
 
 	if (ktime_cmp(now, <, prev)) {
@@ -264,8 +266,12 @@
 		ktime_to_timespec(ts, prev);
 		return;
 	}
+
+	raw_local_irq_save(flags);
 	per_cpu(prev_mono_time, cpu) = now;
 	per_cpu(prev_system_time, cpu) = system_time;
+	raw_local_irq_restore(flags);
+
 	put_cpu();
 }
 


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux