lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 31 Jan 2011 12:38:46 +0100 (CET)
From:	Thomas Gleixner <tglx@...utronix.de>
To:	Torben Hohn <torbenh@....de>
cc:	LKML <linux-kernel@...r.kernel.org>,
	Peter Zijlstra <peterz@...radead.org>, johnstul@...ibm.com,
	yong.zhang0@...il.com, hch@...radead.org
Subject: Re: [PATCH v2 03/20] provide get_xtime_and_monotonic_offset() and
 use it in hrtimer.c

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
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ