From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Gleixner Subject: Re: [PATCH V7 1/8] ntp: add ADJ_SETOFFSET mode bit Date: Thu, 16 Dec 2010 18:48:12 +0100 (CET) Message-ID: References: <880d82bb8120f73973db27e0c48e949014b1a106.1292512461.git.richard.cochran@omicron.at> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: In-Reply-To: <880d82bb8120f73973db27e0c48e949014b1a106.1292512461.git.richard.cochran-3mrvs1K0uXizZXS1Dc/lvw@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Richard Cochran Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Alan Cox , Arnd Bergmann , Christoph Lameter , David Miller , John Stultz , Krzysztof Halasa , Peter Zijlstra , Rodolfo Giometti List-Id: linux-api@vger.kernel.org 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 >