public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6] Fix sys_time() to get subtick correction from the new xtim
@ 2004-03-22 12:16 La Monte H.P. Yarroll
  2004-04-02 20:48 ` Pavel Machek
  0 siblings, 1 reply; 2+ messages in thread
From: La Monte H.P. Yarroll @ 2004-03-22 12:16 UTC (permalink / raw)
  To: kernel list

This is a Scott Wood patch against 2.6.3.  He's shy, so I'm volunteering 
to represent him in
public :-).  The Change number and BUG number are TimeSys internal 
references.

Change 22531 by scott@scott-50 on 2004/01/22 15:30:22

        Use gettimeofday() rather than xtime.tv_sec in sys_time(),
        since sys_stime() uses settimeofday() and thus subtracts
        the subtick correction from the new xtime.
       
        Fixes BUG05331 Command line LTP test stime01 fails.

      stime() used settimeofday(), but time() did not use 
gettimeofday().  Since
      settimeofday() subtracts out the current intra-tick correction, 
and nsec
      was 0 (since stime() only allows seconds), this resulted in xtime 
being
      slightly earlier than the time that was set.  If time() had used 
gettimeofday(),
      the correction would have been applied, and everything would be fine.
      However, instead time just reads the current xtime.tv_sec, so if 
time() is
      called immediately after stime(), you'll usually get a value one 
second earlier.


diff -puN kernel/arch/ia64/ia32/sys_ia32.c~fix-all-time-sys_time 
kernel/arch/ia64/ia32/sys_ia32.c
--- lkml/arch/ia64/ia32/sys_ia32.c~fix-all-time-sys_time        
2004-03-16 10:01:23.000000000 -0500
+++ lkml-piggy/arch/ia64/ia32/sys_ia32.c        2004-03-16 
10:01:23.000000000 -0500
@@ -1678,10 +1678,11 @@ asmlinkage long
 sys32_time (int *tloc)
 {
        int i;
+       struct timeval tv;
+
+       do_gettimeofday(&tv);
+       i = tv.tv_sec;

-       /* SMP: This is fairly trivial. We grab CURRENT_TIME and
-          stuff it to user space. No side effects */
-       i = get_seconds();
        if (tloc) {
                if (put_user(i, tloc))
                        i = -EFAULT;
diff -puN -L kernel/arch/ia64/ia32/sys_ia32.c-orig /dev/null /dev/null
diff -puN kernel/arch/parisc/kernel/sys_parisc32.c~fix-all-time-sys_time 
kernel/arch/parisc/kernel/sys_parisc32.c
--- lkml/arch/parisc/kernel/sys_parisc32.c~fix-all-time-sys_time        
2004-03-16 10:01:23.000000000 -0500
+++ lkml-piggy/arch/parisc/kernel/sys_parisc32.c        2004-03-16 
10:01:23.000000000 -0500
@@ -388,14 +388,16 @@ static inline long get_ts32(struct times

 asmlinkage long sys32_time(compat_time_t *tloc)
 {
-    time_t now = get_seconds();
-    compat_time_t now32 = now;
+       struct timeval tv;

-    if (tloc)
-       if (put_user(now32, tloc))
-               now32 = -EFAULT;
+       do_gettimeofday(&tv);
+       compat_time_t now32 = tv.tv_sec;

-    return now32;
+       if (tloc)
+               if (put_user(now32, tloc))
+                       now32 = -EFAULT;
+
+       return now32;
 }

 asmlinkage int
diff -puN -L kernel/arch/parisc/kernel/sys_parisc32.c-orig /dev/null 
/dev/null
diff -puN kernel/arch/x86_64/ia32/sys_ia32.c~fix-all-time-sys_time 
kernel/arch/x86_64/ia32/sys_ia32.c
--- lkml/arch/x86_64/ia32/sys_ia32.c~fix-all-time-sys_time      
2004-03-16 10:01:23.000000000 -0500
+++ lkml-piggy/arch/x86_64/ia32/sys_ia32.c      2004-03-16 
10:01:23.000000000 -0500
@@ -833,10 +833,11 @@ sys32_writev(int fd, struct compat_iovec
 asmlinkage long sys32_time(int * tloc)
 {
        int i;
+       struct timeval tv;
+
+       do_gettimeofday(&tv);
+       i = tv.tv_sec;

-       /* SMP: This is fairly trivial. We grab CURRENT_TIME and
-          stuff it to user space. No side effects */
-       i = get_seconds();
        if (tloc) {
                if (put_user(i,tloc))
                        i = -EFAULT;
diff -puN -L kernel/arch/x86_64/ia32/sys_ia32.c-orig /dev/null /dev/null
diff -puN kernel/kernel/time.c~fix-all-time-sys_time kernel/kernel/time.c
--- lkml/kernel/time.c~fix-all-time-sys_time    2004-03-16 
10:01:23.000000000 -0500
+++ lkml-piggy/kernel/time.c    2004-03-16 10:01:23.000000000 -0500
@@ -51,10 +51,11 @@ EXPORT_SYMBOL(sys_tz);
 asmlinkage long sys_time(int * tloc)
 {
        int i;
+       struct timeval tv;
+
+       do_gettimeofday(&tv);
+       i = tv.tv_sec;

-       /* SMP: This is fairly trivial. We grab CURRENT_TIME and
-          stuff it to user space. No side effects */
-       i = get_seconds();
        if (tloc) {
                if (put_user(i,tloc))
                        i = -EFAULT;
diff -puN -L kernel/kernel/time.c-orig /dev/null /dev/null

_

-- 
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell's sig


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2.6] Fix sys_time() to get subtick correction from the new xtim
  2004-03-22 12:16 [PATCH 2.6] Fix sys_time() to get subtick correction from the new xtim La Monte H.P. Yarroll
@ 2004-04-02 20:48 ` Pavel Machek
  0 siblings, 0 replies; 2+ messages in thread
From: Pavel Machek @ 2004-04-02 20:48 UTC (permalink / raw)
  To: La Monte H.P. Yarroll; +Cc: kernel list

Hi!


> --- lkml/arch/ia64/ia32/sys_ia32.c~fix-all-time-sys_time        
> 2004-03-16 10:01:23.000000000 -0500
> +++ lkml-piggy/arch/ia64/ia32/sys_ia32.c        2004-03-16 
> 10:01:23.000000000 -0500
> @@ -1678,10 +1678,11 @@ asmlinkage long
> sys32_time (int *tloc)
> {
>        int i;
> +       struct timeval tv;
> +
> +       do_gettimeofday(&tv);
> +       i = tv.tv_sec;
> 
> -       /* SMP: This is fairly trivial. We grab CURRENT_TIME and
> -          stuff it to user space. No side effects */
> -       i = get_seconds();
>        if (tloc) {
>                if (put_user(i, tloc))
>                        i = -EFAULT;

This patch likely suffered some whitespace damage, and you probably
want to correct tabs vs. spacing in indentation.
								Pavel

-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-02 21:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-22 12:16 [PATCH 2.6] Fix sys_time() to get subtick correction from the new xtim La Monte H.P. Yarroll
2004-04-02 20:48 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox