diff options
author | Johannes Berg <johannes.berg@intel.com> | 2020-12-11 11:01:14 +0300 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2020-12-14 00:41:56 +0300 |
commit | 452f94cecff692a76eaaa9330fca03fe0f204f6f (patch) | |
tree | 0820d5797c4e77eea8eee7ba5c6cdfcdde250ba3 /arch/um | |
parent | 9431f7c199ab0d02da1482d62255e0b4621cb1b5 (diff) | |
download | linux-452f94cecff692a76eaaa9330fca03fe0f204f6f.tar.xz |
um: time-travel: Actually apply "free-until" optimisation
Due a bug - we never checked the time_travel_ext_free_until value - we
were always requesting time for every single scheduling. This adds up
since we make reading time cost 256ns, and it's a fairly common call.
Fix this.
While at it, also make reading time only cost something when we're not
currently waiting for our scheduling turn - otherwise things get mixed
up in a very confusing way. We should never get here, since we're not
actually running, but it's possible if you stick printk() or such into
the virtio code that must handle the external interrupts.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/kernel/time.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index 204ddb141b01..e48282308126 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c @@ -183,6 +183,14 @@ static void time_travel_ext_update_request(unsigned long long time) time == time_travel_ext_prev_request) return; + /* + * if we're running and are allowed to run past the request + * then we don't need to update it either + */ + if (!time_travel_ext_waiting && time_travel_ext_free_until_valid && + time < time_travel_ext_free_until) + return; + time_travel_ext_prev_request = time; time_travel_ext_prev_request_valid = true; time_travel_ext_req(UM_TIMETRAVEL_REQUEST, time); @@ -223,6 +231,7 @@ static void time_travel_ext_wait(bool idle) }; time_travel_ext_prev_request_valid = false; + time_travel_ext_free_until_valid = false; time_travel_ext_waiting++; time_travel_ext_req(UM_TIMETRAVEL_WAIT, -1); @@ -492,6 +501,7 @@ invalid_number: #define time_travel_start_set 0 #define time_travel_start 0 #define time_travel_time 0 +#define time_travel_ext_waiting 0 static inline void time_travel_update_time(unsigned long long ns, bool retearly) { @@ -637,7 +647,8 @@ static u64 timer_read(struct clocksource *cs) * "what do I do next" and onstack event we use to know when * to return from time_travel_update_time(). */ - if (!irqs_disabled() && !in_interrupt() && !in_softirq()) + if (!irqs_disabled() && !in_interrupt() && !in_softirq() && + !time_travel_ext_waiting) time_travel_update_time(time_travel_time + TIMER_MULTIPLIER, false); |