From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933236AbcFPBOK (ORCPT ); Wed, 15 Jun 2016 21:14:10 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:35549 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753209AbcFPBOH (ORCPT ); Wed, 15 Jun 2016 21:14:07 -0400 From: Vince Weaver X-Google-Original-From: Vince Weaver Date: Wed, 15 Jun 2016 21:13:59 -0400 (EDT) X-X-Sender: vince@macbook-air To: Huang Rui cc: Borislav Petkov , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Andy Lutomirski , Robert Richter , Jacob Shin , Arnaldo Carvalho de Melo , Kan Liang , linux-kernel@vger.kernel.org, spg_linux_kernel@amd.com, x86@kernel.org, Suravee Suthikulpanit , Aravind Gopalakrishnan , Borislav Petkov , Guenter Roeck , Fengguang Wu Subject: Re: [REDO PATCH v7] perf/x86/amd/power: Add AMD accumulated power reporting mechanism In-Reply-To: <1457502306-2559-1-git-send-email-ray.huang@amd.com> Message-ID: References: <1457502306-2559-1-git-send-email-ray.huang@amd.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org three questions about this functionality: 1. In theory this should also work on an amd fam16h model 30h processor too, correct? The current code limits things to fam15h even though the fam16mod30h has all the proper cpuid flags. I've tested the functionality a bit and it seems to work but for some reason the ptsc seems to occasionally count backwards on my machine. Any reason that would be? (It doesn't seem to be an overflow, just reading the ptsc 5ms apart and the values are slightly lower after than before). 2. Unless I'm misunderstanding things, the code seems to be accumulating Power. (see chunk below) Power is an instantaneous measurement, it makes no sense to add values. If you use 5W for 1ms and 10W for 1ms, the average power across the 2ms interval is not 15W. You can add energy, but not power. > + delta *= cpu_pwr_sample_ratio * 1000; > + tdelta = new_ptsc - prev_ptsc; > + > + do_div(delta, tdelta); > + local64_add(delta, &event->count); 3. The actual results gathered seem rediculously low. 341 seconds of calculation and only using 183 mWatts of power? > Performance counter stats for 'system wide': > > 183.44 mWatts power/power-pkg/ > > 341.837270111 seconds time elapsed > > root@hr-zp:/home/ray/tip# ./tools/perf/perf stat -a -e 'power/power-pkg/' sleep 10 Vince