reading xtime in 2.2

From: Ulrich Windl (Ulrich.Windl@rz.uni-regensburg.de)
Date: Tue Jan 11 2000 - 01:12:43 EST


Hello,

I wonder if it should be postulated that xtime should not be read directly by
any subsystem but the time stuff. If someone ever wants to change the kernel
resolution, a lot of sources have to be fixed. Shouldn't do_gettimeofday() be
used instead?

As a matter of fact I have a patch (taken from PPSkit-0.9.0) against 2.2.13 that
changes such occurencies of reading xtime. I'll include this patch. Maybe it can
get into the standard tree...

Regards,
Ulrich

: This patch agains Linux 2.2.13 fixes some time related stuff,
: i.e. it prepares the code for internal changes to `xtime'.
: I'm not perfectly sure that it's allright in all cases, but it seems to
: work for me and for several other people.

Index: linux/drivers/char/joystick/joystick.c
diff -u linux/drivers/char/joystick/joystick.c:1.1.1.1 linux/drivers/char/joystick/joystick.c:1.1.1.1.22.1
--- linux/drivers/char/joystick/joystick.c:1.1.1.1 Thu Dec 3 12:58:12 1998
+++ linux/drivers/char/joystick/joystick.c Mon Dec 20 21:23:39 1999
@@ -148,8 +148,8 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
 static unsigned int js_get_time_system(void)
 {
- static struct timeval js_tv;
- get_fast_time(&js_tv);
+ struct timeval js_tv;
+ do_gettimeofday(&js_tv);
         return js_tv.tv_sec * 1000000L + js_tv.tv_usec;
 }
 #endif
Index: linux/fs/affs/file.c
diff -u linux/fs/affs/file.c:1.1.1.1 linux/fs/affs/file.c:1.1.1.1.22.1
--- linux/fs/affs/file.c:1.1.1.1 Mon Aug 24 22:02:44 1998
+++ linux/fs/affs/file.c Mon Dec 20 21:23:41 1999
@@ -280,7 +280,7 @@
                 }
         }
         kc = NULL;
- tv = xtime;
+ do_gettimeofday(&tv);
         for (i = 0; i < 4; i++) {
                 tkc = &inode->u.affs_i.i_ec->kc[i];
                 if (tkc->kc_lru_time.tv_sec > tv.tv_sec)
@@ -293,7 +293,7 @@
         }
         if (!kc) /* Really shouldn't happen */
                 kc = tkc;
- kc->kc_lru_time = xtime;
+ do_gettimeofday(&kc->kc_lru_time);
         keyp = kc->kc_keys;
         kc->kc_first = block;
         kc->kc_last = -1;
Index: linux/fs/nfsd/nfssvc.c
diff -u linux/fs/nfsd/nfssvc.c:1.1.1.3 linux/fs/nfsd/nfssvc.c:1.1.1.3.16.1
--- linux/fs/nfsd/nfssvc.c:1.1.1.3 Wed Mar 24 20:28:32 1999
+++ linux/fs/nfsd/nfssvc.c Mon Dec 20 21:23:42 1999
@@ -116,7 +116,7 @@
         oldumask = current->fs->umask; /* Set umask to 0. */
         current->fs->umask = 0;
         if (!nfsd_active++) {
- nfssvc_boot = xtime; /* record boot time */
+ do_gettimeofday(&nfssvc_boot); /* record boot time */
                 first = 1;
         }
         lockd_up(); /* start lockd */
Index: linux/net/core/dev.c
diff -u linux/net/core/dev.c:1.1.1.7 linux/net/core/dev.c:1.1.1.7.2.1
--- linux/net/core/dev.c:1.1.1.7 Wed Nov 3 19:41:09 1999
+++ linux/net/core/dev.c Mon Dec 20 21:24:00 1999
@@ -511,7 +511,7 @@
 void dev_queue_xmit_nit(struct sk_buff *skb, struct device *dev)
 {
         struct packet_type *ptype;
- get_fast_time(&skb->stamp);
+ do_gettimeofday(&skb->stamp);
 
         for (ptype = ptype_all; ptype!=NULL; ptype = ptype->next)
         {
@@ -758,9 +758,9 @@
 {
 #ifndef CONFIG_CPU_IS_SLOW
         if(skb->stamp.tv_sec==0)
- get_fast_time(&skb->stamp);
+ do_gettimeofday(&skb->stamp);
 #else
- skb->stamp = xtime;
+ do_gettimeofday(&skb->stamp);
 #endif
 
         /* The code is rearranged so that the path is the most
Index: linux/net/ipv4/ip_forward.c
diff -u linux/net/ipv4/ip_forward.c:1.1.1.2 linux/net/ipv4/ip_forward.c:1.1.1.2.16.1
--- linux/net/ipv4/ip_forward.c:1.1.1.2 Wed Mar 24 20:32:18 1999
+++ linux/net/ipv4/ip_forward.c Mon Dec 20 21:24:01 1999
@@ -97,7 +97,10 @@
 #ifdef CONFIG_CPU_IS_SLOW
         if (net_cpu_congestion > 1 && !(iph->tos&IPTOS_RELIABILITY) &&
             IPTOS_PREC(iph->tos) < IPTOS_PREC_INTERNETCONTROL) {
- if (((xtime.tv_usec&0xF)<<net_cpu_congestion) > 0x1C)
+ /* If this is some random generator to drop packets fairly,
+ * it's fine; otherwise fix it! -- UW
+ */
+ if (((xtime.tv_nsec & 0xF00) << net_cpu_congestion) > 0x1C00)
                         goto drop;
         }
 #endif
Index: linux/net/sunrpc/svcauth_des.c
diff -u linux/net/sunrpc/svcauth_des.c:1.1.1.1 linux/net/sunrpc/svcauth_des.c:1.1.1.1.22.1
--- linux/net/sunrpc/svcauth_des.c:1.1.1.1 Mon Apr 7 20:35:33 1997
+++ linux/net/sunrpc/svcauth_des.c Mon Dec 20 21:24:02 1999
@@ -175,10 +175,10 @@
 #endif
         }
 
- now = xtime;
+ do_gettimeofday(&now); /* now = xtime; need for speed? -- UW */
         now.tv_secs -= data->dc_window;
         if (now.tv_secs < cryptbuf[0] ||
- (now.tv_secs == cryptbuf[0] && now.tv_usec < cryptbuf[1]))
+ (now.tv_secs == cryptbuf[0] && now.tv_usec < cryptbuf[1]))
                 FAIL(rejectedverf);
 
         /* Okay, we're done. Update the lot */

(The last line was manually fixed to be a no-op)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:17 EST