Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Jan 2021 12:18:44 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jakob Alvermark <jakob@alvermark.net>
Cc:        freebsd-current <freebsd-current@freebsd.org>
Subject:   Re: Waiting for bufdaemon
Message-ID:  <YAgDhJ9/YX29kH2a@kib.kiev.ua>
In-Reply-To: <1d675d77-8bdb-c285-ffa2-28330b839734@alvermark.net>
References:  <369b3d82-98c5-b31e-6168-4003a042f174@FreeBSD.org> <YAGua8f8G57SbUMT@kib.kiev.ua> <556d40b8-92d7-303e-7d87-ea496d0ca733@FreeBSD.org> <YAG4g7dJbRWM7act@kib.kiev.ua> <ed52f8c1-5f43-b71e-1d56-625e2e064a7e@gwdg.de> <9ae3cc65-193a-39c3-4067-0d42e9f634b0@gwdg.de> <YAO9/cxnbGv5u3Bg@kib.kiev.ua> <adb9d42c-d855-1edf-a57c-9b16aad481b7@gwdg.de> <YAQINMoEi7ysBSD5@kib.kiev.ua> <1d675d77-8bdb-c285-ffa2-28330b839734@alvermark.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jan 20, 2021 at 11:02:21AM +0100, Jakob Alvermark wrote:
> This patch hides the problem for me. The system seems to work better now.
> 
> No waiting on reboot, and the webcam works better.
I am curious what do you mean by the above reference to webcam.
Can you explain it with more details, even if only the impressions?

I probably going to commit the following patch in the next 24 hours.

commit 02505d07bca320a638c96918ac9076c6eece2fff
Author: Konstantin Belousov <kib@FreeBSD.org>
Date:   Wed Jan 20 11:32:21 2021 +0200

    AMD Zen CPUs: switch TSC timecounter to RDTSCP
    
    Reported by:    many
    MFC after:      1 weel
    Sponsored by:   The FreeBSD Foundation

diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c
index 7f224f8758cb..7a64f2a0b556 100644
--- a/lib/libc/x86/sys/__vdso_gettc.c
+++ b/lib/libc/x86/sys/__vdso_gettc.c
@@ -125,7 +125,7 @@ struct tsc_selector_tag {
 };
 
 static const struct tsc_selector_tag tsc_selector[] = {
-	[0] = {				/* Intel or AMD Zen+, LFENCE */
+	[0] = {				/* Intel, LFENCE */
 		.ts_rdtsc32 =	rdtsc32_mb_lfence,
 		.ts_rdtsc_low =	rdtsc_low_mb_lfence,
 	},
@@ -164,9 +164,6 @@ tsc_selector_idx(u_int cpu_feature)
 	do_cpuid(1, p);
 	cpu_id = p[0];
 
-	if (amd_cpu && CPUID_TO_FAMILY(cpu_id) >= 0x17)
-		return (0);
-
 	if (cpu_feature != 0) {
 		do_cpuid(0x80000000, p);
 		cpu_exthigh = p[0];
diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c
index 85924df98312..de0a1505c2f6 100644
--- a/sys/x86/x86/tsc.c
+++ b/sys/x86/x86/tsc.c
@@ -633,19 +633,12 @@ init_TSC_tc(void)
 
 	/*
 	 * Timecounter implementation selection, top to bottom:
-	 * - For AMD Zens and newer, use LFENCE;RDTSC.
 	 * - If RDTSCP is available, use RDTSCP.
 	 * - If fence instructions are provided (SSE2), use LFENCE;RDTSC
 	 *   on Intel, and MFENCE;RDTSC on AMD.
 	 * - For really old CPUs, just use RDTSC.
 	 */
-	if ((cpu_vendor_id == CPU_VENDOR_AMD ||
-	    cpu_vendor_id == CPU_VENDOR_HYGON) &&
-	    CPUID_TO_FAMILY(cpu_id) >= 0x17) {
-		tsc_timecounter.tc_get_timecount = shift > 0 ?
-		    tsc_get_timecount_low_lfence :
-		    tsc_get_timecount_lfence;
-	} else if ((amd_feature & AMDID_RDTSCP) != 0) {
+	if ((amd_feature & AMDID_RDTSCP) != 0) {
 		tsc_timecounter.tc_get_timecount = shift > 0 ?
 		    tscp_get_timecount_low : tscp_get_timecount;
 	} else if ((cpu_feature & CPUID_SSE2) != 0 && mp_ncpus > 1) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YAgDhJ9/YX29kH2a>