Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c6b47de authored by John Stultz's avatar John Stultz Committed by Linus Torvalds
Browse files

Cleanup non-arch xtime uses, use get_seconds() or current_kernel_time().



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: default avatarJohn Stultz <johnstul@us.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0de085bb
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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;
}
+3 −3
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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;
Loading