Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3395798rdb; Wed, 13 Sep 2023 10:39:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP9GydVhSU1L2sQeAYubLfO+lPUVHLPRoAxfEzpdA+ekxjKmpYiDJHINZTHPql9mVWnC/1 X-Received: by 2002:a17:902:e88f:b0:1c3:8dbe:aecb with SMTP id w15-20020a170902e88f00b001c38dbeaecbmr3622230plg.2.1694626787534; Wed, 13 Sep 2023 10:39:47 -0700 (PDT) Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x15-20020a170902a38f00b001bc434b9d95si7339966pla.156.2023.09.13.10.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 10:39:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i9rz2OHK; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5937C813EAAF; Tue, 12 Sep 2023 15:10:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237701AbjILWKC (ORCPT + 99 others); Tue, 12 Sep 2023 18:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237776AbjILWJ6 (ORCPT ); Tue, 12 Sep 2023 18:09:58 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C91911728; Tue, 12 Sep 2023 15:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694556592; x=1726092592; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=5NgFuBi0grMJByv+WMk3aDhPrPW3qn0LknZEcOD8NGQ=; b=i9rz2OHKDcvuZaJnbhXr/rmJ0QaAAfxWjSkr1fuXnnbZX5VvI9BL2phK hTqGHHE1ESMCeTnMjyIwWQFBb4wbiG265M0sXrF8eltalh5kiKE0/mNXl CUza7sufwqDWzHKi4lIh4aBEgNVgvE6a/Yz6DucdflyHyw2HADdMoH8Pf 8KPRLOsh0X9qgbofKnWybvIdaZNxZ1WvPwKPWeYWvGafhnmgALgt2xHbo P3a9I7p9RQ+ekhrPF3+4u4STDw2pSVRYUGIRtP1jLHgi4V/kZ2nXznt6H dVn7c5zSszKh8wmuOlavGKqmqngp0PAhB1YPiVToAdkMsBAfdzd8E+TuG Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="368771173" X-IronPort-AV: E=Sophos;i="6.02,141,1688454000"; d="scan'208";a="368771173" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 15:09:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="773206653" X-IronPort-AV: E=Sophos;i="6.02,141,1688454000"; d="scan'208";a="773206653" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga008.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 12 Sep 2023 15:09:39 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 12 Sep 2023 15:09:39 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 12 Sep 2023 15:09:38 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Tue, 12 Sep 2023 15:09:38 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.103) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Tue, 12 Sep 2023 15:09:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CbOlIZBONt5XjA4jdhJcd1xusTaJ/suF6tSD4juM5H2Gb/5Opq21DvOB4kinR+AOT6bfLcUANGMtjj3bpQgDRnvLXWOb+Arnf0btcMN01P3hghmXSzYlp47DMKeAZMaZwd8Jvn9YOEA6FLZAFwqpJtuiPzMPW/lOjPDm1v8X/qOdQtL3KlEoUsOkReQtwJ8wL9u4OUswGdtn5O0bBTnaOgB8CdiRjKzN6lNV1/MXDx++g0Vwb13oJXXl1xk2YmXmZPlzvdJ89IWZSxTxpSaq/x3SR2UZO4QU2VHQOFvYxzBUH2+BYSRU5NVfUtSrSIVp4Y5fYzdu4xlV+WO7v7Gq7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RLySuDW8gDPugdKIUKxa+7O3sTq/hQry6MtBAWD4UXQ=; b=gw+qgmDpjsrj5BNPFD40Yu3hoX5uX46piBWSwtBeNTOpR0ljehvBCi0VoevVp69/z6VXrJ98BcpbMDtzWnDaRPUCJEHSFlaeEBDU6MrRTcqknRvjQiWk3VUdy4WZtnpyP8YlJKitjwx+Nxo3/yHPM7AZE+BrowdU5gW+EEzvSfU03JYtOHEPFQk/iVbLMgheWz8c3VjnKQSUfmwsZ7AdXk0sZECJbPNJYBw49RGRBDjhkpc625KpiZ7cDw6Ay66oAIDVOsqHz6NIrNi0lG2BA4CiKJO2/n6X4IudsFPHoKDZxgc6GTxbgo5pt1COgaNzi7E1QVzaHQ0fnUhdCqNlhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10) by PH7PR11MB6029.namprd11.prod.outlook.com (2603:10b6:510:1d0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Tue, 12 Sep 2023 22:09:36 +0000 Received: from SJ2PR11MB7573.namprd11.prod.outlook.com ([fe80::afd6:ce92:6244:7203]) by SJ2PR11MB7573.namprd11.prod.outlook.com ([fe80::afd6:ce92:6244:7203%5]) with mapi id 15.20.6768.029; Tue, 12 Sep 2023 22:09:36 +0000 Message-ID: Date: Tue, 12 Sep 2023 15:09:33 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.15.0 Subject: Re: [PATCH 3/5] selftests/resctrl: Refactor feature check to use resource and feature name Content-Language: en-US To: =?UTF-8?Q?Ilpo_J=c3=a4rvinen?= , Shuah Khan , Shuah Khan , , =?UTF-8?Q?Maciej_Wiecz=c3=b3r-Retman?= CC: , Shaopeng Tan , References: <20230911111930.16088-1-ilpo.jarvinen@linux.intel.com> <20230911111930.16088-4-ilpo.jarvinen@linux.intel.com> From: Reinette Chatre In-Reply-To: <20230911111930.16088-4-ilpo.jarvinen@linux.intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MW4PR04CA0126.namprd04.prod.outlook.com (2603:10b6:303:84::11) To SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR11MB7573:EE_|PH7PR11MB6029:EE_ X-MS-Office365-Filtering-Correlation-Id: 5191a4b1-f8ed-44f9-a154-08dbb3dcf398 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ye5drV+fRy2taeYMN8lDqUYmak5zd5UQcEhPdygzIlejMVTxbhtpGDZNqsy+1tj/4lrOpavYl01RjpXMzXbuKXsLlp4YoBjA81W8OXDqooqTuRwSJ7APzCFEpoAKwt7V8vx6rbOJ2SOcgKsU8sbr/2oCjU8WGtGPHPpq9Wr20vdCFc/NgWjbOud7sJ4leKNAyeYDs0vM4ka3POcCAqjdqTIVrf69jgeSZtiiqXb1xvW1ooUkenylZp3h5QSPWhJpNdiL+M3gNRiAa+i7gt2vNo/6HKM/3x0vvGTD3i7RVzQqcCr4YLd2t/9SroFO9lV4ix993yTZfViLmv82lpVUzmZf18GaKxJDyYCh+EuSf7L6lQ3CFdRK+E2xEebfkMvHGqYQ8Hl5ARAFE/KHiIUoGPo21yrRtnpXshIexUa6ZK60TOy0YeiGWIoMURc+oblbcKQfH/HlnysY/2e2q5SV6QEFQ4A93rs48iz/DSccNjbLMnOAlnpHwXBEu/1z41H42HUc5+UT6/LgFXNGJ+S8y3sWqfv5IfaYjJpyquF70BM+9j7IGtnw0vOyAxzqRTyAZe/iwfiulRrf0qAV2FAtEWZT4ueXkSlMo0c6qP0hcVWrDXLbrJ8hRA1UhZSmVohpnq2/d0BrwIdQQoSZaP+T3A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR11MB7573.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(346002)(366004)(396003)(451199024)(1800799009)(186009)(4326008)(2616005)(8936002)(8676002)(478600001)(6506007)(66946007)(316002)(53546011)(6636002)(6486002)(41300700001)(6512007)(110136005)(26005)(5660300002)(44832011)(6666004)(66476007)(31686004)(66556008)(66574015)(2906002)(83380400001)(86362001)(36756003)(82960400001)(38100700002)(31696002)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ekFocE8wZ1VUQktNdlBYUlJ5b0ZEVzVCbVVHOVdUSmhxQW9DSk1Cc3JmLysw?= =?utf-8?B?Y1B6RWJFVFdSdXFacExqTHBwc1VSMUI4VHcrdjhyU1pGWE1LSWM3OXhqcWJl?= =?utf-8?B?VFh6cDNWL0hNc2xmRThleVhKWTNHNUNieExxejhPeGxiTzRsd2tVWUlkejR1?= =?utf-8?B?U2k5K0lOWmVmdDR5Y2ttM29hZkVhbWF1RENFQ2UzeWtKdXJGSmRoQ0hSZnIx?= =?utf-8?B?WHlhQmtnVzJFK29NcXFzU0R6TG5jaHVJTXpKbFBIVTM4ZFV3ZThQZGQ3bXRO?= =?utf-8?B?MG8yRVFETmVSZHNGa2lDdUdGTnhpRzlWQzV1blRaTGhHMCtkdWcrSWlBQ3Fz?= =?utf-8?B?ZVdWR2NabEtmcTcwbFBYZzRldC9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-8?B?aUE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5191a4b1-f8ed-44f9-a154-08dbb3dcf398 X-MS-Exchange-CrossTenant-AuthSource: SJ2PR11MB7573.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2023 22:09:36.5651 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 09/GD/hxGsSb01frnz45XSByuIUrc94k3EBBMlNceIhNXow9VYzZGDfNkRwpx2rYGDqSmIc5ZTv1Ag6b7KF+S8qmhhJ2TT/++8eK8IsiFpc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6029 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 15:10:09 -0700 (PDT) Hi Ilpo, On 9/11/2023 4:19 AM, Ilpo Järvinen wrote: > Feature check in validate_resctrl_feature_request() takes in the test > name string and maps that to what to check per test. > > Pass resource and feature names to validate_resctrl_feature_request() > directly rather than deriving them from the test name inside the > function which makes the feature check easier to extend for new test > cases. > > Signed-off-by: Ilpo Järvinen > Cc: This does not seem to be stable material. > --- > tools/testing/selftests/resctrl/resctrl.h | 6 +- > .../testing/selftests/resctrl/resctrl_tests.c | 10 +-- > tools/testing/selftests/resctrl/resctrlfs.c | 69 ++++++++----------- > 3 files changed, 34 insertions(+), 51 deletions(-) > > diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h > index dd07463cdf48..89ced4152933 100644 > --- a/tools/testing/selftests/resctrl/resctrl.h > +++ b/tools/testing/selftests/resctrl/resctrl.h > @@ -28,10 +28,6 @@ > #define RESCTRL_PATH "/sys/fs/resctrl" > #define PHYS_ID_PATH "/sys/devices/system/cpu/cpu" > #define INFO_PATH "/sys/fs/resctrl/info" > -#define L3_PATH "/sys/fs/resctrl/info/L3" > -#define MB_PATH "/sys/fs/resctrl/info/MB" > -#define L3_MON_PATH "/sys/fs/resctrl/info/L3_MON" > -#define L3_MON_FEATURES_PATH "/sys/fs/resctrl/info/L3_MON/mon_features" > > #define ARCH_INTEL 1 > #define ARCH_AMD 2 > @@ -88,7 +84,7 @@ int get_resource_id(int cpu_no, int *resource_id); > int mount_resctrlfs(void); > int umount_resctrlfs(void); > int validate_bw_report_request(char *bw_report); > -bool validate_resctrl_feature_request(const char *resctrl_val); > +bool validate_resctrl_feature_request(const char *resource, const char *feature); > char *fgrep(FILE *inf, const char *str); > int taskset_benchmark(pid_t bm_pid, int cpu_no); > void run_benchmark(int signum, siginfo_t *info, void *ucontext); > diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c > index 3d66fbdc2df3..3052394ca884 100644 > --- a/tools/testing/selftests/resctrl/resctrl_tests.c > +++ b/tools/testing/selftests/resctrl/resctrl_tests.c > @@ -84,7 +84,9 @@ static void run_mbm_test(const char * const *benchmark_cmd, int cpu_no) > return; > } > > - if (!validate_resctrl_feature_request(MBM_STR) || (get_vendor() != ARCH_INTEL)) { > + if (!validate_resctrl_feature_request("L3_MON", "mbm_total_bytes") || > + !validate_resctrl_feature_request("L3_MON", "mbm_local_bytes") || > + (get_vendor() != ARCH_INTEL)) { > ksft_test_result_skip("Hardware does not support MBM or MBM is disabled\n"); > goto umount; > } > @@ -116,7 +118,7 @@ static void run_mba_test(const char * const *benchmark_cmd, int cpu_no) > return; > } > > - if (!validate_resctrl_feature_request(MBA_STR) || (get_vendor() != ARCH_INTEL)) { > + if (!validate_resctrl_feature_request("MB", NULL) || (get_vendor() != ARCH_INTEL)) { > ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n"); > goto umount; > } > @@ -146,7 +148,7 @@ static void run_cmt_test(const char * const *benchmark_cmd, int cpu_no) > return; > } > > - if (!validate_resctrl_feature_request(CMT_STR)) { > + if (!validate_resctrl_feature_request("L3_MON", "llc_occupancy")) { > ksft_test_result_skip("Hardware does not support CMT or CMT is disabled\n"); > goto umount; > } > @@ -178,7 +180,7 @@ static void run_cat_test(int cpu_no, int no_of_bits) > return; > } > > - if (!validate_resctrl_feature_request(CAT_STR)) { > + if (!validate_resctrl_feature_request("L3", NULL)) { > ksft_test_result_skip("Hardware does not support CAT or CAT is disabled\n"); > goto umount; > } > diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c > index bd36ee206602..bd547a10791c 100644 > --- a/tools/testing/selftests/resctrl/resctrlfs.c > +++ b/tools/testing/selftests/resctrl/resctrlfs.c > @@ -10,6 +10,8 @@ > */ > #include "resctrl.h" > > +#include > + Could you please include before the local resctrl.h? > static int find_resctrl_mount(char *buffer) > { > FILE *mounts; > @@ -604,63 +606,46 @@ char *fgrep(FILE *inf, const char *str) > > /* > * validate_resctrl_feature_request - Check if requested feature is valid. > - * @resctrl_val: Requested feature > + * @resource: Required resource (e.g., MB, L3, L2, L3_MON, etc.) > + * @feature: Feature to be checked under resource (can be NULL). This path > + * is relative to the resource path. I do not think "this path" is accurate. @feature is not a path but an entry within the mon_features file. Also please note that mon_features only exists for L3_MON, none of the other listed resources have an associated mon_features file in resctrl. This function is created to be generic has specific requirements on what valid (never checked) parameters should be. This may be ok with the usage but it should not pretend to be generic. > * > - * Return: True if the feature is supported, else false. False is also > - * returned if resctrl FS is not mounted. > + * Return: True if the resource/feature is supported, else false. False is > + * also returned if resctrl FS is not mounted. > */ > -bool validate_resctrl_feature_request(const char *resctrl_val) > +bool validate_resctrl_feature_request(const char *resource, const char *feature) > { > struct stat statbuf; > - bool found = false; > + char res_path[PATH_MAX]; Please maintain reverse fir order. > char *res; > FILE *inf; > int ret; > > - if (!resctrl_val) > + if (!resource) > return false; > > ret = find_resctrl_mount(NULL); > if (ret) > return false; > > - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) { > - if (!stat(L3_PATH, &statbuf)) > - return true; > - } else if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { > - if (!stat(MB_PATH, &statbuf)) > - return true; > - } else if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || > - !strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { > - if (!stat(L3_MON_PATH, &statbuf)) { > - inf = fopen(L3_MON_FEATURES_PATH, "r"); > - if (!inf) > - return false; > - > - if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { > - res = fgrep(inf, "llc_occupancy"); > - if (res) { > - found = true; > - free(res); > - } > - } > - > - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { > - res = fgrep(inf, "mbm_total_bytes"); > - if (res) { > - free(res); > - res = fgrep(inf, "mbm_local_bytes"); > - if (res) { > - found = true; > - free(res); > - } > - } > - } > - fclose(inf); > - } > - } > + snprintf(res_path, sizeof(res_path), "%s/%s", INFO_PATH, resource); > + > + if (stat(res_path, &statbuf)) > + return false; > + > + if (!feature) > + return true; > + > + snprintf(res_path, sizeof(res_path), "%s/%s/mon_features", INFO_PATH, resource); > + inf = fopen(res_path, "r"); > + if (!inf) > + return false; > + > + res = fgrep(inf, feature); > + free(res); > + fclose(inf); > > - return found; > + return res; This is unexpected. Function should return bool but instead returns a char * that has been freed? > } > > int filter_dmesg(void) Reinette