From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756888AbcEDABG (ORCPT ); Tue, 3 May 2016 20:01:06 -0400 Received: from mga14.intel.com ([192.55.52.115]:57645 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756295AbcEDABE (ORCPT ); Tue, 3 May 2016 20:01:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,574,1455004800"; d="scan'208";a="96668103" Date: Tue, 3 May 2016 17:00:55 -0700 (PDT) From: Vikas Shivappa X-X-Sender: vikas@vshiva-Udesk To: Peter Zijlstra cc: Vikas Shivappa , Vikas Shivappa , tony.luck@intel.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, h.peter.anvin@intel.com Subject: Re: [PATCH 2/4] perf/x86/mbm: Store bytes counted for mbm during recycle In-Reply-To: <20160503074650.GF3430@twins.programming.kicks-ass.net> Message-ID: References: <1461371241-4258-1-git-send-email-vikas.shivappa@linux.intel.com> <1461371241-4258-3-git-send-email-vikas.shivappa@linux.intel.com> <20160425091311.GE3430@twins.programming.kicks-ass.net> <20160425200222.GM3448@twins.programming.kicks-ass.net> <20160503074650.GF3430@twins.programming.kicks-ass.net> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 May 2016, Peter Zijlstra wrote: > On Mon, Apr 25, 2016 at 02:12:09PM -0700, Vikas Shivappa wrote: > > >>> start: >>> prev_count = read_hw_counter(); >> >> I am assuming this means we keep the prev_count when event is initialized. >> This is done in the mbm_init which calls update_sample with first parameter >> set to true.. > > No, when pmu::start() is called. > >>> read: >>> do { >>> prev = prev_count; >>> cur_val = read_hw_counter(); >>> delta = cur_val - prev; >>> } while (local_cmpxchg(&prev_count, prev, cur_val) != prev); >>> count += delta; > > And this you do on pmu::{stop,read}() Ok. We have same function for del and stop in cqm. Also we do count for cqm.. So we end up reading the counter every sched_out. We avoided this to not have the overhead. Also we have the overflow of mbm counters on top of this. But I see how this can be done using the update_sample as the wrapper. start: prev = update_sample(rmid) // reads the counter and takes care of overflow. Basically replace the hw_counter call with the update_sample and also do the part thats done in the read in the overflow timer as well.. Will send an update. Thanks, Vikas