]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Cleanup non-arch xtime uses, use get_seconds() or current_kernel_time().
authorjohn stultz <johnstul@us.ibm.com>
Wed, 25 Jul 2007 00:47:43 +0000 (17:47 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 25 Jul 2007 17:09:20 +0000 (10:09 -0700)
This avoids use of the kernel-internal "xtime" variable directly outside
of the actual time-related functions.  Instead, use the helper functions
that we already have available to us.

This doesn't actually change any behaviour, but this will allow us to
fix the fact that "xtime" isn't updated very often with CONFIG_NO_HZ
(because much of the realtime information is maintained as separate
offsets to 'xtime'), which has caused interfaces that use xtime directly
to get a time that is out of sync with the real-time clock by up to a
third of a second or so.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 files changed:
drivers/rtc/class.c
drivers/s390/net/ctcmain.c
drivers/s390/net/netiucv.c
include/linux/time.h
kernel/acct.c
kernel/hrtimer.c
kernel/time.c
kernel/time/timekeeping.c
kernel/tsacct.c
net/rxrpc/af_rxrpc.c
net/rxrpc/ar-connection.c
net/rxrpc/ar-transport.c
net/rxrpc/rxkad.c

index 8b3cd31d6a61898ae892539e84d7d3b8ebca6d39..10ab3b71ffc621694c509a4bc7582ef9468ccc54 100644 (file)
@@ -46,6 +46,7 @@ static int rtc_suspend(struct device *dev, pm_message_t mesg)
 {
        struct rtc_device       *rtc = to_rtc_device(dev);
        struct rtc_time         tm;
+       struct timespec         ts = current_kernel_time();
 
        if (strncmp(rtc->dev.bus_id,
                                CONFIG_RTC_HCTOSYS_DEVICE,
@@ -57,8 +58,8 @@ static int rtc_suspend(struct device *dev, pm_message_t mesg)
 
        /* RTC precision is 1 second; adjust delta for avg 1/2 sec err */
        set_normalized_timespec(&delta,
-                               xtime.tv_sec - oldtime,
-                               xtime.tv_nsec - (NSEC_PER_SEC >> 1));
+                               ts.tv_sec - oldtime,
+                               ts.tv_nsec - (NSEC_PER_SEC >> 1));
 
        return 0;
 }
index b20fd068173388759e7d501c03102d3395ffc9a9..92e8a37b50220f85517bc5367667f1db526f653c 100644 (file)
@@ -674,7 +674,7 @@ ch_action_txdone(fsm_instance * fi, int event, void *arg)
        int first = 1;
        int i;
        unsigned long duration;
-       struct timespec done_stamp = xtime;
+       struct timespec done_stamp = current_kernel_time();
 
        DBF_TEXT(trace, 4, __FUNCTION__);
 
@@ -730,7 +730,7 @@ ch_action_txdone(fsm_instance * fi, int event, void *arg)
                spin_unlock(&ch->collect_lock);
                ch->ccw[1].count = ch->trans_skb->len;
                fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch);
-               ch->prof.send_stamp = xtime;
+               ch->prof.send_stamp = current_kernel_time();
                rc = ccw_device_start(ch->cdev, &ch->ccw[0],
                                      (unsigned long) ch, 0xff, 0);
                ch->prof.doios_multi++;
@@ -2281,7 +2281,7 @@ transmit_skb(struct channel *ch, struct sk_buff *skb)
                fsm_newstate(ch->fsm, CH_STATE_TX);
                fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch);
                spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
-               ch->prof.send_stamp = xtime;
+               ch->prof.send_stamp = current_kernel_time();
                rc = ccw_device_start(ch->cdev, &ch->ccw[ccw_idx],
                                      (unsigned long) ch, 0xff, 0);
                spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
index 3d28e1a5bf799ea0369afeec25405e594dfd21e4..2688894743396c429196bfdd93e6c4e0d3d06498 100644 (file)
@@ -753,7 +753,7 @@ static void conn_action_txdone(fsm_instance *fi, int event, void *arg)
 
        header.next = 0;
        memcpy(skb_put(conn->tx_buff, NETIUCV_HDRLEN), &header, NETIUCV_HDRLEN);
-       conn->prof.send_stamp = xtime;
+       conn->prof.send_stamp = current_kernel_time();
        txmsg.class = 0;
        txmsg.tag = 0;
        rc = iucv_message_send(conn->path, &txmsg, 0, 0,
@@ -1185,7 +1185,7 @@ static int netiucv_transmit_skb(struct iucv_connection *conn,
                memcpy(skb_put(nskb, NETIUCV_HDRLEN), &header,  NETIUCV_HDRLEN);
 
                fsm_newstate(conn->fsm, CONN_STATE_TX);
-               conn->prof.send_stamp = xtime;
+               conn->prof.send_stamp = current_kernel_time();
 
                msg.tag = 1;
                msg.class = 0;
index e6aea5146e5d9a15acb5dc9f6e0216cfe26cb8d8..71181df8b744b0f450ae2f73895e70f514bef390 100644 (file)
@@ -107,7 +107,7 @@ static inline unsigned long get_seconds(void)
 struct timespec current_kernel_time(void);
 
 #define CURRENT_TIME           (current_kernel_time())
-#define CURRENT_TIME_SEC       ((struct timespec) { xtime.tv_sec, 0 })
+#define CURRENT_TIME_SEC       ((struct timespec) { get_seconds(), 0 })
 
 extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday(struct timespec *tv);
index 70d0d88e55541821ff0fd9561e30fcae12e49e17..24f0f8b2ba724567861b6b8983b554f8f0473b90 100644 (file)
@@ -468,7 +468,7 @@ static void do_acct_process(struct file *file)
        }
 #endif
        do_div(elapsed, AHZ);
-       ac.ac_btime = xtime.tv_sec - elapsed;
+       ac.ac_btime = get_seconds() - elapsed;
        /* we really need to bite the bullet and change layout */
        ac.ac_uid = current->uid;
        ac.ac_gid = current->gid;
index eb1ddebd2c0413bbcc3c857aa568ac31150c35c0..a7bb05e6cb634e77749401b7f326e5e8db903394 100644 (file)
@@ -144,7 +144,7 @@ static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
 #ifdef CONFIG_NO_HZ
                getnstimeofday(&xts);
 #else
-               xts = xtime;
+               xts = current_kernel_time();
 #endif
                tom = wall_to_monotonic;
        } while (read_seqretry(&xtime_lock, seq));
index 5b81da08bbdb48d9bb452784298a4e0c480664fb..2289a8d68314f35f3c6b10f7edf8e53b721b8857 100644 (file)
@@ -215,22 +215,6 @@ asmlinkage long sys_adjtimex(struct timex __user *txc_p)
        return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
 }
 
-inline struct timespec current_kernel_time(void)
-{
-        struct timespec now;
-        unsigned long seq;
-
-       do {
-               seq = read_seqbegin(&xtime_lock);
-               
-               now = xtime;
-       } while (read_seqretry(&xtime_lock, seq));
-
-       return now; 
-}
-
-EXPORT_SYMBOL(current_kernel_time);
-
 /**
  * current_fs_time - Return FS time
  * @sb: Superblock.
index 88c81026e0039ae8cf16e3da6b1de223d3c96312..07a3f1420c27fa06fedf7d18e7a33e7b99aa2c03 100644 (file)
@@ -509,3 +509,19 @@ void monotonic_to_bootbased(struct timespec *ts)
 {
        ts->tv_sec += total_sleep_time;
 }
+
+struct timespec current_kernel_time(void)
+{
+       struct timespec now;
+       unsigned long seq;
+
+       do {
+               seq = read_seqbegin(&xtime_lock);
+
+               now = xtime;
+       } while (read_seqretry(&xtime_lock, seq));
+
+       return now;
+}
+
+EXPORT_SYMBOL(current_kernel_time);
index 658f638c402c48fbb307b1a8242c6dfe16d9a1ac..c122131a122f54121f239ece78f830efbaf90d69 100644 (file)
@@ -39,7 +39,7 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
        ac_etime = timespec_to_ns(&ts);
        do_div(ac_etime, NSEC_PER_USEC);
        stats->ac_etime = ac_etime;
-       stats->ac_btime = xtime.tv_sec - ts.tv_sec;
+       stats->ac_btime = get_seconds() - ts.tv_sec;
        if (thread_group_leader(tsk)) {
                stats->ac_exitcode = tsk->exit_code;
                if (tsk->flags & PF_FORKNOEXEC)
index 16a68df4e36b9a8ba8c4e44ceb65f39c3bfb1fe6..c58fa0d1be26b7cea959ae4e00d8a4bbfe2bde0e 100644 (file)
@@ -787,7 +787,7 @@ static int __init af_rxrpc_init(void)
 
        BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > sizeof(dummy_skb->cb));
 
-       rxrpc_epoch = htonl(xtime.tv_sec);
+       rxrpc_epoch = htonl(get_seconds());
 
        ret = -ENOMEM;
        rxrpc_call_jar = kmem_cache_create(
index 482750efc2355b4ea3f875044cd8b0323f848c62..372b24466dc768fa1765de0a471e10dc8ba0ad9d 100644 (file)
@@ -791,7 +791,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
 
        ASSERTCMP(atomic_read(&conn->usage), >, 0);
 
-       conn->put_time = xtime.tv_sec;
+       conn->put_time = get_seconds();
        if (atomic_dec_and_test(&conn->usage)) {
                _debug("zombie");
                rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
@@ -835,7 +835,7 @@ void rxrpc_connection_reaper(struct work_struct *work)
 
        _enter("");
 
-       now = xtime.tv_sec;
+       now = get_seconds();
        earliest = ULONG_MAX;
 
        write_lock_bh(&rxrpc_connection_lock);
index d43d78f19302f9a126dd226d5bc1ffedf0bd9502..bb282a6a19f0d7e38ac75542296acbf231330e77 100644 (file)
@@ -183,7 +183,7 @@ void rxrpc_put_transport(struct rxrpc_transport *trans)
 
        ASSERTCMP(atomic_read(&trans->usage), >, 0);
 
-       trans->put_time = xtime.tv_sec;
+       trans->put_time = get_seconds();
        if (unlikely(atomic_dec_and_test(&trans->usage)))
                _debug("zombie");
                /* let the reaper determine the timeout to avoid a race with
@@ -219,7 +219,7 @@ static void rxrpc_transport_reaper(struct work_struct *work)
 
        _enter("");
 
-       now = xtime.tv_sec;
+       now = get_seconds();
        earliest = ULONG_MAX;
 
        /* extract all the transports that have been dead too long */
index 5ec705144e10f7500b51755699afc97f3aa0e2a5..ac3cabdca78cb9e2ec3285cf3d6084315c336015 100644 (file)
@@ -916,7 +916,7 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn,
                issue = be32_to_cpu(stamp);
        }
        p += 4;
-       now = xtime.tv_sec;
+       now = get_seconds();
        _debug("KIV ISSUE: %lx [%lx]", issue, now);
 
        /* check the ticket is in date */