diff mbox series

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

Message ID 20231103-bb-timetravel-patches-v1-11-e2c68efcf664@uni-rostock.de
State Changes Requested
Headers show
Series Several Time Travel Mode Enhancements | expand

Commit Message

Benjamin Beichler Nov. 3, 2023, 4:41 p.m. UTC
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@uni-rostock.de>
---
 arch/um/kernel/um_arch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Anton Ivanov Nov. 3, 2023, 6:45 p.m. UTC | #1
On 03/11/2023 16:41, 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@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);
>   	}
>   }
> 

Acked-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Johannes Berg Nov. 6, 2023, 8:52 p.m. UTC | #2
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@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
diff mbox series

Patch

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);
 	}
 }