From owner-freebsd-stable@FreeBSD.ORG Fri Sep 11 15:05:32 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA57C1065672 for ; Fri, 11 Sep 2009 15:05:32 +0000 (UTC) (envelope-from pldrouin@pldrouin.net) Received: from smtp.cyberfingers.net (smtp.cyberfingers.net [198.177.254.227]) by mx1.freebsd.org (Postfix) with ESMTP id A6CBC8FC1C for ; Fri, 11 Sep 2009 15:05:32 +0000 (UTC) Received: from mdaemon.pldrouin.net (CPE0023695b905f-CM001a666aca96.cpe.net.cable.rogers.com [99.246.67.95]) by smtp.cyberfingers.net (Postfix) with ESMTP id CA8C2AB6C5B for ; Fri, 11 Sep 2009 11:05:31 -0400 (EDT) Message-ID: <4AAA6755.7070502@pldrouin.net> Date: Fri, 11 Sep 2009 11:05:57 -0400 From: Pierre-Luc Drouin User-Agent: Thunderbird 2.0.0.23 (X11/20090824) MIME-Version: 1.0 To: freebsd-stable@freebsd.org References: <4AA9A07C.4050200@pldrouin.net> <20090911074123.00006179@unknown> In-Reply-To: <20090911074123.00006179@unknown> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: How to enable CPU turbo mode on FreeBSD? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2009 15:05:32 -0000 Bruce Cran wrote: > On Thu, 10 Sep 2009 20:57:32 -0400 > Pierre-Luc Drouin wrote: > > >> Hi, >> >> I have an overclocked i7 920 CPU for which I have enabled Turbo Mode >> in the BIOS (21x multiplier). The base clock is set at 190 MHz, so >> the CPU frequency with Turbo mode activated should be 3990 MHz. >> However the maximum value FreeBSD amd64 shows for the CPU frequency >> in dmesg and sysctl is 3790 MHz. How can I enable the Turbo Mode? >> >> CPU: Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz (3790.52-MHz >> K8-class CPU) >> >> machdep.acpi_timer_freq: 3579545 >> machdep.tsc_freq: 3790522507 >> machdep.i8254_freq: 1193182 >> dev.cpu.0.freq: 349 >> dev.cpu.0.freq_levels: 2793/130000 2443/113750 2094/97500 1745/81250 >> 1396/65000 1047/48750 698/32500 349/16250 >> > > You may be able to use the cpuctl kernel module with sysutils/x86info > to see when the CPUs are using Turbo mode. I haven't had any success > yet but I know in Windows the System control panel reported the 2.66GHz > CPU running at 2.83GHz without me doing anything, so I guess FreeBSD > should be doing the same. > > So I managed to test that the Turbo Mode is working. Here is how I tested it, if it can be useful for other people in the future: I wrote this very dumb program in C (compiled using gcc -lpthread -o test test.c): #include #include #include int main(int nargs, char* args[]); void* floop(void* args); long long int niters; int main(int nargs, char* args[]) { int nthrs; int i; pthread_t *threads; --nargs; ++args; if(nargs!=2) { fprintf(stderr,"Usage: loop nthreads niters\n"); return 1; } sscanf(args[0],"%i",&nthrs); sscanf(args[1],"%lli",&niters); printf("Number of threads: %i\n",nthrs); printf("Number of iterations: %lli\n",niters); threads=(pthread_t*)malloc(nthrs*sizeof(pthread_t)); for(i=nthrs-1; i>=0; --i) pthread_create(threads+i,NULL,floop,NULL); for(i=nthrs-1; i>=0; --i) pthread_join(threads[i],NULL); free(threads); return 0; } void* floop(void* args){ long long int i; for(i=niters-1; i>=0; --i); return NULL; } I ran it with 8 threads and 150 000 000 000 iterations/threads using time ./test 8 150000000000 I got a user time of 1827.24 sec with turbo and 1908.69 sec without, a 4.5% speed difference, which is pretty close to the expected 5% (1-21/20 where 21/20 is the ratio of CPU multipliers with and without turbo for my i7 920 CPU)