Skip to content

Commit cef9037

Browse files
timekeeping: Move ADJ_SETOFFSET to top level do_adjtimex()
Since ADJ_SETOFFSET adjusts the timekeeping state, process it as part of the top level do_adjtimex() function in timekeeping.c. This avoids deadlocks that could occur once we change the ntp locking rules. Cc: Thomas Gleixner <[email protected]> Cc: Richard Cochran <[email protected]> Cc: Prarit Bhargava <[email protected]> Signed-off-by: John Stultz <[email protected]>
1 parent 87ace39 commit cef9037

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

kernel/time/ntp.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -666,17 +666,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai)
666666
{
667667
int result;
668668

669-
if (txc->modes & ADJ_SETOFFSET) {
670-
struct timespec delta;
671-
delta.tv_sec = txc->time.tv_sec;
672-
delta.tv_nsec = txc->time.tv_usec;
673-
if (!(txc->modes & ADJ_NANO))
674-
delta.tv_nsec *= 1000;
675-
result = timekeeping_inject_offset(&delta);
676-
if (result)
677-
return result;
678-
}
679-
680669
raw_spin_lock_irq(&ntp_lock);
681670

682671
if (txc->modes & ADJ_ADJTIME) {

kernel/time/timekeeping.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,17 @@ int do_adjtimex(struct timex *txc)
16271627
if (ret)
16281628
return ret;
16291629

1630+
if (txc->modes & ADJ_SETOFFSET) {
1631+
struct timespec delta;
1632+
delta.tv_sec = txc->time.tv_sec;
1633+
delta.tv_nsec = txc->time.tv_usec;
1634+
if (!(txc->modes & ADJ_NANO))
1635+
delta.tv_nsec *= 1000;
1636+
ret = timekeeping_inject_offset(&delta);
1637+
if (ret)
1638+
return ret;
1639+
}
1640+
16301641
getnstimeofday(&ts);
16311642
orig_tai = tai = timekeeping_get_tai_offset();
16321643

0 commit comments

Comments
 (0)