Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp608166ybb; Fri, 3 Apr 2020 08:37:23 -0700 (PDT) X-Google-Smtp-Source: APiQypLLtCcfrxrHKHWJVYuFu3CCNwn1tN0Box005fK+2MF3/5wfpTIQFTuy19woyC/Q5Evg+WiS X-Received: by 2002:a05:6830:1610:: with SMTP id g16mr6629969otr.358.1585928243829; Fri, 03 Apr 2020 08:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585928243; cv=none; d=google.com; s=arc-20160816; b=cgM36VoWtCwYlKXu73fuUZlwYAfcixVG7xSlHv2j1saK415SYK3sIrdObabquCSrVh 2it2rpNDIvW7JV/EElp1XVNFVTSSyaI6gm+qOx9Vlx2S6T1Ejo+9IQ+7Y2jC90+Z3a0D Ggiz+UFuYhcz1qQNvoGaG203H3TkPgfk5aztP4m4dkC6rMCgb39fmLF7WPGSNGZFqTCk 3rSyXJoJLanIDddKM+8sXZZcZ3FEDxmhWuPw1ueXXvdGgmtd1yeEM8r+NvYhpLn/Kl6B f0OnNpfLYqF4bKQvjvDZSR2ZCsWYoTsfXFIUC2r0QRdkp10bnwWefVe9L8Q0e0nrmpef Jpjw== 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=X+0XagN+WdKWxAjPAsjjU+/R3yk6xgryAnRewRRYpKg=; b=UHMoeALEE88t39EWb794YUop2MB4zOsJ/igSQcTiHQUoiASAhuGuNmlVgJ12COIt1A F0N64Z4SxHjfdt132GKFsfPNsidlhqnBzAZ0VSvzKW8k1tjryuk0BHgK00kcOBHmbgQZ 36X8evcFtG7U4duo96r3TwHhjtsiJMJuXg9j9qKxuFw3In6YqQ1wRjCpe/VyKisRSbVt nkOshkszEdjGWVRfDsfLKt4xaSLESr8S9jPccimpMlJB2HLqXir+i0wRGTrbn137HcM+ 7kiGtwqapnQbBfPHmMW/EBDERsaKsEJevpUH6eTG+qofr0K5Kpc4alXG5CZR2Jum2q6o fNUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id f41si3835896otf.280.2020.04.03.08.37.10; Fri, 03 Apr 2020 08:37:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2404300AbgDCPfv (ORCPT + 99 others); Fri, 3 Apr 2020 11:35:51 -0400 Received: from mga12.intel.com ([192.55.52.136]:61909 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404171AbgDCPfv (ORCPT ); Fri, 3 Apr 2020 11:35:51 -0400 IronPort-SDR: 999bLMYgJypysDSYO6K+LdzvS27N2nR5fBb+2nZv71FqPv8R0XImzTqhWMNi09MHZmzIt0MSSS qc84Qcbj0hYA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 08:35:50 -0700 IronPort-SDR: /8Kx6Fr3AFBUEFndItwYFkDShMvhjJOcyYzK0tosICU3Z1Mr3oLvqfzhg0ol3bpphYKwxrJrQj K05dBsTZ94nA== X-IronPort-AV: E=Sophos;i="5.72,340,1580803200"; d="scan'208";a="329197211" Received: from rchatre-mobl.amr.corp.intel.com (HELO [10.251.28.58]) ([10.251.28.58]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 08:35:50 -0700 Subject: Re: [PATCH 2/2] x86/resctrl: Use appropriate API for strings terminated by newline To: Andy Shevchenko Cc: Andy Shevchenko , Thomas Gleixner , Fenghua Yu , Borislav Petkov , Tony Luck , kuo-lang.tseng@intel.com, Ingo Molnar , babu.moger@amd.com, "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Linux Kernel Mailing List References: <2a51c327497738ad7012e4f185046c530dba4594.1585765499.git.reinette.chatre@intel.com> <20200402130625.GA1922688@smile.fi.intel.com> <720ab442-3e2e-bd6d-d35c-5cc5de1d9824@intel.com> From: Reinette Chatre Message-ID: <13499ebf-dd5f-1940-3d01-366f038d5a66@intel.com> Date: Fri, 3 Apr 2020 08:35:49 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: 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 4/3/2020 12:27 AM, Andy Shevchenko wrote: > On Fri, Apr 3, 2020 at 12:54 AM Reinette Chatre > wrote: >> On 4/2/2020 6:06 AM, Andy Shevchenko wrote: >>> On Wed, Apr 01, 2020 at 11:30:48AM -0700, Reinette Chatre wrote: ... >>>> /* Valid input requires a trailing newline */ >>>> if (nbytes == 0 || buf[nbytes - 1] != '\n') >>>> return -EINVAL; >>>> - buf[nbytes - 1] = '\0'; >>> >>> The above test is not needed and comment now is misleading. >>> WRT nbytes I believe that kernel fs code checks for that. > > This module provides it's own kernfs_ops... > >> If nbytes is 0 it is still passed to this function. You are correct that >> those tests are not needed though (if nbytes is 0 then >> sysfs_match_string() will not find a match and return EINVAL via that path). >> >> Thank you for catching this. I'll remove those unnecessary checks. > > ...which means that nbytes == 0 is a valid check. Please keep it > there. It will protect from unnecessary locking and loading CPU for > nothing. > Will do. Thank you. Reinette