summaryrefslogtreecommitdiff
path: root/arch/um/include/shared
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2019-05-27 10:34:27 +0200
committerRichard Weinberger <richard@nod.at>2019-07-02 23:27:36 +0200
commit065038706f77a56754e8f0c2556dab7e22dfe577 (patch)
tree00e8ea2389184678dab2abe1155988b8aa488aad /arch/um/include/shared
parentc7c6f3b95303c7de5d52af56c902fcb5abe827df (diff)
um: Support time travel mode
Sometimes it can be useful to run with "time travel" inside the UML instance, for example for testing. For example, some tests for the wireless subsystem and userspace are based on hwsim, a virtual wireless adapter. Some tests can take a long time to run because they e.g. wait for 120 seconds to elapse for some regulatory checks. This obviously goes faster if it need not actually wait that long, but time inside the test environment just "bumps up" when there's nothing to do. Add CONFIG_UML_TIME_TRAVEL_SUPPORT to enable code to support such modes at runtime, selected on the command line: * just "time-travel", in which time inside the UML instance can move faster than real time, if there's nothing to do * "time-travel=inf-cpu" in which time also moves slower and any CPU processing takes no time at all, which allows to implement consistent behaviour regardless of host CPU load (or speed) or debug overhead. An additional "time-travel-start=<seconds>" parameter is also supported in this case to start the wall clock at this time (in unix epoch). With this enabled, the test mentioned above goes from a runtime of about 140 seconds (with startup overhead and all) to being CPU bound and finishing in 15 seconds (on my slow laptop). Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/include/shared')
-rw-r--r--arch/um/include/shared/timer-internal.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/um/include/shared/timer-internal.h b/arch/um/include/shared/timer-internal.h
index 03e6f217f807..5ca74f415d52 100644
--- a/arch/um/include/shared/timer-internal.h
+++ b/arch/um/include/shared/timer-internal.h
@@ -10,4 +10,50 @@
#define TIMER_MULTIPLIER 256
#define TIMER_MIN_DELTA 500
+enum time_travel_mode {
+ TT_MODE_OFF,
+ TT_MODE_BASIC,
+ TT_MODE_INFCPU,
+};
+
+enum time_travel_timer_mode {
+ TT_TMR_DISABLED,
+ TT_TMR_ONESHOT,
+ TT_TMR_PERIODIC,
+};
+
+#ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT
+extern enum time_travel_mode time_travel_mode;
+extern unsigned long long time_travel_time;
+extern enum time_travel_timer_mode time_travel_timer_mode;
+extern unsigned long long time_travel_timer_expiry;
+extern unsigned long long time_travel_timer_interval;
+
+static inline void time_travel_set_time(unsigned long long ns)
+{
+ time_travel_time = ns;
+}
+
+static inline void time_travel_set_timer(enum time_travel_timer_mode mode,
+ unsigned long long expiry)
+{
+ time_travel_timer_mode = mode;
+ time_travel_timer_expiry = expiry;
+}
+#else
+#define time_travel_mode TT_MODE_OFF
+#define time_travel_time 0
+#define time_travel_timer_expiry 0
+#define time_travel_timer_interval 0
+
+static inline void time_travel_set_time(unsigned long long ns)
+{
+}
+
+static inline void time_travel_set_timer(enum time_travel_timer_mode mode,
+ unsigned long long expiry)
+{
+}
+#endif
+
#endif