Received: by 10.223.164.202 with SMTP id h10csp1661719wrb; Thu, 16 Nov 2017 02:03:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMZCc9uk+PzE8Z4elOwTofu0ccfZB+4alvIW8vNWQdDHaCYcdLcWohBj24hBGBXdukQZsVjb X-Received: by 10.84.244.129 with SMTP id h1mr1139484pll.255.1510826585839; Thu, 16 Nov 2017 02:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510826585; cv=none; d=google.com; s=arc-20160816; b=iIKjXPlciHiLsfxI0XaHkATjpXMFU180ss5EzGALSIYi1Shih15G6wXrpBefNBuw/X k87ZWKNvvYRVfDmq53d9MmD9GDFYqmzu5IuFn8z6fEmouaKJkGjQzVNmuh+LA0JWtYx4 Bj5kN6XX29ncAxWCZVTc7zW3uynXT0Y+2WQFcEYMj+e2aCqZPoMI9Ovq7eBGYVV/aysb WToMnKdk0HKhnRUcYeKceaP83f4C1VO7uRoNhbcl87rJkILKcDnunOabiZd3FL+BXsMg 6Y/Vyy5ZGWI2A/6bJxAwhBTnUgDaibPMTxdC7+JeMNoL96TBnDeUaXAvhj+1Ub42xBob zWOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=AgQ+F/J06vRS9gUk3/RXlpnRmGl2Big+RKb/fBUsbgc=; b=ueLSzCDQntb9e8Yo1EuUFaxwmCzRGwPcsKWBnyHfRxRWe1WzlmxESfKOowgR3Ln0lW KhTea5fEKNl26nqGR0V47zdi2bSDnCdkrMhg+pHUTjqooUNdtvhLOa/Rm7kLT2i1vW0Q 3s9NF6jPK8DdtvPZlNx1LcsPrQ4y9GAIgBxOPU6t6pEGysoNTV0FT8YFvOHJmBAlUgmX izFgVJqatxFg6+X3+b6LXDsdBHdif3eGHbAUojCaDC9IYC3vZlJSeOwvzZ/dybTj5YrK yvekPj5AOqq/WpPgxAKF7RrM5yp3C8hXwvksRMXmpktqR19BIBrTDWJCt/oTvMdYlodh MjOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ucloud.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 88si595539plf.291.2017.11.16.02.02.51; Thu, 16 Nov 2017 02:03:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ucloud.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759524AbdKPJzJ (ORCPT + 91 others); Thu, 16 Nov 2017 04:55:09 -0500 Received: from m97139.mail.qiye.163.com ([220.181.97.139]:33585 "EHLO m97139.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759363AbdKPJy4 (ORCPT ); Thu, 16 Nov 2017 04:54:56 -0500 Received: from localhost (unknown [106.38.57.250]) by smtp10 (Coremail) with SMTP id vOCowAD3EVBsXw1aF_cIAA--.13S3; Thu, 16 Nov 2017 17:50:36 +0800 (CST) Date: Thu, 16 Nov 2017 17:50:36 +0800 From: WANG Chao To: "Rafael J. Wysocki" Cc: Linux Kernel Mailing List , Linus Torvalds , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Vikas Shivappa , Kate Stewart , Len Brown , Greg Kroah-Hartman , Philippe Ombredanne , Mathias Krause , the arch/x86 maintainers , Linux PM , "Rafael J. Wysocki" Subject: Re: [PATCH] x86 / CPU: Always show current CPU frequency in /proc/cpuinfo Message-ID: <20171116095036.GB28750@WANG-Chaos-MacBook-Pro.local> References: <20171109103814.70688-1-chao.wang@ucloud.cn> <50366815.86mgx8Isne@aspire.rjw.lan> <20171115093347.GA28750@WANG-Chaos-MacBook-Pro.local> <8646127.yoBvgp8gpO@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8646127.yoBvgp8gpO@aspire.rjw.lan> User-Agent: Mutt/1.9.1 (2017-09-22) X-CM-TRANSID: vOCowAD3EVBsXw1aF_cIAA--.13S3 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjfUpq-eUUUUU X-Originating-IP: [106.38.57.250] X-CM-SenderInfo: pfkd0hpzdqwq5xfo03fgof0/1tbibw2SVFlZsxUU-AAAsq Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/16/17 at 01:24P, Rafael J. Wysocki wrote: > On Wednesday, November 15, 2017 10:33:47 AM CET WANG Chao wrote: > > On 11/15/17 at 02:13P, Rafael J. Wysocki wrote: > > > From: Rafael J. Wysocki > > > > > > After commit 890da9cf0983 (Revert "x86: do not use cpufreq_quick_get() > > > for /proc/cpuinfo "cpu MHz"") the "cpu MHz" number in /proc/cpuinfo > > > on x86 can be either the nominal CPU frequency (which is constant) > > > or the frequency most recently requested by a scaling governor in > > > cpufreq, depending on the cpufreq configuration. That is somewhat > > > inconsistent and is different from what it was before 4.13, so in > > > order to restore the previous behavior, make it report the current > > > CPU frequency like the scaling_cur_freq sysfs file in cpufreq. > > > > > > To that end, modify the /proc/cpuinfo implementation on x86 to use > > > aperfmperf_snapshot_khz() to snapshot the APERF and MPERF feedback > > > registers, if available, and use their values to compute the CPU > > > frequency to be reported as "cpu MHz". > > > > > > However, do that carefully enough to avoid accumulating delays that > > > lead to unacceptable access times for /proc/cpuinfo on systems with > > > many CPUs. Run aperfmperf_snapshot_khz() once on all CPUs > > > asynchronously at the /proc/cpuinfo open time, add a single delay > > > upfront (if necessary) at that point and simply compute the current > > > frequency while running show_cpuinfo() for each individual CPU. > > > > Hi, Rafael > > > > I tested your patch. It's much faster. > > > > But from what I got, calling aperfmperf_snapshot_khz() asynchronously > > with 10ms sleep takes much longer than calling aperfmperf_snapshot_khz() > > synchronously. > > > > Here's my result on 64 CPUs: > > > > - async aperfmperf_snapshot_khz() w/ 10ms sleep: > > > > # time cat /proc/cpuinfo > /dev/null > > real 0m0.014s > > user 0m0.000s > > sys 0m0.002s > > > > - sync aperfmperf_snapshot_khz() w/o any sleep: > > > > # time cat /proc/cpuinfo > /dev/null > > real 0m0.002s > > user 0m0.000s > > sys 0m0.002s > > Sure, but the delay is there, because without it the computed frequency > may be way off for at least one of the CPUs. Thanks, I understand now. In this case, The 10ms delay turns out to be the interval of measuring aperf and mperf and computing their deltas. Last question though, is 10ms best practice or can we make it shorter, say 5ms? Thanks, WANG Chao From 1584190478105938423@xxx Thu Nov 16 03:09:31 +0000 2017 X-GM-THRID: 1584093074206377441 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread