Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1687916rdb; Thu, 25 Jan 2024 03:17:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEc/bEA/h6Yrn93JU/pabwVAuuooCCpSAtZJA1efjKydpcQTT+F2q5nsm022wTdW7t94yul X-Received: by 2002:a2e:7805:0:b0:2cf:1759:b643 with SMTP id t5-20020a2e7805000000b002cf1759b643mr419081ljc.26.1706181432045; Thu, 25 Jan 2024 03:17:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706181432; cv=pass; d=google.com; s=arc-20160816; b=crzNfa5EjtBb2iJoHPNxB5arVcl8lxIT5G/k14hQKx1Yx0M0HRvz4e6/ENt5t9XWbc aaoa4o1H25JwLrxtB+FsTgGRcrylX0ZfyeppAVZTGGk8yOo+T/R5GkhxMynTt2ptxwab EBPk21qQ+5k47RyJwwkL7DTSoysKJa2vGXqWQaldylTPfiMM/17H3VmYVEP9HEWjHqQ6 OVJ1JJetVWhN39VWB+Wp/QiZRVN/tfaj3gKaCAJ8ySMDl4dX+1tKN6h26C+q4aTqAJ83 S2rttB1bjmZ+lRGJ2/DfK9TTVZDX2vNOfJHl6ZmFpwdMs1aX+r9grCrHJrOgYpq0SV6L Rk2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kR3kO8rJeyaYG7Bvs9hNyBFZpFeLxQ/gPa47a4FsZYk=; fh=eNkS6XcMxBX7jqqaCWKBjHPfznBhZVo4Re/mvAqqtp8=; b=hXkCuIS24QwZ4gDIN/Ma4laDTyNtw/xKaxmww6x4Ur68SMxFZUclI5NF/1gFuuz78d vkjr/fLwxx+tP3LQ9Usu2GCAGCzMD50ngDiZYTzMru5zVJi8rnzeA6Wy5EWqQ7vFK4SX dKIAKB49t8bSbVFlqpwXFNhEEcTID7t7r5eW9XTnyWH224RDjhrd8AwUoeuVPGAK4Npc 3TALLw6VFlkRc1Kepzio0Ezb7gcDRgKPMjMU9Th/89T1DZeOCQcEk/6Qe7Zbl/Y6kPUj vnCHZvkYybERSih4TSZkXo8d5ePoaG6B2Rr7RlVlDPC8dO1qGTKf3AVh26VaOAwcNvqr Uh0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vn3NfZf4; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-38491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r10-20020a056402234a00b0055c05b981d7si5438033eda.207.2024.01.25.03.17.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:17:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vn3NfZf4; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-38491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 737E21F21EAD for ; Thu, 25 Jan 2024 11:17:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C84DF54BE6; Thu, 25 Jan 2024 11:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Vn3NfZf4" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8594A54BC0; Thu, 25 Jan 2024 11:13:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.120 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181182; cv=none; b=f5crJA5wJ+oiw+v6c5SImW3VCI0WpjswrEKT6j5BR5GFi89NAhHN/cdcgiNvxk2ZPbHknJYzKna1DcH0YFgjkDFlF4oc09GLawMhLWaeXasUveoB4OiYUuI/OuaxqTN0ioNv7WP9vayTC9O+dAnEnd9thm9MmOXVi26hlWzLp8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181182; c=relaxed/simple; bh=SxRU7/I2LYttjmLWpA1g2TAp7MIA5p+HKBajTxhEzJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lGBifd8nUus7qBZDhAxIQAPd5cxSG8HQreIQtbZtEnwt9ad7zY9IfUyXcJ0WIi4ninAcxzqjN21sGBusbnp4jpElowbWwmE9JOa/5wxrBFaLJpm0ovC2B+KosgMohuZAi84MQJF+Wl8LqaFmerIrSYXXAMAYjP+nZAlQoQUKP10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Vn3NfZf4; arc=none smtp.client-ip=192.55.52.120 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706181180; x=1737717180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SxRU7/I2LYttjmLWpA1g2TAp7MIA5p+HKBajTxhEzJs=; b=Vn3NfZf4itAM/jGnV5273rCZEb6G7jXlC2qR69Zwp8dd8LChKxkgVvom fIhwPdquFkGsTE0PFmFhe0U1LqNi2kfwU35kiQwymmWmROrnEJ8Oiw4ZA fLMzVflcPYFCwSy9bSM8T96wWbAxOCm4+4v1tc/apYmLZAj213X6WncrH dszCTcMD2gAfH/NMKC5P3JU7fgCdTNQ9m5kiSUBAiVoexXX8oWJlrjsIk JZY/wlTjAmZAnsj4EwICtkgw5Nogu/6KgUyTnGm+Ygf4+ggM6KkQkFxhM mXhjYGUykNnYBZzc9P8nlA5t/KAFc9kDzIFmfefn+rEWXlrSpPhpml3aZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="400987627" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="400987627" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:12:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="909968606" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="909968606" Received: from apejovix-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.0.239]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:12:57 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, shuah@kernel.org, fenghua.yu@intel.com Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v3 4/5] selftests/resctrl: Add resource_info_file_exists() Date: Thu, 25 Jan 2024 12:12:44 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Feature checking done by resctrl_mon_feature_exists() covers features represented by the feature name presence inside the 'mon_features' file in /sys/fs/resctrl/info/L3_MON directory. There exists a different way to represent feature support and that is by the presence of 0 or 1 in a single file in the info/resource directory. In this case the filename represents what feature support is being indicated. Add a generic function to check file presence in the /sys/fs/resctrl/info/ directory. Signed-off-by: Maciej Wieczor-Retman --- Changelog v3: - Split off the new function into this patch. (Reinette) Changelog v2: - Add this patch. tools/testing/selftests/resctrl/resctrl.h | 2 ++ tools/testing/selftests/resctrl/resctrlfs.c | 26 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 4603b215b97e..c39105f46da9 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -138,6 +138,8 @@ int umount_resctrlfs(void); int validate_bw_report_request(char *bw_report); bool resctrl_resource_exists(const char *resource); bool resctrl_mon_feature_exists(const char *feature); +bool resource_info_file_exists(const char *resource, + const char *feature); bool test_resource_feature_check(const struct resctrl_test *test); char *fgrep(FILE *inf, const char *str); int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index e4ba8614fb7b..a6427732e0ad 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -763,6 +763,32 @@ bool resctrl_mon_feature_exists(const char *feature) return !!res; } +/* + * resource_info_file_exists - Check if a file is present inside + * /sys/fs/resctrl/info/RESOURCE. + * @resource: Required resource (Eg: MB, L3, L2, etc.) + * @feature: Required feature. + * + * Return: True if the file exists, else false. + */ +bool resource_info_file_exists(const char *resource, + const char *feature) +{ + char res_path[PATH_MAX]; + struct stat statbuf; + + if (!feature || !resource) + return false; + + snprintf(res_path, sizeof(res_path), "%s/%s/%s", INFO_PATH, resource, + feature); + + if (stat(res_path, &statbuf)) + return false; + + return true; +} + bool test_resource_feature_check(const struct resctrl_test *test) { return resctrl_resource_exists(test->resource); -- 2.43.0