Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964819AbcDYUC1 (ORCPT ); Mon, 25 Apr 2016 16:02:27 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:50943 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933361AbcDYUC0 (ORCPT ); Mon, 25 Apr 2016 16:02:26 -0400 Date: Mon, 25 Apr 2016 22:02:22 +0200 From: Peter Zijlstra To: Vikas Shivappa Cc: 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 Message-ID: <20160425200222.GM3448@twins.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1004 Lines: 35 On Mon, Apr 25, 2016 at 11:04:38AM -0700, Vikas Shivappa wrote: > >This is a 'creative' solution; why don't you do the normal thing, which > >is: > > > >start: > > prev_count = read_hw_counter(); > > > >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; > > > I may need to update the comment. > > rc_count stores the total bytes for RMIDs that were used for this event > except for the count of current RMID. Yeah, I got that, eventually. > Say an event used RMID(1) .. RMID(k) from init to read and it had RMID(k) > when read was called, the rc_count stores the values read from RMID1 .. > RMID(k-1). > > For MBM the patch is trying to do: > count > = total_bytes of RMID(1) + ... +total_bytes of RMID(k-1) + total_bytes of > RMID(k)) > = rc_count + total_bytes of RMID(k). How is the regular counting scheme as outlined above not dealing with this properly?