git: e6d31b4b70f0 - stable/13 - timecounter: Load the currently selected tc once in tc_windup()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 19 Jul 2022 14:09:30 UTC
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e6d31b4b70f039f85420dd9ddf67e07651b72358 commit e6d31b4b70f039f85420dd9ddf67e07651b72358 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-10-29 18:29:22 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-07-19 13:59:14 +0000 timecounter: Load the currently selected tc once in tc_windup() Reported by: Sebastian Huber <sebastian.huber@embedded-brains.de> Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 26f76aea2d276aacb69a1f9d78558d6107155aed) --- sys/kern/kern_tc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index f06665a69488..469c5fa12c82 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1355,6 +1355,7 @@ static void tc_windup(struct bintime *new_boottimebin) { struct bintime bt; + struct timecounter *tc; struct timehands *th, *tho; u_int delta, ncount, ogen; int i; @@ -1383,9 +1384,10 @@ tc_windup(struct bintime *new_boottimebin) * changing timecounters, a counter value from the new timecounter. * Update the offset fields accordingly. */ + tc = atomic_load_ptr(&timecounter); delta = tc_delta(th); - if (th->th_counter != timecounter) - ncount = timecounter->tc_get_timecount(timecounter); + if (th->th_counter != tc) + ncount = tc->tc_get_timecount(tc); else ncount = 0; #ifdef FFCLOCK @@ -1440,17 +1442,17 @@ tc_windup(struct bintime *new_boottimebin) bintime2timespec(&bt, &th->th_nanotime); /* Now is a good time to change timecounters. */ - if (th->th_counter != timecounter) { + if (th->th_counter != tc) { #ifndef __arm__ - if ((timecounter->tc_flags & TC_FLAGS_C2STOP) != 0) + if ((tc->tc_flags & TC_FLAGS_C2STOP) != 0) cpu_disable_c2_sleep++; if ((th->th_counter->tc_flags & TC_FLAGS_C2STOP) != 0) cpu_disable_c2_sleep--; #endif - th->th_counter = timecounter; + th->th_counter = tc; th->th_offset_count = ncount; - tc_min_ticktock_freq = max(1, timecounter->tc_frequency / - (((uint64_t)timecounter->tc_counter_mask + 1) / 3)); + tc_min_ticktock_freq = max(1, tc->tc_frequency / + (((uint64_t)tc->tc_counter_mask + 1) / 3)); recalculate_scaling_factor_and_large_delta(th); #ifdef FFCLOCK ffclock_change_tc(th);