From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BABF4C10F25 for ; Mon, 9 Mar 2020 21:45:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E12124649 for ; Mon, 9 Mar 2020 21:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727250AbgCIVpA (ORCPT ); Mon, 9 Mar 2020 17:45:00 -0400 Received: from mga01.intel.com ([192.55.52.88]:29758 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727233AbgCIVo4 (ORCPT ); Mon, 9 Mar 2020 17:44:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 14:44:55 -0700 X-IronPort-AV: E=Sophos;i="5.70,534,1574150400"; d="scan'208";a="245476220" Received: from rchatre-mobl.amr.corp.intel.com (HELO [10.251.21.24]) ([10.251.21.24]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 09 Mar 2020 14:44:54 -0700 Subject: Re: [PATCH V1 01/13] selftests/resctrl: Fix feature detection To: Sai Praneeth Prakhya , shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org References: <7e3e4b91f5786a489e68eecda21e1d8049b60181.1583657204.git.sai.praneeth.prakhya@intel.com> From: Reinette Chatre Message-ID: Date: Mon, 9 Mar 2020 14:44:53 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <7e3e4b91f5786a489e68eecda21e1d8049b60181.1583657204.git.sai.praneeth.prakhya@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 Sai, On 3/6/2020 7:40 PM, Sai Praneeth Prakhya wrote: > From: Reinette Chatre > > The intention of the resctrl selftests is to only run the tests > associated with the feature(s) supported by the platform. Through > parsing of the feature flags found in /proc/cpuinfo it is possible > to learn which features are supported by the plaform. > > There are currently two issues with the platform feature detection that > together result in tests always being run, whether the platform supports > a feature or not. First, the parsing of the the feature flags loads the > line containing the flags in a buffer that is too small (256 bytes) to > always contain all flags. The consequence is that the flags of the features > being tested for may not be present in the buffer. Second, the actual > test for presence of a feature has an error in the logic, negating the > test for a particular feature flag instead of testing for the presence of a > particular feature flag. > > These two issues combined results in all tests being run on all > platforms, whether the feature is supported or not. > > Fix these issue by (1) increasing the buffer size being used to parse > the feature flags, and (2) change the logic to test for presence of the > feature being tested for. > > Signed-off-by: Reinette Chatre > Signed-off-by: Sai Praneeth Prakhya > --- > tools/testing/selftests/resctrl/resctrlfs.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c > index 19c0ec4045a4..226dd7fdcfb1 100644 > --- a/tools/testing/selftests/resctrl/resctrlfs.c > +++ b/tools/testing/selftests/resctrl/resctrlfs.c > @@ -596,11 +596,11 @@ bool check_resctrlfs_support(void) > > char *fgrep(FILE *inf, const char *str) > { > - char line[256]; > int slen = strlen(str); > + char line[2048]; > > while (!feof(inf)) { > - if (!fgets(line, 256, inf)) > + if (!fgets(line, 2048, inf)) > break; > if (strncmp(line, str, slen)) > continue; > @@ -631,7 +631,7 @@ bool validate_resctrl_feature_request(char *resctrl_val) > if (res) { > char *s = strchr(res, ':'); > > - found = s && !strstr(s, resctrl_val); > + found = s && strstr(s, resctrl_val); > free(res); > } > fclose(inf); > Please note that this is only a partial fix. The current feature detection relies on the feature flags found in /proc/cpuinfo. Quirks and kernel boot parameters are not taken into account. This fix only addresses the parsing of feature flags. If a feature has been disabled via kernel boot parameter or quirk then the resctrl tests would still attempt to run the test for it. Reinette