Message ID | 9c38bb317d4246182f87e376926b61adbb7e20fd.1707130307.git.maciej.wieczor-retman@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-52571-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp831916dyb; Mon, 5 Feb 2024 04:15:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSak7TqhvNuCwseDmIODBSpcYnfqRihx73+jlk+pF+fOZy7nN/97PzKQCO60iGPazwEDkt X-Received: by 2002:a17:906:1d9:b0:a36:f993:a853 with SMTP id 25-20020a17090601d900b00a36f993a853mr6498235ejj.74.1707135318229; Mon, 05 Feb 2024 04:15:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707135318; cv=pass; d=google.com; s=arc-20160816; b=0UaGtYIVknLVM5MMbGOFHo07rYtSHTZW0rdSzviG8QPqtorTfNma3XdSoj6KPQ7sQD RbpdQEkNkRI8LjyPMBBcBd0SqABAnmwXrA0UEGozRKwWZF2QfRZrBFFYpcL/otPY0yXl cWa0wS15Lh7yLAzHoCXOYmLc6GaMDsW2XNKc3prASJPhOAyKijTQkOy5AxW+bRWFLv7A ESSaqwguyGO+tunOdi6bNKQoO4Wy3Uj6+CAu2BE3r6X83KmMtpSfx3rh36M7Vi5NRMZ7 IOKToEA4J8zPsnO8ihQBik/5UaVCpvxVaExzGwl6RKrw5nHZBYIZSDDt5pC9Y6yniaf/ XlGA== 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=BlLugm1x4zVrqFbloclAw0k8hN5MlkBDWD/fuPb4pXI=; fh=MwlbPOMC5Z/IzYhPoa5flof4XXcLtdq8ST7Kh5587/o=; b=YIn6l4sYWQZi71HydqNp5+WgtQVFalBmUVXl07VYQ4YcAi/qQJ1dcwPoanJDyGERjp uUA0doAGqPkep5EvEsWyb+ZzmaGViaRFfAJxmtFqYAyXlC0OL9gxgGhGpxk+8IKNan7+ hRQ2YT0f6/P4YtMosxzMJXSTNXNPzQljle9DsGmFo0KWZzMe5Nhy8witRBEELcwyMi11 w1cTDsS4E+Ds7jiZAlDpo3pUrbzFI+S+/Elsdd89zfAk0GVYKNlrIQN7DV4HEMzRCrgu pInVFO6vPD0ReZuhq2MPNQ2hXDkKXV0KfXCd4JTo4pWzOATuhYGuy4OgLNUllqna9Exs 6vFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P7mTtuZC; 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-52571-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52571-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCVqD37eVKhc8VrG7W/UqWumFeO26RnGiGCTV8ZQmJPfupsG04KSiQtlP1HV7lbwusabvFj/RxQRnxUaEQNecrlbL50H1Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g18-20020a170906349200b00a3787de465fsi1729934ejb.231.2024.02.05.04.15.18 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 04:15:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52571-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=P7mTtuZC; 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-52571-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52571-ouuuleilei=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 A62FA1F27ACB for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 12:15:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A342A1CF87; Mon, 5 Feb 2024 12:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="P7mTtuZC" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 6A1361CD2E; Mon, 5 Feb 2024 12:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707134927; cv=none; b=ZbdyP7Tl5vhfLBl5ff1yOTZsdDdTkb7W2bvclGSuP2dtSr18pUOfBWTdJ8Ey3ai9HIOZGDI7H7YO1NJRAnw5AQ+CpXDtMHIPs5dizNkAcU4btNkv2qYdXrN9wUoOJwFJ7evGzwWCNo6LFegT8zfbgZf9iHFuUylX6eROll1FAaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707134927; c=relaxed/simple; bh=cQXt66XNAxdPbuQ3HHleM5aXlSZ96lSuJgWfQYcNYtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Bc//MgJ3WrdaclgsCkpczJf0CXSA7lhTimHvAncX6bvBs5lRHgp1KtoqiCN9jw3cIaBZalPmQXlTa0ZBPXBeSPXuMHRT1vJFRglyvn/JQJu6GmXGangBaSgIwXZouYyvPcpxz9Fo8c9xs9/OeWJv5L0yMUa8XCeUN5dVdr0LcxU= 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=P7mTtuZC; arc=none smtp.client-ip=192.198.163.12 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=1707134926; x=1738670926; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cQXt66XNAxdPbuQ3HHleM5aXlSZ96lSuJgWfQYcNYtk=; b=P7mTtuZCC5CkGcsyw3boOXRKBhDh6Y/xpWe1s98j+ab87HXMRdDvVSJi eVpWJ81X8+O1n9xnko5yICOzAxl8+C9tv58146CpJOA4+5WrvLXJa1ALv S6S2xmgDPSDgEibjTiErTl5L8NkC1imJtBRad9OzIZw7nGoBJbEggizTO YdY/RJxM8POWKNdrlFkgHRkZdWLkLE4L2bnYQ1o4OewGNDwgm4lgyzJIK e9CTvLE7oHJfu4NsvHikB2bKqtk+Kj11VMS0mEwise8cOzrD53QjYmzh9 oclICfrIMq2nzJNozvgzq2IRz1dykT5c+xJfXTArEaG0grC0jcQJPf3xn A==; X-IronPort-AV: E=McAfee;i="6600,9927,10974"; a="4303552" X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="4303552" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 04:08:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="5445990" Received: from snestero-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.21.196]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 04:08:41 -0800 From: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> To: fenghua.yu@intel.com, reinette.chatre@intel.com, shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v4 4/5] selftests/resctrl: Add resource_info_file_exists() Date: Mon, 5 Feb 2024 13:08:31 +0100 Message-ID: <9c38bb317d4246182f87e376926b61adbb7e20fd.1707130307.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <cover.1707130307.git.maciej.wieczor-retman@intel.com> References: <cover.1707130307.git.maciej.wieczor-retman@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790061123263411159 X-GMAIL-MSGID: 1790061123263411159 |
Series |
selftests/resctrl: Add non-contiguous CBMs in Intel CAT selftest
|
|
Commit Message
Maciej Wieczor-Retman
Feb. 5, 2024, 12:08 p.m. UTC
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/<RESOURCE> directory. Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> --- Changelog v4: - Remove unnecessary new lines. - Change 'feature' -> 'file' to keep things generic. (Reinette) - Add Ilpo's reviewed-by tag. Changelog v3: - Split off the new function into this patch. (Reinette) Changelog v2: - Add this patch. tools/testing/selftests/resctrl/resctrl.h | 1 + tools/testing/selftests/resctrl/resctrlfs.c | 25 +++++++++++++++++++++ 2 files changed, 26 insertions(+)
Comments
Hi Maciej, On 2/5/2024 4:08 AM, Maciej Wieczor-Retman wrote: > 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/<RESOURCE> directory. > > Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > --- > Changelog v4: > - Remove unnecessary new lines. > - Change 'feature' -> 'file' to keep things generic. (Reinette) > - Add Ilpo's reviewed-by tag. > > Changelog v3: > - Split off the new function into this patch. (Reinette) > > Changelog v2: > - Add this patch. > > tools/testing/selftests/resctrl/resctrl.h | 1 + > tools/testing/selftests/resctrl/resctrlfs.c | 25 +++++++++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h > index 4603b215b97e..2b9a3d0570c7 100644 > --- a/tools/testing/selftests/resctrl/resctrl.h > +++ b/tools/testing/selftests/resctrl/resctrl.h > @@ -138,6 +138,7 @@ 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); One stray "feature" usage. > 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 0cfec8bb23fd..6a3082ca58b5 100644 > --- a/tools/testing/selftests/resctrl/resctrlfs.c > +++ b/tools/testing/selftests/resctrl/resctrlfs.c > @@ -760,6 +760,31 @@ 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.) > + * @file: Required file. > + * > + * Return: True if the file exists, else false. How about "True if /sys/fs/resctrl/info/@resource/@file exists, else false"? Reinette
Hi Reinette! On 2024-02-05 at 20:17:48 -0800, Reinette Chatre wrote: >Hi Maciej, > >On 2/5/2024 4:08 AM, Maciej Wieczor-Retman wrote: >> 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/<RESOURCE> directory. >> >> Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> >> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> >> --- >> Changelog v4: >> - Remove unnecessary new lines. >> - Change 'feature' -> 'file' to keep things generic. (Reinette) >> - Add Ilpo's reviewed-by tag. >> >> Changelog v3: >> - Split off the new function into this patch. (Reinette) >> >> Changelog v2: >> - Add this patch. >> >> tools/testing/selftests/resctrl/resctrl.h | 1 + >> tools/testing/selftests/resctrl/resctrlfs.c | 25 +++++++++++++++++++++ >> 2 files changed, 26 insertions(+) >> >> diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h >> index 4603b215b97e..2b9a3d0570c7 100644 >> --- a/tools/testing/selftests/resctrl/resctrl.h >> +++ b/tools/testing/selftests/resctrl/resctrl.h >> @@ -138,6 +138,7 @@ 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); > >One stray "feature" usage. Thank you for catching that! > >> 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 0cfec8bb23fd..6a3082ca58b5 100644 >> --- a/tools/testing/selftests/resctrl/resctrlfs.c >> +++ b/tools/testing/selftests/resctrl/resctrlfs.c >> @@ -760,6 +760,31 @@ 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.) >> + * @file: Required file. >> + * >> + * Return: True if the file exists, else false. > >How about "True if /sys/fs/resctrl/info/@resource/@file exists, else false"? Sure. I was wondering what the best format of paths in the function comments could be and that does look very sensible. I'll redo the other paths in the comments of this series for consistency. > >Reinette
diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 4603b215b97e..2b9a3d0570c7 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -138,6 +138,7 @@ 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 0cfec8bb23fd..6a3082ca58b5 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -760,6 +760,31 @@ 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.) + * @file: Required file. + * + * Return: True if the file exists, else false. + */ +bool resource_info_file_exists(const char *resource, const char *file) +{ + char res_path[PATH_MAX]; + struct stat statbuf; + + if (!file || !resource) + return false; + + snprintf(res_path, sizeof(res_path), "%s/%s/%s", INFO_PATH, resource, + file); + + 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);