Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933266AbcCGX1u (ORCPT ); Mon, 7 Mar 2016 18:27:50 -0500 Received: from mga02.intel.com ([134.134.136.20]:7259 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933325AbcCGX12 convert rfc822-to-8bit (ORCPT ); Mon, 7 Mar 2016 18:27:28 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,554,1449561600"; d="scan'208";a="904363275" From: "Luck, Tony" To: Peter Zijlstra , Vikas Shivappa CC: "Shivappa, Vikas" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "hpa@zytor.com" , "tglx@linutronix.de" , "mingo@kernel.org" , "Shankar, Ravi V" , "Yu, Fenghua" , "Anvin, H Peter" Subject: RE: [PATCH 4/6] x86/mbm: Memory bandwidth monitoring event management Thread-Topic: [PATCH 4/6] x86/mbm: Memory bandwidth monitoring event management Thread-Index: AQHRdBTRYrill/rqkU+ff/3h6/+MD59PKRKA//99WGA= Date: Mon, 7 Mar 2016 23:27:26 +0000 Message-ID: <3908561D78D1C84285E8C5FCA982C28F3A000C1D@ORSMSX114.amr.corp.intel.com> References: <1456876108-28770-1-git-send-email-vikas.shivappa@linux.intel.com> <1456876108-28770-5-git-send-email-vikas.shivappa@linux.intel.com> <20160307230329.GT6344@twins.programming.kicks-ass.net> In-Reply-To: <20160307230329.GT6344@twins.programming.kicks-ass.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDViNTY5MzAtNjM1My00YzcwLTgwN2EtOTI0ZGRlNDAxOTVkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InhGd21KRTZac0tvSER4MmtiaTN2ZVdnUzNGUXk4andZN0ZlNW1vNVFWeHM9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.22.254.139] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1208 Lines: 28 >> + bytes = mbm_current->interval_bytes * MSEC_PER_SEC; >> + do_div(bytes, diff_time); >> + mbm_current->bandwidth = bytes; >> + mbm_current->interval_bytes = 0; >> + mbm_current->interval_start = cur_time; >> + } >>> + >> + return mbm_current; >> +} > > How does the above time tracking deal with the event not actually having > been scheduled the whole time? That's been the topic of a few philosophical debates ... what exactly are we trying to say when we report that a process has a "memory bandwidth" of, say, 1523 MBytes/s? We need to know both the amount of data moved and to pick an interval to measure and divide by. Does it make a difference whether the process voluntarily gave up the cpu for some part of the interval (by blocking on I/O)? Or did the scheduler time-slice it out to run other jobs? The above code gives the average bandwidth across the last interval (with a minimum interval size of 100ms to avoid craziness with rounding errors on exceptionally tiny intervals). Some folks apparently want to get a "rate" directly from perf. I think many folks will find the "bytes" counters more helpful (where they control the sample interval with '-I" flag to perf utility). -Tony