Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3704810ybk; Tue, 19 May 2020 10:59:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdqfGEFH/IfFCYdQgvd+AoHs2JShrNsK1SJSO1EQflz4mGZF7TnaPYAlpDfN+vfogftdHV X-Received: by 2002:a17:906:4e87:: with SMTP id v7mr387247eju.384.1589911144847; Tue, 19 May 2020 10:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589911144; cv=none; d=google.com; s=arc-20160816; b=Fy/B/IJ7kRz9axw1pot3L6P7xYyqPgrGP+FYGzf+NMW8uVDvTvd1rUtDSkDaoPZhlc R/sUsgh4j5oi4QV8iXF9Ct6mRmehaFqLCFCmyzKTmgjwkaxQpWo+peCTjsTClG29dmwt Iylp09ilK9gJmkCduE2JSq6DYelE4+3LBdLP2V9Noh4n02IQJA+gcO0J4SwyKGTgGW82 KaOXrdIYZk3NKFrunKDpJUjG0nPhKv+7nmOtpiLsAUA1Xe2BPXHeSoLxzT0ZF+yFgY/x UwyrDmrR1ntJ2PF9a70g2bSJbJeqk99zde2pRegf7Twio2Sup30Zjmv2pAYPBlcANm+j sjoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=ra1eOr2pHSpC2Yjx424Gs2A+BF2je4ZrQ5kPxxqCXpc=; b=lpSfBTn9ZBCWFZRVsetBMzeWFWT4IVvzAZ4n+ulNyUS/JHGDhuUQyrnkXHv8Lhfk1N jmKqvh5KJRyWgn/KaYtQvQCvdOvKcHNbriiN6Nah+8Ni7LsD9YVGH7r3h9+hao+LDEaU wKjDBSFcq8L4SXK1POH9x3ZQHRT0gX/9/ak5iEo1VkPZZkDBdALxCY/db1Jfykw8eV5H fuMUkQmULpHuaTO6p75sULBNPXgRcUetMY4z/OnVFM2GGF+7ugMqd/CYJAZF7w/8m5Iy W2h28NWnQUPdFJxt8GoB/TyfByxyOq7ehoEUbh7b4p6gDadvztPpBV+CXCWrXiWlweGr ETUA== 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w15si60608edi.597.2020.05.19.10.58.41; Tue, 19 May 2020 10:59:04 -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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbgESRy4 (ORCPT + 99 others); Tue, 19 May 2020 13:54:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:45549 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbgESRy4 (ORCPT ); Tue, 19 May 2020 13:54:56 -0400 IronPort-SDR: Q43gCF6nAzm+KczJ8J8u3FB2Z1E14Btw9dTRv3+LSIsfrF0Ppw4XdNGCyHP2vyKmW2Xywhe0uX SzHX4OB1djvA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2020 10:54:54 -0700 IronPort-SDR: hpPnUjjcjcPumfqHPKVthzvzlEuENKNnPVgsTW0wCgzE3FsftI1zpMToUV9TUSRC9AinDR/6dS tFZ1ILxHWeow== X-IronPort-AV: E=Sophos;i="5.73,410,1583222400"; d="scan'208";a="439705633" Received: from rchatre-mobl.amr.corp.intel.com (HELO [10.255.229.46]) ([10.255.229.46]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2020 10:54:53 -0700 Subject: Re: [PATCH V5 4/4] x86/resctrl: Use appropriate API for strings terminated by newline To: Andy Shevchenko 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 References: <4a9603b8-32fb-024a-e2f5-14e95b4e3763@intel.com> <20200519160710.GK1634618@smile.fi.intel.com> From: Reinette Chatre Message-ID: <87d00e95-7944-2fa4-fd02-1662ec4382fe@intel.com> Date: Tue, 19 May 2020 10:54:52 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200519160710.GK1634618@smile.fi.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On 5/19/2020 9:07 AM, Andy Shevchenko wrote: > 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. Not if we keep this change ... but that is no longer of concern with the removal of the check as you propose later. > > ... > >>> 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? > Yes, we can. Will do. Reinette