From owner-svn-src-head@freebsd.org Thu Nov 30 20:21:44 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 18FACE6AB2D; Thu, 30 Nov 2017 20:21:44 +0000 (UTC) (envelope-from jkim@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 D94E872FBD; Thu, 30 Nov 2017 20:21:43 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAUKLgKr016747; Thu, 30 Nov 2017 20:21:42 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAUKLgNg016746; Thu, 30 Nov 2017 20:21:42 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201711302021.vAUKLgNg016746@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Thu, 30 Nov 2017 20:21:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326407 - head/sys/x86/cpufreq X-SVN-Group: head X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: head/sys/x86/cpufreq X-SVN-Commit-Revision: 326407 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.25 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, 30 Nov 2017 20:21:44 -0000 Author: jkim Date: Thu Nov 30 20:21:42 2017 New Revision: 326407 URL: https://svnweb.freebsd.org/changeset/base/326407 Log: Properly skip the first CPU. It only accidentally worked because the CPU_FOREACH() loop always starts from BSP (cpu0) and the if condition is always false for APs. Reported by: cem Modified: head/sys/x86/cpufreq/hwpstate.c Modified: head/sys/x86/cpufreq/hwpstate.c ============================================================================== --- head/sys/x86/cpufreq/hwpstate.c Thu Nov 30 17:58:48 2017 (r326406) +++ head/sys/x86/cpufreq/hwpstate.c Thu Nov 30 20:21:42 2017 (r326407) @@ -167,10 +167,8 @@ static int hwpstate_goto_pstate(device_t dev, int id) { sbintime_t sbt; - int i; uint64_t msr; - int j; - int limit; + int cpu, i, j, limit; /* get the current pstate limit */ msr = rdmsr(MSR_AMD_10H_11H_LIMIT); @@ -178,8 +176,8 @@ hwpstate_goto_pstate(device_t dev, int id) if (limit > id) id = limit; - HWPSTATE_DEBUG(dev, "setting P%d-state on cpu%d\n", id, - PCPU_GET(cpuid)); + cpu = curcpu; + HWPSTATE_DEBUG(dev, "setting P%d-state on cpu%d\n", id, cpu); /* Go To Px-state */ wrmsr(MSR_AMD_10H_11H_CONTROL, id); @@ -188,7 +186,7 @@ hwpstate_goto_pstate(device_t dev, int id) * Probably should take _PSD into account. */ CPU_FOREACH(i) { - if (i == PCPU_GET(cpuid)) + if (i == cpu) continue; /* Bind to each cpu. */