Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1687673ybz; Thu, 16 Apr 2020 13:42:56 -0700 (PDT) X-Google-Smtp-Source: APiQypKBiP3Ivn0JjDOkr/9tC/cGmQFGoGXuiNGqa2jJrwpCw+lybMMFXGHSXJFF4ZBzRHjV4ybP X-Received: by 2002:a05:6402:144c:: with SMTP id d12mr31049edx.225.1587069776659; Thu, 16 Apr 2020 13:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587069776; cv=none; d=google.com; s=arc-20160816; b=miVUh2iAD6GwhTHKcrrWOsEdJ4sT5xHfq04N4q3NNQK7AtMlf/KY65aNigGVvLWUBg y3cYbxUZiB5Fmb56Oz2uv/IbWDwk4p4eNcKyVCec+HL4aDS4vMlHJ6K1VDiI9nZG7uMM uJEV3wgtC79j1LkjqaGJrgZMobGZ7O8PULxpT3YKU0CopxFF8XLcFYAvTTNcFGKw395u dUuRWYfq9UMtuDft2Nqlow1JKirxnJ5BNtTkk8mEZzduUafscXQZmla/Hi7umAKW2c3i E5rxubc4ZnaKy2nMIh5o185FCzrNBkRXK20njOLzSDtfTpl+yvvZQsE3703Ld4X63Jeh umbA== 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:ironport-sdr:ironport-sdr; bh=LaRKllHFGmfCidXFeSS3YY2jYDQdYNo2Qnj6WKriEpU=; b=0/PWOrdTxk6PBNSpjRMPwmWfm00QNAwe2DSWFLIDzgH/WU8QXZuttPBMurG3PL9Lyn zbR+xFBBFUFJSpEXU99SJ/iEFWno83+IrKySJ98pp30fZnBmLpIomMHsKgELBLGb+Krb LJ1ed9hw6Qiqq1zfn1usZ/5k9e48RGM9Zj/YLRdZm/sgrgLflD7LlPxwL8f/zwNcP2HP qzmUqWb9ElkJ6o2GpR8WW+gTiDEtF7U+zg2bti2ENXel/2agzfdsvkW/c7wgBMg3o+Ce 4jWNkGDLjaCSg2EAaA2M58p8pqSkPqF30aZP8XACzkdTnxdrS0hvnz7Oybe+leZLRVJT PW7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si13102672edf.265.2020.04.16.13.42.34; Thu, 16 Apr 2020 13:42:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394520AbgDPRFn (ORCPT + 99 others); Thu, 16 Apr 2020 13:05:43 -0400 Received: from mga12.intel.com ([192.55.52.136]:7539 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730647AbgDPRFl (ORCPT ); Thu, 16 Apr 2020 13:05:41 -0400 IronPort-SDR: ZtviEUcwAw04AQ6vGY2G6qGqhVhluMbOfUY9MOTyDKQ/HBJlrfEQCTppp6icNF6lCYwwlEBLwe lgH+ydAGIQXQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2020 10:05:40 -0700 IronPort-SDR: r2p37llV8oTWEX2XJNI4HUD191O2WCdTioOapylF9eDQt2rnWXEtqiqUUUL7PgwyfxBRBlAi4M pxaUQq64DoUw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,391,1580803200"; d="scan'208";a="257290016" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by orsmga006.jf.intel.com with ESMTP; 16 Apr 2020 10:05:39 -0700 Date: Fri, 17 Apr 2020 01:06:11 +0800 From: Chen Yu To: Doug Smythies Cc: 'Len Brown' , "'Rafael J. Wysocki'" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [PATCH 2/3][v2] tools/power turbostat: Introduce functions to accumulate RAPL consumption Message-ID: <20200416170611.GA23628@chenyu-office.sh.intel.com> References: <001901d613a4$010e0a70$032a1f50$@net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001901d613a4$010e0a70$032a1f50$@net> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Doug, Thanks for reviewing this patch. On Wed, Apr 15, 2020 at 09:03:34PM -0700, Doug Smythies wrote: > On 2020.04.15 05:57 Chen Yu wrote: > > ... > > > v2: According to Len's suggestion: > > 1. Enable the accumulated RAPL mechanism by default. > > I am not a fan of this, but O.K. > > > 2. Re-use the rapl_joule_counter_range to represent the > > the timeout of periodical timer. > > No, please no. It is too easy to still have an overflow. > > ... > > + /* > > + * A wraparound time is calculated early. > > + */ > > + its.it_interval.tv_sec = rapl_joule_counter_range; > > Would this be o.K.? > > + its.it_interval.tv_sec = rapl_joule_counter_range / 2; > This should be okay. I've checked the defination of TDP, and on a wiki page it has mentioned that[1]: "Some sources state that the peak power for a microprocessor is usually 1.5 times the TDP rating" although the defination of TDP varies, using 2 * TDP should be safe. > > + its.it_interval.tv_nsec = 0; > > The way it was sent, this patch set does not work. > It still overflows. > > Example, sample time calculated to ensure overflow: > > Busy% Bzy_MHz IRQ PkgTmp PkgWatt GFXWatt > 100.00 3500 3592125 80 9.72 0.12 > 100.00 3500 3587391 79 9.77 0.12 > > Actual package watts was around 65. > > However, if this additional patch is applied (I only fixed one of them): > > doug@s18:~/temp-k-git/linux/tools/power/x86/turbostat$ git diff > diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c > index 29fc4069f467..4d72d9be5209 100644 > --- a/tools/power/x86/turbostat/turbostat.c > +++ b/tools/power/x86/turbostat/turbostat.c > @@ -1350,7 +1350,8 @@ delta_package(struct pkg_data *new, struct pkg_data *old) > > old->gfx_mhz = new->gfx_mhz; > > - DELTA_WRAP32(new->energy_pkg, old->energy_pkg); > +/* DELTA_WRAP32(new->energy_pkg, old->energy_pkg); */ > + old->energy_pkg = new->energy_pkg - old->energy_pkg; > DELTA_WRAP32(new->energy_cores, old->energy_cores); > DELTA_WRAP32(new->energy_gfx, old->energy_gfx); > DELTA_WRAP32(new->energy_dram, old->energy_dram); > > Then it seems to work. > Nice catch, I did not realize that the energy_pkg field has already been converted into accumuted variable which does not need to consider the wrapping(64bit should be long enough for normal test cases). Thanks, Chenyu > Example: > > doug@s15:~/temp-turbostat$ sudo ./turbostat --Summary --show Busy%,Bzy_MHz,PkgTmp,PkgWatt,GFXWatt,IRQ --interval 1200 > ... > RAPL: 690 sec. Joule Counter Range, at 95 Watts > ... > Busy% Bzy_MHz IRQ PkgTmp PkgWatt GFXWatt > 100.00 3500 3592328 80 64.32 0.12 > 100.00 3500 3595195 79 64.37 0.12 > > ... Doug > >