From owner-svn-src-all@FreeBSD.ORG Tue Apr 12 22:15:46 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A76E41065673; Tue, 12 Apr 2011 22:15:46 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CE968FC0A; Tue, 12 Apr 2011 22:15:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CMFkvg037200; Tue, 12 Apr 2011 22:15:46 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CMFkCZ037196; Tue, 12 Apr 2011 22:15:46 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201104122215.p3CMFkCZ037196@svn.freebsd.org> From: Jung-uk Kim Date: Tue, 12 Apr 2011 22:15:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220579 - in head/sys: amd64/amd64 i386/i386 x86/x86 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2011 22:15:46 -0000 Author: jkim Date: Tue Apr 12 22:15:46 2011 New Revision: 220579 URL: http://svn.freebsd.org/changeset/base/220579 Log: Probe capability to find effective frequency. When the TSC is P-state invariant, APERF/MPERF ratio can be used to find effective frequency. Modified: head/sys/amd64/amd64/identcpu.c head/sys/i386/i386/identcpu.c head/sys/x86/x86/tsc.c Modified: head/sys/amd64/amd64/identcpu.c ============================================================================== --- head/sys/amd64/amd64/identcpu.c Tue Apr 12 22:12:23 2011 (r220578) +++ head/sys/amd64/amd64/identcpu.c Tue Apr 12 22:15:46 2011 (r220579) @@ -396,8 +396,11 @@ printcpuinfo(void) * If this CPU supports P-state invariant TSC then * mention the capability. */ - if (tsc_is_invariant) + if (tsc_is_invariant) { printf("\n TSC: P-state invariant"); + if (tsc_perf_stat) + printf(", performance statistics"); + } } } Modified: head/sys/i386/i386/identcpu.c ============================================================================== --- head/sys/i386/i386/identcpu.c Tue Apr 12 22:12:23 2011 (r220578) +++ head/sys/i386/i386/identcpu.c Tue Apr 12 22:15:46 2011 (r220579) @@ -873,8 +873,11 @@ printcpuinfo(void) * If this CPU supports P-state invariant TSC then * mention the capability. */ - if (tsc_is_invariant) + if (tsc_is_invariant) { printf("\n TSC: P-state invariant"); + if (tsc_perf_stat) + printf(", performance statistics"); + } } } else if (cpu_vendor_id == CPU_VENDOR_CYRIX) { Modified: head/sys/x86/x86/tsc.c ============================================================================== --- head/sys/x86/x86/tsc.c Tue Apr 12 22:12:23 2011 (r220578) +++ head/sys/x86/x86/tsc.c Tue Apr 12 22:15:46 2011 (r220579) @@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$"); uint64_t tsc_freq; int tsc_is_invariant; +int tsc_perf_stat; + static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag; SYSCTL_INT(_kern_timecounter, OID_AUTO, invariant_tsc, CTLFLAG_RDTUN, @@ -151,6 +153,7 @@ tsc_freq_intel(void) static void probe_tsc_freq(void) { + u_int regs[4]; uint64_t tsc1, tsc2; switch (cpu_vendor_id) { @@ -178,6 +181,12 @@ probe_tsc_freq(void) break; } + if (cpu_high >= 6) { + do_cpuid(6, regs); + if ((regs[2] & CPUID_PERF_STAT) != 0) + tsc_perf_stat = 1; + } + if (tsc_skip_calibration) { if (cpu_vendor_id == CPU_VENDOR_INTEL) tsc_freq_intel();