svn commit: r345359 - in head/sys/cddl/dev/dtrace: amd64 i386

John Baldwin jhb at FreeBSD.org
Thu Mar 21 16:25:25 UTC 2019


On 3/20/19 7:52 PM, Mark Johnston wrote:
> Author: markj
> Date: Thu Mar 21 02:52:22 2019
> New Revision: 345359
> URL: https://svnweb.freebsd.org/changeset/base/345359
> 
> Log:
>   Don't attempt to measure TSC skew when running as a VM guest.
>   
>   It simply doesn't work in general since VCPUs may migrate between
>   physical cores.  The approach used to measure skew also doesn't
>   make much sense in a VM.
>   
>   PR:		218452
>   MFC after:	2 weeks
>   Sponsored by:	The FreeBSD Foundation
> 
> Modified:
>   head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
>   head/sys/cddl/dev/dtrace/i386/dtrace_subr.c
> 
> Modified: head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
> ==============================================================================
> --- head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c	Thu Mar 21 01:16:37 2019	(r345358)
> +++ head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c	Thu Mar 21 02:52:22 2019	(r345359)
> @@ -319,6 +319,9 @@ dtrace_gethrtime_init(void *arg)
>  	int i;
>  #endif
>  
> +	if (vm_guest)
> +		return;
> +
>  	/* The current CPU is the reference one. */
>  	sched_pin();
>  	tsc_skew[curcpu] = 0;
> 
> Modified: head/sys/cddl/dev/dtrace/i386/dtrace_subr.c
> ==============================================================================
> --- head/sys/cddl/dev/dtrace/i386/dtrace_subr.c	Thu Mar 21 01:16:37 2019	(r345358)
> +++ head/sys/cddl/dev/dtrace/i386/dtrace_subr.c	Thu Mar 21 02:52:22 2019	(r345359)
> @@ -321,6 +321,9 @@ dtrace_gethrtime_init(void *arg)
>  	int i;
>  #endif
>  
> +	if (vm_guest)
> +		return;
> +
>  	/* The current CPU is the reference one. */
>  	sched_pin();
>  	tsc_skew[curcpu] = 0;

I do think I would prefer 'if (vm_guest != VM_GUEST_NO)' or some such vs
'if (vm_guest)'.  The latter does read well, but it seems like comparisons
against enums should always be against an enum value?  That seems more
consistent with our rule to require pointers to be compared with NULL
for example.

-- 
John Baldwin


More information about the svn-src-head mailing list