Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3628877ybk; Tue, 19 May 2020 09:10:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWqK+xZPD4dASw2VG7byKCQe+i/ipbJAgcbyfYlqwfSCgroLYynstZYF92fZ6K3l9BQHbP X-Received: by 2002:a17:906:7211:: with SMTP id m17mr1262355ejk.548.1589904617942; Tue, 19 May 2020 09:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589904617; cv=none; d=google.com; s=arc-20160816; b=I3XBFzvFKfQU8bZh0TFB7uJ1LGB4XVzGddeg70YxPEUbZEBC7HPK12XeTVwv4KkIUT 3Jk3Q+Dc1CtzYiPvnX1pYdfMbFOL5zRXpYmk0nPXBZsjGvmcvJ3/EIvs+CIUPkcHDprk UkGArg/5jywLS67PueDHjZCRZzgPERKSfm+q72U1l8NNI0C8jhLVf6oh89UPZI8+niai Wp+9meG+yrs+lDaHEJsApltco03SMHmOOrCvQHFKE3+BS3jgQQOJ3Bh7GoJqUwcZhaZF Hu3fMDJs3dmNjj3fdTVu/+WXVDT6T0X7ZtFBp1Kh49aox5CFHpsLGKtfMAIcwA4mPt5c xlCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=076cehxGRo22uvYzPO/LQlJkWUuQn/8kauqBrmWqS4g=; b=lXliAlo3WSfbfynSfWwewL0Q/Ga6UNEr/bJ5ylW0XIznieD27nyM8YsXqPMY83ob2+ x1MGso9T3otseWKK1n/u9TXv8PyWx/jWTEW8WVV2Q+1ZZ1g+F6E9zyV+b6tF8nZvbitY j2Id2s4OoM5XvKkOfRArfVAOrF3IybGGqsY8BJVR2d1g3U5SiMAmYD1cdPEIz7cyGz1v 8twqTaYIF2N+YRaA4bGuBS1TkHLfVo77kgFNIf3GmivMkHfsmJ9J8Ei4b59YXqLdNow0 qzVFydRWHjwj0Pi8ma6rO4grhpGsbWWttJTAvMrf/NgcHSZNNUmtWBf6AfJ9Ok9w1WI9 9ygw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr10si156551ejc.190.2020.05.19.09.09.44; Tue, 19 May 2020 09:10:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729290AbgESQHN (ORCPT + 99 others); Tue, 19 May 2020 12:07:13 -0400 Received: from mga07.intel.com ([134.134.136.100]:35299 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729163AbgESQHM (ORCPT ); Tue, 19 May 2020 12:07:12 -0400 IronPort-SDR: ZlzsSj4r6qNyZvDH82VV2Vnk5O/FJ25tW6CZ1clMmmz83R4F2g/xXYa5LyaAOdaFeroleBCBHa D5RBl+2bQBFg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2020 09:07:10 -0700 IronPort-SDR: VlKkK3daLDIlq6QVXRViMYsT7nUGhrqA9YqgwgXRQ27g2cEvwvgGbVvFKOVTaanqCukq7/qv/t bGmpaL47aBKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,410,1583222400"; d="scan'208";a="411684759" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga004.jf.intel.com with ESMTP; 19 May 2020 09:07:07 -0700 Received: from andy by smile with local (Exim 4.93) (envelope-from ) id 1jb4lq-007g71-KH; Tue, 19 May 2020 19:07:10 +0300 Date: Tue, 19 May 2020 19:07:10 +0300 From: Andy Shevchenko To: Reinette Chatre Cc: Thomas Gleixner , Fenghua Yu , Borislav Petkov , Tony Luck , kuo-lang.tseng@intel.com, ravi.v.shankar@intel.com, Ingo Molnar , Babu Moger , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Linux Kernel Mailing List Subject: Re: [PATCH V5 4/4] x86/resctrl: Use appropriate API for strings terminated by newline Message-ID: <20200519160710.GK1634618@smile.fi.intel.com> References: <4a9603b8-32fb-024a-e2f5-14e95b4e3763@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a9603b8-32fb-024a-e2f5-14e95b4e3763@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 19, 2020 at 08:50:22AM -0700, Reinette Chatre wrote: > On 5/19/2020 1:28 AM, Andy Shevchenko wrote: > > On Tue, May 19, 2020 at 2:50 AM Reinette Chatre > > wrote: ... > >> + ret = sysfs_match_string(rdt_mode_str, buf); > >> + if (ret < 0) { > >> + rdt_last_cmd_puts("Unknown or unsupported mode\n"); > >> + ret = -EINVAL; > >> + goto out; > >> + } > > From your previous email ... > > >> + ret = sysfs_match_string(rdt_mode_str, buf); > >> + if (ret < 0) { > >> + rdt_last_cmd_puts("Unknown or unsupported mode\n"); > > > >> + ret = -EINVAL; > > > > This is redundant. > > I understand that shadowing an error code is generally of concern. In > this case the error code is set to -EINVAL to ensure that it is the same > error code that was returned to user space originally and will continue > to be so no matter what changes may come to sysfs_match_string(). It returns -EINVAL and if that will be ever changed this driver would be one of hundreds who suffers. ... > > Can't we unify latter with a former like ... > This would have been ideal if done from the start but currently "0" is > returned if the current mode is pseudo-locked and user attempts to > change the mode to pseudo-locked. Thus, to maintain the current user > interface the check if user wants to set pseudo-locked mode is moved > after the check if new mode is same as existing mode and thus not > unified because that will result in an error returned always when user > requests pseudo-locked mode. Ah, I see now. But we can then drop the check from sysfs_match_string() returned value, like user_m = sysfs_match_string(); if (...) { ... } else { // w/o even checking for the PSEUDO_LOCKED ... goto out; } Can we? -- With Best Regards, Andy Shevchenko