From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754045AbbIKVLV (ORCPT ); Fri, 11 Sep 2015 17:11:21 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:37859 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753779AbbIKVLU (ORCPT ); Fri, 11 Sep 2015 17:11:20 -0400 Date: Fri, 11 Sep 2015 22:11:17 +0100 From: Matt Fleming To: Kanaka Juvva Cc: Matt Fleming , Thomas Gleixner , Kanaka Juvva , "Williamson, Glenn P" , "Auld, Will" , Andi Kleen , LKML , "Luck, Tony" , Peter Zijlstra , Tejun Heo , "x86@kernel.org" , Ingo Molnar , "H. Peter Anvin" , "Shivappa, Vikas" Subject: Re: [PATCH v3 1/2] perf,x86: add Intel Memory Bandwidth Monitoring (MBM) PMU Message-ID: <20150911211117.GB2537@codeblueprint.co.uk> References: <1439016145-7505-1-git-send-email-kanaka.d.juvva@linux.intel.com> <06033C969873E840BDE9FC9B584F66B51944F51B@ORSMSX116.amr.corp.intel.com> <1441712834.9911.39.camel@intel.com> <06033C969873E840BDE9FC9B584F66B51944F741@ORSMSX116.amr.corp.intel.com> <1441893520.8271.39.camel@intel.com> <1441919929.8892.10.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441919929.8892.10.camel@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 10 Sep, at 02:18:49PM, Kanaka Juvva wrote: > > > > > > > > } else { > > > > > mbm_current = &mbm_total[vrmid]; > > > > > eventid = QOS_MBM_TOTAL_EVENT_ID; > > > > > } > > > > > rmid = tmp32; > > > > > > > > Why did you assign rmid to vrmid if you reassign it before it was used? > > > > > > > > > > > > > > For MSR writes we use rmid value and for mbm_* arrary we use vrmid which is actual > > > index. > > > > What I'm saying is that the assignment rmid = vrmid looks unnecessary in > > this piece of code. > > > > From my previous review: > > "This is completely backwards. > > tmp32 = rmid; > rmid = vrmid; > do_stuff(rmid); > rmid = tmp32; > do_other_stuff(rmid); > > Why can't you use vrmid for do_stuff() and leave rmid alone? Just > because it would make the code simpler to read?" > > I have included Thomas comment inline above. > > and also I meant the following logic: > > writemsr(..,rmid,...) > mbm_*[vrmid] > > So new patch will use this logic. OK, let's pull the code in and discuss this with some context, u64 val, currentmsr, currentbw, diff_time, cma, bytes, index; bool overflow = false, first = false; ktime_t cur_time; u32 tmp32 = rmid, eventid; struct sample *mbm_current; u32 vrmid = rmid_2_index(rmid); rmid = vrmid; <--------- This looks wrong cur_time = ktime_get(); if (read_mbm_local) { mbm_current = &mbm_local[vrmid]; eventid = QOS_MBM_LOCAL_EVENT_ID_HW; wrmsr(MSR_IA32_QM_EVTSEL, QOS_MBM_LOCAL_EVENT_ID_HW, rmid); <---- Unneccesary because.. } else { mbm_current = &mbm_total[vrmid]; eventid = QOS_MBM_TOTAL_EVENT_ID; } rmid = tmp32; wrmsr(MSR_IA32_QM_EVTSEL, eventid, rmid); <----- ... you write here So you don't actually use 'rmid' within that if/else block. You can probably get away with deleting 'tmp32' now that you've refactored things. -- Matt Fleming, Intel Open Source Technology Center