LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Torben Hohn <torbenh@gmx.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	johnstul@us.ibm.com, yong.zhang0@gmail.com, hch@infradead.org
Subject: Re: [PATCH v2 03/20] provide get_xtime_and_monotonic_offset() and use it in hrtimer.c
Date: Mon, 31 Jan 2011 12:38:46 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.2.00.1101311236440.31804@localhost6.localdomain6> (raw)
In-Reply-To: <20110127145905.23248.30458.stgit@localhost>

On Thu, 27 Jan 2011, Torben Hohn wrote:

> 2 places in hrtimer need to take the xtime_lock, but we want it
> to be private to kernel/time...
> 
> we just provide a function, which gets the values with proper
> read locking the xtime_lock.

Proper sentences start with an uppercase letter.
 
> @@ -617,10 +612,7 @@ static void retrigger_next_event(void *arg)
>  	if (!hrtimer_hres_active())
>  		return;
>  
> -	do {
> -		seq = read_seqbegin(&xtime_lock);
> -		wtm = __get_wall_to_monotonic();
> -	} while (read_seqretry(&xtime_lock, seq));
> +	get_xtime_and_monotonic_offset(NULL, &wtm);
>  	set_normalized_timespec(&realtime_offset, -wtm.tv_sec, -wtm.tv_nsec);

Leaves an unused variable seq. Please do NOT ignore compiler warnings.
 
>  	base = &__get_cpu_var(hrtimer_bases);
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index e4fd957..6085fa5 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -957,3 +957,24 @@ void do_timer(unsigned long ticks)
>  	jiffies_64 += ticks;
>  	update_wall_time();
>  }
> +
> +/**
> + * get_xtime_and_monotonic_offset() - get xtime and wall_to_monotonic
> + * @xts: pointer to struct timespec, filled with the current_time
> + * @tom: pointer to struct timespec, filled with the wall_to_monotonic offset
> + *
> + * this function does proper locking.
> + * and it allows passing NULL, when one is not interested in the value.
> + */
> +void get_xtime_and_monotonic_offset(struct timespec *xts, struct timespec *tom)
> +{
> +	unsigned long seq;
> +
> +	do {
> +		seq = read_seqbegin(&xtime_lock);
> +		if (xts)
> +			*xts = xtime;
> +		if (tom)
> +			*tom = wall_to_monotonic;

That's silly. We can hand in realtime_offset in
retrigger_next_event(). No need for these conditionals.

> +	} while (read_seqretry(&xtime_lock, seq));
> +}

Thanks,

	tglx
 

  reply	other threads:[~2011-01-31 11:38 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 14:58 [PATCH v2 00/20] localize xtime_lock usage to kernel/time/ Torben Hohn
2011-01-27 14:58 ` [PATCH v2 01/20] move do_timer() from kernel/timer.c into kernel/time/timekeeping.c Torben Hohn
2011-01-31 14:03   ` [tip:timers/core] time: Move do_timer() to kernel/time/timekeeping.c tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 02/20] move get_jiffies_64 to kernel/time/jiffies.c Torben Hohn
2011-01-31 11:36   ` Thomas Gleixner
2011-01-31 14:04   ` [tip:timers/core] time: Move " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 03/20] provide get_xtime_and_monotonic_offset() and use it in hrtimer.c Torben Hohn
2011-01-31 11:38   ` Thomas Gleixner [this message]
2011-01-31 14:04   ` [tip:timers/core] time: Provide get_xtime_and_monotonic_offset() tip-bot for Torben Hohn
2011-02-01  9:21   ` [tip:timers/core] time: Fix legacy arch fallout tip-bot for Thomas Gleixner
2011-01-27 14:59 ` [PATCH v2 04/20] provide xtime_update() which does not require the caller to hold xtime_lock Torben Hohn
2011-01-31 14:05   ` [tip:timers/core] time: Provide xtime_update() tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 05/20] alpha: change do_timer() to xtime_update() Torben Hohn
2011-01-31 10:23   ` Thomas Gleixner
2011-01-31 10:32     ` Thomas Gleixner
2011-01-31 14:05   ` [tip:timers/core] alpha: Change " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 06/20] arm: switch from " Torben Hohn
2011-01-31 14:06   ` [tip:timers/core] arm: Switch " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 07/20] arm/mach-clps711x: switch " Torben Hohn
2011-01-31 14:06   ` [tip:timers/core] arm/mach-clps711x: Switch " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 08/20] blackfin: switch from " Torben Hohn
2011-01-27 19:42   ` Mike Frysinger
2011-01-31 14:07   ` [tip:timers/core] blackfin: Switch " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 09/20] cris/arch-v10: switch " Torben Hohn
2011-01-31 14:07   ` [tip:timers/core] cris: arch-v10: Switch " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 10/20] cris/arch-v32: switch " Torben Hohn
2011-01-31 14:07   ` [tip:timers/core] cris: arch-v32: Switch " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 11/20] frv: switch " Torben Hohn
2011-01-31 14:08   ` [tip:timers/core] frv: Switch " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 12/20] h8300: switch " Torben Hohn
2011-01-31 14:08   ` [tip:timers/core] h8300: Switch " tip-bot for Torben Hohn
2011-01-27 14:59 ` [PATCH v2 13/20] ia64: switch " Torben Hohn
2011-01-31 14:09   ` [tip:timers/core] ia64: Switch " tip-bot for Torben Hohn
2011-01-27 15:00 ` [PATCH v2 14/20] m32r: switch from " Torben Hohn
2011-01-31 14:09   ` [tip:timers/core] m32r: Switch " tip-bot for Torben Hohn
2011-01-27 15:00 ` [PATCH v2 15/20] m68k: switch " Torben Hohn
2011-01-31 14:09   ` [tip:timers/core] m68k: Switch " tip-bot for Torben Hohn
2011-02-03 23:07     ` Greg Ungerer
2011-01-27 15:00 ` [PATCH v2 16/20] mn10300: switch do_timer() to xtimer_update() Torben Hohn
2011-01-31 13:47   ` Thomas Gleixner
2011-02-09 15:18   ` [tip:timers/core] mn10300: Switch " tip-bot for Torben Hohn
2011-03-18 16:35   ` [PATCH v2 16/20] mn10300: switch " David Howells
2011-01-27 15:00 ` [PATCH v2 17/20] parisc: switch do_timer() to xtime_update() Torben Hohn
2011-01-31 14:10   ` [tip:timers/core] parisc: Switch " tip-bot for Torben Hohn
2011-01-27 15:00 ` [PATCH v2 18/20] sparc: switch " Torben Hohn
2011-01-31 14:10   ` [tip:timers/core] sparc: Switch " tip-bot for Torben Hohn
2011-01-27 15:00 ` [PATCH v2 19/20] xtensa: switch " Torben Hohn
2011-01-31 14:11   ` [tip:timers/core] xtensa: Switch " tip-bot for Torben Hohn
2011-01-27 15:00 ` [PATCH v2 20/20] make do_timer() and xtime_lock private to the timer code Torben Hohn
2011-01-31 14:11   ` [tip:timers/core] time: Make do_timer() and xtime_lock local to kernel/time/ tip-bot for Torben Hohn
2011-01-31 18:21   ` tip-bot for Torben Hohn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.00.1101311236440.31804@localhost6.localdomain6 \
    --to=tglx@linutronix.de \
    --cc=hch@infradead.org \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=torbenh@gmx.de \
    --cc=yong.zhang0@gmail.com \
    --subject='Re: [PATCH v2 03/20] provide get_xtime_and_monotonic_offset() and use it in hrtimer.c' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).