David Vrabel
2013-Jun-27 10:35 UTC
[PATCH 2/5] time: pass flags instead of multiple bools to timekeeping_update()
From: David Vrabel <david.vrabel@citrix.com> Instead of passing multiple bools to timekeeping_updated(), define flags and use a single ''action'' parameter. It is then more obvious what each timekeeping_update() call does. Signed-off-by: David Vrabel <david.vrabel@citrix.com> --- kernel/time/timekeeping.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index baeeb5c..7aed2b0 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -26,6 +26,9 @@ #include "tick-internal.h" #include "ntp_internal.h" +#define TK_CLEAR_NTP (1 << 0) +#define TK_MIRROR (1 << 1) + static struct timekeeper timekeeper; static DEFINE_RAW_SPINLOCK(timekeeper_lock); static seqcount_t timekeeper_seq; @@ -241,16 +244,16 @@ int pvclock_gtod_unregister_notifier(struct notifier_block *nb) EXPORT_SYMBOL_GPL(pvclock_gtod_unregister_notifier); /* must hold timekeeper_lock */ -static void timekeeping_update(struct timekeeper *tk, bool clearntp, bool mirror) +static void timekeeping_update(struct timekeeper *tk, unsigned action) { - if (clearntp) { + if (action & TK_CLEAR_NTP) { tk->ntp_error = 0; ntp_clear(); } update_vsyscall(tk); update_pvclock_gtod(tk); - if (mirror) + if (action & TK_MIRROR) memcpy(&shadow_timekeeper, &timekeeper, sizeof(timekeeper)); } @@ -508,7 +511,7 @@ int do_settimeofday(const struct timespec *tv) tk_set_xtime(tk, tv); - timekeeping_update(tk, true, true); + timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR); write_seqcount_end(&timekeeper_seq); raw_spin_unlock_irqrestore(&timekeeper_lock, flags); @@ -552,7 +555,7 @@ int timekeeping_inject_offset(struct timespec *ts) tk_set_wall_to_mono(tk, timespec_sub(tk->wall_to_monotonic, *ts)); error: /* even if we error out, we forwarded the time, so call update */ - timekeeping_update(tk, true, true); + timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR); write_seqcount_end(&timekeeper_seq); raw_spin_unlock_irqrestore(&timekeeper_lock, flags); @@ -633,7 +636,7 @@ static int change_clocksource(void *data) if (old->disable) old->disable(old); } - timekeeping_update(tk, true, true); + timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR); write_seqcount_end(&timekeeper_seq); raw_spin_unlock_irqrestore(&timekeeper_lock, flags); @@ -872,7 +875,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta) __timekeeping_inject_sleeptime(tk, delta); - timekeeping_update(tk, true, true); + timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR); write_seqcount_end(&timekeeper_seq); raw_spin_unlock_irqrestore(&timekeeper_lock, flags); @@ -954,7 +957,7 @@ static void timekeeping_resume(void) tk->cycle_last = clock->cycle_last = cycle_now; tk->ntp_error = 0; timekeeping_suspended = 0; - timekeeping_update(tk, false, true); + timekeeping_update(tk, TK_MIRROR); write_seqcount_end(&timekeeper_seq); raw_spin_unlock_irqrestore(&timekeeper_lock, flags); @@ -1415,7 +1418,7 @@ static void update_wall_time(void) * updating. */ memcpy(real_tk, tk, sizeof(*tk)); - timekeeping_update(real_tk, false, false); + timekeeping_update(real_tk, 0); write_seqcount_end(&timekeeper_seq); out: raw_spin_unlock_irqrestore(&timekeeper_lock, flags); -- 1.7.2.5
John Stultz
2013-Jun-27 17:39 UTC
Re: [PATCH 2/5] time: pass flags instead of multiple bools to timekeeping_update()
On 06/27/2013 03:35 AM, David Vrabel wrote:> From: David Vrabel <david.vrabel@citrix.com> > > Instead of passing multiple bools to timekeeping_updated(), define > flags and use a single ''action'' parameter. It is then more obvious > what each timekeeping_update() call does. > > Signed-off-by: David Vrabel <david.vrabel@citrix.com> > --- > kernel/time/timekeeping.c | 21 ++++++++++++--------- > 1 files changed, 12 insertions(+), 9 deletions(-) > > diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c > index baeeb5c..7aed2b0 100644 > --- a/kernel/time/timekeeping.c > +++ b/kernel/time/timekeeping.c > @@ -26,6 +26,9 @@ > #include "tick-internal.h" > #include "ntp_internal.h" > > +#define TK_CLEAR_NTP (1 << 0) > +#define TK_MIRROR (1 << 1) > + > static struct timekeeper timekeeper; > static DEFINE_RAW_SPINLOCK(timekeeper_lock); > static seqcount_t timekeeper_seq; > @@ -241,16 +244,16 @@ int pvclock_gtod_unregister_notifier(struct notifier_block *nb) > EXPORT_SYMBOL_GPL(pvclock_gtod_unregister_notifier); > > /* must hold timekeeper_lock */ > -static void timekeeping_update(struct timekeeper *tk, bool clearntp, bool mirror) > +static void timekeeping_update(struct timekeeper *tk, unsigned action)Nit: Mind making this "unsigned int" just for consistency sake with the rest of the code? thanks -john
Reasonably Related Threads
- [PATCH 2/4] time: add a notifier chain for when the system time is stepped
- [RFC][PATCH 2/5] timekeeping: Fix potential lost pv notification of time change
- [RFC][PATCH 3/3] timekeeping: Fix potential lost pv notification of time change
- [RFC v4 02/12] kthread: Add kthread_(un)block_work_queuing() and kthread_work_queuable()
- Patch "genirq: Add IRQF_RESUME_EARLY and resume such IRQs earlier" has been added to the 3.1-stable tree