From owner-svn-src-head@freebsd.org Thu Sep 7 20:20:13 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C69F9E0D6E1; Thu, 7 Sep 2017 20:20:13 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8082066B98; Thu, 7 Sep 2017 20:20:13 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v87KKCHT023856; Thu, 7 Sep 2017 20:20:12 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v87KKCcB023855; Thu, 7 Sep 2017 20:20:12 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201709072020.v87KKCcB023855@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Thu, 7 Sep 2017 20:20:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323286 - head/sys/x86/cpufreq X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/x86/cpufreq X-SVN-Commit-Revision: 323286 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Sep 2017 20:20:14 -0000 Author: cem Date: Thu Sep 7 20:20:12 2017 New Revision: 323286 URL: https://svnweb.freebsd.org/changeset/base/323286 Log: cpufreq(4) hwpstate: Yield CPU awaiting frequency change It doesn't seem necessary to busy the CPU while waiting to transition into a different p-state. PR: 221621 (related, but does not completely address) Reviewed by: truckman Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D12260 Modified: head/sys/x86/cpufreq/hwpstate.c Modified: head/sys/x86/cpufreq/hwpstate.c ============================================================================== --- head/sys/x86/cpufreq/hwpstate.c Thu Sep 7 20:18:57 2017 (r323285) +++ head/sys/x86/cpufreq/hwpstate.c Thu Sep 7 20:20:12 2017 (r323286) @@ -160,6 +160,7 @@ DRIVER_MODULE(hwpstate, cpu, hwpstate_driver, hwpstate static int hwpstate_goto_pstate(device_t dev, int pstate) { + sbintime_t sbt; int i; uint64_t msr; int j; @@ -170,7 +171,7 @@ hwpstate_goto_pstate(device_t dev, int pstate) /* get the current pstate limit */ msr = rdmsr(MSR_AMD_10H_11H_LIMIT); limit = AMD_10H_11H_GET_PSTATE_LIMIT(msr); - if(limit > id) + if (limit > id) id = limit; /* @@ -184,7 +185,7 @@ hwpstate_goto_pstate(device_t dev, int pstate) sched_bind(curthread, i); thread_unlock(curthread); HWPSTATE_DEBUG(dev, "setting P%d-state on cpu%d\n", - id, PCPU_GET(cpuid)); + id, PCPU_GET(cpuid)); /* Go To Px-state */ wrmsr(MSR_AMD_10H_11H_CONTROL, id); } @@ -194,13 +195,14 @@ hwpstate_goto_pstate(device_t dev, int pstate) sched_bind(curthread, i); thread_unlock(curthread); /* wait loop (100*100 usec is enough ?) */ - for(j = 0; j < 100; j++){ + for (j = 0; j < 100; j++){ /* get the result. not assure msr=id */ msr = rdmsr(MSR_AMD_10H_11H_STATUS); - if(msr == id){ + if (msr == id) break; - } - DELAY(100); + sbt = SBT_1MS / 10; + tsleep_sbt(dev, PZERO, "pstate_goto", sbt, + sbt >> tc_precexp, 0); } HWPSTATE_DEBUG(dev, "result: P%d-state on cpu%d\n", (int)msr, PCPU_GET(cpuid));