[PATCH RFC 11/11] um: Remove all TSC flags when using Time Travel Mode

Johannes Berg johannes at sipsolutions.net
Mon Nov 6 12:52:17 PST 2023


On Fri, 2023-11-03 at 16:41 +0000, Benjamin Beichler wrote:
> In time travel mode, the internal time is only advanced at discrete
> synchronization points, while the TSC register continuously increases.
> Although the TSC registers remain accessible, we remove the TSC flags to
> indicate to programs that properly check the TSC flag before reading
> that the CPU lacks a proper TSC register.
> 
> This change is primarily cosmetic but may encourage some programs to use
> gettimeofday and similar calls for time measurement.
> 
> Signed-off-by: Benjamin Beichler <benjamin.beichler at uni-rostock.de>
> ---
>  arch/um/kernel/um_arch.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
> index b1bfed0c8528..6bfd531b5f87 100644
> --- a/arch/um/kernel/um_arch.c
> +++ b/arch/um/kernel/um_arch.c
> @@ -30,6 +30,7 @@
>  #include <kern_util.h>
>  #include <mem_user.h>
>  #include <os.h>
> +#include <timetravel.h>
>  
>  #include "um_arch.h"
>  
> @@ -284,7 +285,8 @@ static void parse_host_cpu_flags(char *line)
>  {
>  	int i;
>  	for (i = 0; i < 32*NCAPINTS; i++) {
> -		if ((x86_cap_flags[i] != NULL) && strstr(line, x86_cap_flags[i]))
> +		if ((x86_cap_flags[i] != NULL) && strstr(line, x86_cap_flags[i]) &&
> +			!(time_travel_mode != TT_MODE_OFF && strstr("tsc", x86_cap_flags[i])))
>  			set_cpu_cap(&boot_cpu_data, i);
> 

Makes sense, but the code formatting is all wrong ;-)
(indentation should only be to the logical level of the parentheses)

johannes



More information about the linux-um mailing list