Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934005AbdGKVh6 (ORCPT ); Tue, 11 Jul 2017 17:37:58 -0400 Received: from mga05.intel.com ([192.55.52.43]:45612 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933396AbdGKVh5 (ORCPT ); Tue, 11 Jul 2017 17:37:57 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,347,1496127600"; d="scan'208";a="1150503495" Date: Tue, 11 Jul 2017 14:37:56 -0700 From: "Luck, Tony" To: Shivappa Vikas Cc: Thomas Gleixner , Vikas Shivappa , x86@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, peterz@infradead.org, ravi.v.shankar@intel.com, fenghua.yu@intel.com, andi.kleen@intel.com Subject: Re: [PATCH 14/21] x86/intel_rdt/cqm: Add mon_data Message-ID: <20170711213755.cnlyaif3ah3keoi2@intel.com> References: <1498503368-20173-1-git-send-email-vikas.shivappa@linux.intel.com> <1498503368-20173-15-git-send-email-vikas.shivappa@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1974 Lines: 59 On Tue, Jul 11, 2017 at 02:17:47PM -0700, Shivappa Vikas wrote: > > > On Thu, 6 Jul 2017, Thomas Gleixner wrote: > > > On Thu, 6 Jul 2017, Shivappa Vikas wrote: > > > On Sun, 2 Jul 2017, Thomas Gleixner wrote: > > > > > +static bool __mon_event_count(u32 rmid, struct rmid_read *rr) > > > > > +{ > > > > > + u64 tval; > > > > > + > > > > > + tval = __rmid_read(rmid, rr->evtid); > > > > > + if (tval & (RMID_VAL_ERROR | RMID_VAL_UNAVAIL)) { > > > > > + rr->val = tval; > > > > > + return false; > > > > > + } > > > > > + switch (rr->evtid) { > > > > > + case QOS_L3_OCCUP_EVENT_ID: > > > > > + rr->val += tval; > > > > > + return true; > > > > > + default: > > > > > + return false; > > > > > > > > I have no idea what that return code means. > > > > > > false for the invalid event id and all errors for __rmid_read. (IOW all errors > > > for __mon_event-read) > > > > Sure, but why bool? What's wrong with proper error return codes, so issues > > can be distinguished and potentially propagated in the callchain? > > Ok, The error is propagated wih the rr->val actually. is this better? > > Hardware throws the RMID_VAL_ERROR (bit 63) when an invalid RMID or > event is written to event select - this case seems similar. > > default: > rr->val = RMID_VAL_ERROR; > return -EINVAL; > } I'll take the blame for not documenting this better. What's going on here is that we are calculating the sum of some list of RMIDs (for the case where we read a mon_data/*/* file for a CTRL_MON group that has some MON subgroups ... when reading a from a MON group there is only one RMID). Now we might get an error reading one of those (either or both of RMID_VAL_ERROR and RMID_VAL_UNAVAIL bits set). In which case we can't compute the sum, and there is no point in reading any more RMIDs. So the return of this function is: true: I read this RMID OK and added it to rr->val false: I got an error. Give up. The error type is in the high bits of rr->val -Tony