lkml.org 
[lkml]   [2010]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH V7 1/8] ntp: add ADJ_SETOFFSET mode bit
    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
    >


    \
     
     \ /
      Last update: 2010-12-16 18:53    [W:4.015 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site