Re: [PATCH V7 1/8] ntp: add ADJ_SETOFFSET mode bit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Thu, 16 Dec 2010, Richard Cochran wrote:
> +	if (txc->modes & ADJ_SETOFFSET) {
> +		/* Validate the delta value. */
> +		if (txc->time.tv_sec && txc->time.tv_usec < 0)
> +			return -EINVAL;
> +
> +		if (txc->modes & ADJ_NANO) {
> +			struct timespec tmp;
> +			tmp.tv_sec  = txc->time.tv_sec;
> +			tmp.tv_nsec = txc->time.tv_usec;
> +			delta = timespec_to_ktime(tmp);
> +		} else
> +			delta = timeval_to_ktime(txc->time);
> +
> +		/* Adding the delta should be an "atomic" operation. */
> +		local_irq_disable();

I really do not like that conditional irq_disable(), especially as we
disable them further down again and we only safe the getnstimeofday()
call in the non ADJSETOFFSET code path.

So we really better do that unconditionally before getnstimeofday()
with an appropriate comment and change the write_seqlock_irq() to
write_seqlock().

> +	}
> +
>  	getnstimeofday(&ts);
>  
> +	if (txc->modes & ADJ_SETOFFSET) {
> +		kt = timespec_to_ktime(ts);
> +		kt = ktime_add(kt, delta);
> +		ts = ktime_to_timespec(kt);
> +		do_settimeofday(&ts);
> +		local_irq_enable();
> +	}
> +
>  	write_seqlock_irq(&xtime_lock);

Thanks,

	tglx
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Home]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [XFree86]

Add to Google Powered by Linux