From patchwork Fri Feb 9 14:01:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 198881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp869570dyd; Fri, 9 Feb 2024 06:02:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1uLpvM7mn0F46kQTJW/y/rmhhyHcVZfvwdCOz6J3gnVk0+HXQ7ElpOKCoNQbx6nSzneaO X-Received: by 2002:aa7:c2cf:0:b0:560:cae:53f7 with SMTP id m15-20020aa7c2cf000000b005600cae53f7mr1411435edp.35.1707487327372; Fri, 09 Feb 2024 06:02:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707487327; cv=pass; d=google.com; s=arc-20160816; b=uKItvgsp/joXH56hyTaD0VUYKZ7OhH9iQMofeH/Z5zXvGy8wp2SZ+mj2Mi2IPrGc/e fbebCks+vLX3uCHlH75SJTQEkgag0dbESUNdiY8NVKu/Y5zQ37k4ooxITlQl3SY2AL/E 4Ar4+zXhXmIoe+Po/ij216yg2dyoKp7/YI0GibuNCZbQFeMA5L1Oq8LMgV7oqzBm0VKK N38MQ3DOfqCb3Hl2nSFEyXPLGa22gYwNdHZNW01ULI5M6QjfjkSYUYZ5wsk4bDhyY+O/ 3ZFxS+RJzCgN+nJy89B3Auve50O4eVg8SE/ImfrRQd2plgvJA3vdNb82G+/o4QRF1cNT ql8Q== 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=wOzp1pFgIcYTiPHAiv5f7UuLJOigPd8KBSsP0sYwjQ8=; fh=EJ+kburi34rdOxNe+xBYkcGxNwFy4vEgVK/1njUhf4k=; b=ttqVMi+m7n8x1OqQuCgdRIBeWzcuSowK+yh/8cZVm5zuxOoidZvjf8BInGV5m+xOFi tZnpxfqSx8yjKTQcM3/4Gzwt/NxPs2UBYvcCPPjsvBBruAZ86vYWgtilQ2nWOIZxUh6f +V6Sfoj7we3ncqPk4NjJb76u3NTVODZunToy7C1wyBEJzTsqT0G9NJGfmuS1QsEXo9ex RZt1OnovOZrzTQsauhaEH9TJLYULIgdRYx0FM+lBtoi9qknQoFCTczV2YsnMJZM4D+mr tNpb1F+Cta/DkdIUzc6YP0TrXCXWOFUChFuV5M+j+3cOAqELFynPOuxCFi7thNxG0ueH uH0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hW100hmi; 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-59402-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59402-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCVRX64KGnlEyd9HjsG/9Wob3yy9YuwIALGC3G4aWL+9wLNiqgdvObgGMWMzYKiQbhm+XXbnFI70eoK26u5lGGSziNPcwA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m20-20020aa7c494000000b00561160219dasi932243edq.134.2024.02.09.06.02.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:02:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59402-ouuuleilei=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=hW100hmi; 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-59402-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59402-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 306501F28701 for ; Fri, 9 Feb 2024 14:01:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 759D765BBC; Fri, 9 Feb 2024 14:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hW100hmi" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 F0E744F896; Fri, 9 Feb 2024 14:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487288; cv=none; b=Y5HY7fwpgbU0ILY43yV92VyvJrtoIZlwXsFgozFtzC/TbxfdgC3gazqwn5H70ShIQxL0KT67WAY+ChserE43Q7eUC1ynB4qyw67R6MQ766uNw7UP0z3AWQOxx03zCgA7zL6xkZ7wD0paJhwhLjIrQ3ip3dBJ0CtAVu4q0rbRgtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487288; c=relaxed/simple; bh=ITmCMI4xWgouC17/92dBGHeJbGzaQW2iSuy8CYT4Aao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rn2jTaqDe8HkShRwWONyU6lPVH2VH3Xh+n7TTEIO8CIvNcHeqWEREGsYe1B1Ys4BQySWxVSxHkrBlxWRomQ3esI/BrgQsdBYU/LH5VRRUCgLtkSoQmGCfh4T4pH5OEaOZpl/QPk84nBZLpa9h1Ps30IHGAcXrwC2k1DSMuiguq0= 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=hW100hmi; arc=none smtp.client-ip=192.198.163.10 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=1707487287; x=1739023287; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ITmCMI4xWgouC17/92dBGHeJbGzaQW2iSuy8CYT4Aao=; b=hW100hmibI0vASIr2Dih7NzUYWftVkGZwaNh0a/ilrreQ2NAxYPNxAKg PfLKpPKlLht3PCubq4ZB5nlvilvdT0GrSZ9PC5SvkuPFvuoOP7CP4NWzO ITh4BfnOpKpBu58iELnGQKMzDy4pzt3/kbcE1wHT6GNgMxhLZgOq5YQ+H ZQpwi5pXlEPAYsCcA1SdWMYhZJ0pvlyACbzx9P2AEAnKrNA8vJNsES/Ha 6VPUdfZfPZIrqD1PWkmuiDqkh03vi4F9ZEtbfqYEsnN7gwaEdsXRj3BlH J9wCcQ3DurmmNxrBD/2d4JTlHU5Sk4KQWykgc4sNX8ku5sCaDSsbY3SO4 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="12801813" X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="12801813" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:01:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="2284399" Received: from ldziemin-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.2.218]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:01:23 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, shuah@kernel.org, fenghua.yu@intel.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v5 1/5] selftests/resctrl: Add test groups and name L3 CAT test L3_CAT Date: Fri, 9 Feb 2024 15:01:10 +0100 Message-ID: <62192ad50be67f750b78a0e28a62b7704fbc63f5.1707487039.git.maciej.wieczor-retman@intel.com> 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790430231929182228 X-GMAIL-MSGID: 1790430231929182228 From: Ilpo Järvinen To select test to run -t parameter can be used. However, -t cat currently maps to L3 CAT test which will be confusing after more CAT related tests will be added. Allow selecting tests as groups and call L3 CAT test "L3_CAT", "CAT" group will enable all CAT related tests. Signed-off-by: Ilpo Järvinen Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Reinette Chatre --- Changelog v5: - Add Reinette's reviewed-by tag. Changelog v3: - Expand group description in struct comment (Reinette). Changelog v2: - Move this patch from Ilpo's series here (Ilpo). tools/testing/selftests/resctrl/cat_test.c | 3 ++- tools/testing/selftests/resctrl/resctrl.h | 3 +++ tools/testing/selftests/resctrl/resctrl_tests.c | 16 +++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 24af8310288a..39fc9303b8e8 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -295,7 +295,8 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param } struct resctrl_test l3_cat_test = { - .name = "CAT", + .name = "L3_CAT", + .group = "CAT", .resource = "L3", .feature_check = test_resource_feature_check, .run_test = cat_run_test, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index c52eaf46f24d..a1462029998e 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -65,6 +65,8 @@ struct user_params { /* * resctrl_test: resctrl test definition * @name: Test name + * @group: Test group - a common name for tests that share some characteristic + * (e.g., L3 CAT test belongs to the CAT group). Can be NULL * @resource: Resource to test (e.g., MB, L3, L2, etc.) * @vendor_specific: Bitmask for vendor-specific tests (can be 0 for universal tests) * @disabled: Test is disabled @@ -73,6 +75,7 @@ struct user_params { */ struct resctrl_test { const char *name; + const char *group; const char *resource; unsigned int vendor_specific; bool disabled; diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 75fc49ba3efb..3044179ee6e9 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -65,11 +65,15 @@ static void cmd_help(void) printf("usage: resctrl_tests [-h] [-t test list] [-n no_of_bits] [-b benchmark_cmd [option]...]\n"); printf("\t-b benchmark_cmd [option]...: run specified benchmark for MBM, MBA and CMT\n"); printf("\t default benchmark is builtin fill_buf\n"); - printf("\t-t test list: run tests specified in the test list, "); + printf("\t-t test list: run tests/groups specified by the list, "); printf("e.g. -t mbm,mba,cmt,cat\n"); - printf("\t\tSupported tests:\n"); - for (i = 0; i < ARRAY_SIZE(resctrl_tests); i++) - printf("\t\t\t%s\n", resctrl_tests[i]->name); + printf("\t\tSupported tests (group):\n"); + for (i = 0; i < ARRAY_SIZE(resctrl_tests); i++) { + if (resctrl_tests[i]->group) + printf("\t\t\t%s (%s)\n", resctrl_tests[i]->name, resctrl_tests[i]->group); + else + printf("\t\t\t%s\n", resctrl_tests[i]->name); + } printf("\t-n no_of_bits: run cache tests using specified no of bits in cache bit mask\n"); printf("\t-p cpu_no: specify CPU number to run the test. 1 is default\n"); printf("\t-h: help\n"); @@ -199,7 +203,9 @@ int main(int argc, char **argv) bool found = false; for (i = 0; i < ARRAY_SIZE(resctrl_tests); i++) { - if (!strcasecmp(token, resctrl_tests[i]->name)) { + if (!strcasecmp(token, resctrl_tests[i]->name) || + (resctrl_tests[i]->group && + !strcasecmp(token, resctrl_tests[i]->group))) { if (resctrl_tests[i]->disabled) tests++; resctrl_tests[i]->disabled = false; From patchwork Fri Feb 9 14:01:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 198882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp869686dyd; Fri, 9 Feb 2024 06:02:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWjazj08Y639HQOgz0eCtcUjtygjXqo/BXaei5oMtvK7K44qrdZKXC7imiAWa14vIZfHe/ X-Received: by 2002:a17:906:37d4:b0:a37:b8fb:50e0 with SMTP id o20-20020a17090637d400b00a37b8fb50e0mr1382640ejc.52.1707487335865; Fri, 09 Feb 2024 06:02:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707487335; cv=pass; d=google.com; s=arc-20160816; b=H8PFxJ9TQQ8O+4HLwid67nGXY5pVu2t7q8yo1utMT8yLM9mtq7iPAy2TqsMEpP+Doo fC4lejCigK6KgNoBNq8QBgIUHiTtOuD60NmZ41EoWKGuFgvgfL7fEHMiV+BERv52p3+z YKCd1KEI3ILMbj6aoGhw6og20BMxkyYG7g4iHjYKcN4n8chTI0s71Vu28l7PYTYeammd 7v4WtdaDCTRfzX2GJegfJlpK9ebxgCcGrdpNRVVZ4FHo6/bciPyuWcIFEuAoibPKWUAd YbD0+jeUSNY2u2IjS4E9/KfpVqVfZfe3W/r0OvPNIDwT+3xr9rSDGtBuGnwDq398IG54 I/HQ== 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=ZXjU9nzp0R7DXeCB6DHPqWTW/+NI9Z7Lj+WZGplIzHs=; fh=ih8rngRzdydAWj/mzbY/erVKaYvtKj6ywuRnWLA+1vU=; b=xqFARc5WCc7FoRNdNbDM5sQ7udKJoPaRaHocLclUisfyr70RO2plw3IMCtLNNtR21t bpeMvmnAPwz3ajLoDkWMO94wdIGBHemeuffp9fcplcndtjTo8kq/zde3i3MdUymG5XHK 3DX9AmkSsGWmDqXdMeFm5lqVe51vuTuecRykzGq/LO6sZzQGo8NnNIOaxrZMvq+UTynU 5pXg6KAW278TLnbEzAAvBGbBpp+d0rm5RtAiJXNxlUttmGbvk+INQ6paclSCcnbGJQg6 ZWNZfqx+vKCrU2hABeLwHv8Sj+XQkmFG7pvKEXn87oY5XNgEqijOlV6xOXxRXyRyGG9X hbew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="CcKI7y/r"; 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-59403-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59403-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCU5YstuWNzYFMpne3WglUh03JV4ujH6LbTdwdMI1hzPmME1maURC8++WwgSsdmkckoFY2coHGD6LPkdGlhHawpBstUwOw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dr4-20020a170907720400b00a387bc7aa3esi909459ejc.223.2024.02.09.06.02.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:02:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59403-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="CcKI7y/r"; 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-59403-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59403-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 B5FA91F235AA for ; Fri, 9 Feb 2024 14:01:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75DF1664A3; Fri, 9 Feb 2024 14:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CcKI7y/r" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 37D9E37147; Fri, 9 Feb 2024 14:01:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487304; cv=none; b=bqf+LbBxRcLVK4eRP638kNETL3d0ImPRKYNA/76Xc8Wo7NblKqRjqDjj5wH2F1ahoSBJzLdYvd4H7GLJpfxXYhhtSR4QajBeL/hDZXhAR0ATF1KAMNuX6WLxQMxZn5sihVfbTvRTcY2KQ/c5wejO9SDKJkRvfv91kPx1L/P1czA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487304; c=relaxed/simple; bh=x/Q+b8kyrZMmm2Xl3T6auY682+KEi1Ln5OJwND+72Ks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bWKpELbwoOLfHL/YSzpN81pi2YbpXVOHeLFZplz3gEvzgEleYUWWWnfYZgPBnHrskDq71y1bGOcPhA29hHoLQwPi+8naSQKzU63j0vs9AD8CQ24U9dQQlqZPVmbpwXkh0LVh2iVjVfeFq62lWYAUidpgFARmehxLOjWy+t/YZUM= 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=CcKI7y/r; arc=none smtp.client-ip=192.198.163.10 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=1707487303; x=1739023303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x/Q+b8kyrZMmm2Xl3T6auY682+KEi1Ln5OJwND+72Ks=; b=CcKI7y/rwqgyy0qvH2kRwv3QS30ArJyZtHFQgwneYgnt4qr/j0NSaa2S Ta+41YXdkPkwq3a89FNmutVSM8+zaGrOblTPLqrnQ143ofKn7ZM6lyH95 TH1GSMOA2dk0WUrXabQHKmbVfIt8KxtgqH4j8IchhDluDbW1fel6aAYw+ v90aB7IRpwO17X8r+FZ4cKUwmK+7tpprEV7YXH5xlPS1S1szoGXAibk4q ZLHnpkMN13MIcHHEsa5zSNT2O8DXJfuAE1wU95HVB0SsYOxpqIn+2dgU4 0GZZsS9b2uG2qnq2EQJQHr1Ksc/XivQntvTeu+0ZMHeEFeH8rKLdCn3I5 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="12801861" X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="12801861" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:01:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="2284446" Received: from ldziemin-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.2.218]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:01:39 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, shuah@kernel.org, fenghua.yu@intel.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v5 2/5] selftests/resctrl: Add a helper for the non-contiguous test Date: Fri, 9 Feb 2024 15:01:26 +0100 Message-ID: <42246fb33f396267431e8b5432554647179acc27.1707487039.git.maciej.wieczor-retman@intel.com> 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790430240555316588 X-GMAIL-MSGID: 1790430240555316588 The CAT non-contiguous selftests have to read the file responsible for reporting support of non-contiguous CBMs in kernel (resctrl). Then the test compares if that information matches what is reported by CPUID output. Add a generic helper function to read an unsigned number from /sys/fs/resctrl/info//. Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- Changelog v5: - Remove '\n' from ksft_print_msg() calls. (Ilpo) - Add Ilpo's reviewed-by tag. - Change 'helpers' -> 'a helper' in the subject. - Change 'a file in' -> '' in patch message. - Remove '*' from resource_info_file_exists()'s comment. - 'saved into the @val' -> 'saved into @val' - 'Error in opening' -> 'Error opening' - Redo path in function comment. Changelog v4: - Rewrite function comment. - Redo ksft_perror() as ksft_print_msg(). (Reinette) Changelog v3: - Rewrite patch message. - Add documentation and rewrote the function. (Reinette) Changelog v2: - Add this patch. tools/testing/selftests/resctrl/resctrl.h | 1 + tools/testing/selftests/resctrl/resctrlfs.c | 36 +++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index a1462029998e..5116ea082d03 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -162,6 +162,7 @@ unsigned int count_contiguous_bits(unsigned long val, unsigned int *start); int get_full_cbm(const char *cache_type, unsigned long *mask); int get_mask_no_shareable(const char *cache_type, unsigned long *mask); int get_cache_size(int cpu_no, const char *cache_type, unsigned long *cache_size); +int resource_info_unsigned_get(const char *resource, const char *filename, unsigned int *val); void ctrlc_handler(int signum, siginfo_t *info, void *ptr); int signal_handler_register(void); void signal_handler_unregister(void); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 5750662cce57..8a183c73bc23 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -249,6 +249,42 @@ static int get_bit_mask(const char *filename, unsigned long *mask) return 0; } +/* + * resource_info_unsigned_get - Read an unsigned value from + * /sys/fs/resctrl/info/@resource/@filename + * @resource: Resource name that matches directory name in + * /sys/fs/resctrl/info + * @filename: File in /sys/fs/resctrl/info/@resource + * @val: Contains read value on success. + * + * Return: = 0 on success, < 0 on failure. On success the read + * value is saved into @val. + */ +int resource_info_unsigned_get(const char *resource, const char *filename, + unsigned int *val) +{ + char file_path[PATH_MAX]; + FILE *fp; + + snprintf(file_path, sizeof(file_path), "%s/%s/%s", INFO_PATH, resource, + filename); + + fp = fopen(file_path, "r"); + if (!fp) { + ksft_print_msg("Error opening %s: %m\n", file_path); + return -1; + } + + if (fscanf(fp, "%u", val) <= 0) { + ksft_print_msg("Could not get contents of %s: %m\n", file_path); + fclose(fp); + return -1; + } + + fclose(fp); + return 0; +} + /* * create_bit_mask- Create bit mask from start, len pair * @start: LSB of the mask From patchwork Fri Feb 9 14:01:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 198884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp872260dyd; Fri, 9 Feb 2024 06:04:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVWV+MbK+GA8+ftwsyx75v4jtvVKz9JqSnwXVCzaM564hnexgs2rkLGkQ44EONcPF1050GLe3XmIKiSwSKxS+6Ly2ewBw== X-Google-Smtp-Source: AGHT+IHXn1lk+vS6mBItb6K/TUXQL1yXk9rhwxBDJkxskD/eFXi0apW4HZQ1jlAWlmgy6BPRlyEG X-Received: by 2002:a05:6102:3749:b0:46d:233b:2233 with SMTP id u9-20020a056102374900b0046d233b2233mr1409524vst.0.1707487493289; Fri, 09 Feb 2024 06:04:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707487493; cv=pass; d=google.com; s=arc-20160816; b=s0kmkdd+KgNNUjIMZ2xTpETRgwUJ7vLbculMxDTHRBvsQvz4uGl8qsK/bg7N+95sw/ 2J0btPn/5TCIHU2J9aSy4gVCa2ijVrhZ91NyFDOzdrvcd43ZHuXcUUdVh1/mNvSJy0AF ZeYZt1LV6FMVy3gG568d+gfKbUAJOeV21HXz1pP5m0LviZDhR3mYNryGe+5FKHp8MVUX n8V3SBM2412xxmL8P5Wv1iC8slHUbqVszplMCvtm9MJaxhAfS/NqPv1cY920Qdug7qQO wixwsb2Cj2f+w2c937tyP/r2Hv6ChfJx0z3BOw6DxXJUZXuB1Dbe4hC+ynAkkH41c0JP WTgQ== 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=qEoRj5qLfsbTiEHc9VrXQHfZ/V4am4Ap1Aj1Mv7Z7xw=; fh=yIoSgQkq8PyYfBv92d9K7ijZZjLPqAw3xXw5J229QjE=; b=xcGT3yzYwaNe3QkjYNDZ3P5y7Rjfbeia3aiDITqhe9OI+sv3+XDIRiSrtK9B8gIHgx uYA3TifdGaNz3s5dS+1IlFAINOwiWTIdzRze4VTrUyAt3jVHuWSP8FLoHQk1TMrq2al4 HJ5oIlfWwEU4dOVwweQe1+IwDRNGDYV7wTk/CErjgvGUEZuLBoV09tMz08P2qPDtVNIo stCXGJ2zxsnpiGOBSOTMPXVc/dXu5kzmTQt0qOz1eVVvR1U6xFRXrDzw+Y5pklRSco4a 7xdXGHe9U+RvHTg6C4rLl8PHDbKF3IstU5jJ7Uu7ghVFnqN1V0UcAbfEaqBAPs+zu1jm CFUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=oI9coJTo; 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-59404-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59404-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUt9yLwmi1sHzTmWDOwB1NtQO3QItHxjnbj6TWTckdBfwHHJoWY6okfnAdi1ttuKlEoqORoh4FVglENOYXx7ngcHk/9IQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id az23-20020a056102285700b0046aface8740si195560vsb.300.2024.02.09.06.04.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:04:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59404-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=oI9coJTo; 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-59404-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59404-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 70BE01C2482D for ; Fri, 9 Feb 2024 14:02:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3563766B56; Fri, 9 Feb 2024 14:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="oI9coJTo" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 218E067E86; Fri, 9 Feb 2024 14:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487323; cv=none; b=MWxj5cfCoWbu0GoHMtf+NYnjruJ5XPzJohfKVk71ljGcKgy8PtKo4Dy+MT6Z5T7z7HHrzwj0Brof3EvM/ohd8Fw+BIecZdwYQAXRi86RKOgJjtIIss6oCwtQ5phfg9bBSyuPTrRdn2ELD4rQA/aawlIjRM/TtF6FUA8HlBSVS4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487323; c=relaxed/simple; bh=FIQ9fq48KDISYrnkBp58xIkJcuO5BR3cZnh2mpxZfSs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XpYOXfSem8Fo0jYxQC1hIufftYff8blcbKsdkf6km83S8dgOe6A1/oR74Xxzuome/WVf0wR7U/hq3mxlFxlxez49fsTv6p49fCS1ntBvHXzF8Pd8Q3eFFfMGLDxL5dMPgrWSVk4MRuf8KimQbUmb1qT0kT9ACUWVUeS0Dhiu2dM= 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=oI9coJTo; arc=none smtp.client-ip=192.198.163.11 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=1707487322; x=1739023322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FIQ9fq48KDISYrnkBp58xIkJcuO5BR3cZnh2mpxZfSs=; b=oI9coJTo/eFcqo+O5vranBW55IZx5ncUhL9XAUdN8pRuzt7Pij9/JM62 2Dr9ALr7HFdwC6t8KaEmNsL2bpfxC6Fv8ysmF5EfMtq/Wo5fCjTukiuME op7IvWq6WhosCMr0WXD0sHLle3xcazt24r/3AjIN3pLMcg8NGz4lfiF1O HCs49J3c12tXkES9p3AMsac8YE35YBD6NMzsmsf+V5ISidLTRo44NTC37 mXG22S25eXw/LRgM1DKzHlh1GMkgz198QX9xPBsqPTWE1ckAfVRaHPM+H wd9U12Qmvpf0SDPaDZC3/5e3jmD/f2MvBoXUCrOYIwPh/dAC8iAVoO4Zg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="12080132" X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="12080132" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:02:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934430883" X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="934430883" Received: from ldziemin-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.2.218]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:01:58 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, shuah@kernel.org, fenghua.yu@intel.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v5 3/5] selftests/resctrl: Split validate_resctrl_feature_request() Date: Fri, 9 Feb 2024 15:01:43 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790430406112763423 X-GMAIL-MSGID: 1790430406112763423 validate_resctrl_feature_request() is used to test both if a resource is present in the info directory, and if a passed monitoring feature is present in the mon_features file. Refactor validate_resctrl_feature_request() into two smaller functions that each accomplish one check to give feature checking more granularity: - Resource directory presence in the /sys/fs/resctrl/info directory. - Feature name presence in the /sys/fs/resctrl/info//mon_features file. Signed-off-by: Maciej Wieczor-Retman --- Changelog v5: - Move back to using resource parameter in mon_feature handling function. (Ilpo) Changelog v4: - Roll back to using test_resource_feature_check() for CMT and MBA. (Ilpo). Changelog v3: - Move new function to a separate patch. (Reinette) - Rewrite resctrl_mon_feature_exists() only for L3_MON. Changelog v2: - Add this patch. tools/testing/selftests/resctrl/cmt_test.c | 2 +- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 6 ++-- tools/testing/selftests/resctrl/resctrl.h | 4 ++- tools/testing/selftests/resctrl/resctrlfs.c | 33 ++++++++++++++------- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index dd5ca343c469..a81f91222a89 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -170,7 +170,7 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param static bool cmt_feature_check(const struct resctrl_test *test) { return test_resource_feature_check(test) && - validate_resctrl_feature_request("L3_MON", "llc_occupancy"); + resctrl_mon_feature_exists("L3_MON", "llc_occupancy"); } struct resctrl_test cmt_test = { diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index da256d2dbe5c..7946e32e85c8 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -171,7 +171,7 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param static bool mba_feature_check(const struct resctrl_test *test) { return test_resource_feature_check(test) && - validate_resctrl_feature_request("L3_MON", "mbm_local_bytes"); + resctrl_mon_feature_exists("L3_MON", "mbm_local_bytes"); } struct resctrl_test mba_test = { diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 34879e7b71a0..d67ffa3ec63a 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -97,7 +97,7 @@ static int mbm_setup(const struct resctrl_test *test, return END_OF_TESTS; /* Set up shemata with 100% allocation on the first run. */ - if (p->num_of_runs == 0 && validate_resctrl_feature_request("MB", NULL)) + if (p->num_of_runs == 0 && resctrl_resource_exists("MB")) ret = write_schemata(p->ctrlgrp, "100", uparams->cpu, test->resource); p->num_of_runs++; @@ -140,8 +140,8 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param static bool mbm_feature_check(const struct resctrl_test *test) { - return validate_resctrl_feature_request("L3_MON", "mbm_total_bytes") && - validate_resctrl_feature_request("L3_MON", "mbm_local_bytes"); + return resctrl_mon_feature_exists("L3_MON", "mbm_total_bytes") && + resctrl_mon_feature_exists("L3_MON", "mbm_local_bytes"); } struct resctrl_test mbm_test = { diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 5116ea082d03..f434a6543b4f 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -136,7 +136,9 @@ int get_domain_id(const char *resource, int cpu_no, int *domain_id); int mount_resctrlfs(void); int umount_resctrlfs(void); int validate_bw_report_request(char *bw_report); -bool validate_resctrl_feature_request(const char *resource, const char *feature); +bool resctrl_resource_exists(const char *resource); +bool resctrl_mon_feature_exists(const char *resource, const char *feature); +bool resource_info_file_exists(const char *resource, const char *file); 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 8a183c73bc23..af4f800ab23d 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -708,20 +708,16 @@ char *fgrep(FILE *inf, const char *str) } /* - * validate_resctrl_feature_request - Check if requested feature is valid. - * @resource: Required resource (e.g., MB, L3, L2, L3_MON, etc.) - * @feature: Required monitor feature (in mon_features file). Can only be - * set for L3_MON. Must be NULL for all other resources. + * resctrl_resource_exists - Check if a resource is supported. + * @resource: Resctrl resource (e.g., MB, L3, L2, L3_MON, etc.) * - * Return: True if the resource/feature is supported, else false. False is + * Return: True if the resource is supported, else false. False is * also returned if resctrl FS is not mounted. */ -bool validate_resctrl_feature_request(const char *resource, const char *feature) +bool resctrl_resource_exists(const char *resource) { char res_path[PATH_MAX]; struct stat statbuf; - char *res; - FILE *inf; int ret; if (!resource) @@ -736,8 +732,25 @@ bool validate_resctrl_feature_request(const char *resource, const char *feature) if (stat(res_path, &statbuf)) return false; + return true; +} + +/* + * resctrl_mon_feature_exists - Check if requested monitoring feature is valid. + * @resource: Resource that uses the mon_features file. Currently only L3_MON + * is valid. + * @feature: Required monitor feature (in mon_features file). + * + * Return: True if the feature is supported, else false. + */ +bool resctrl_mon_feature_exists(const char *resource, const char *feature) +{ + char res_path[PATH_MAX]; + char *res; + FILE *inf; + if (!feature) - return true; + return false; snprintf(res_path, sizeof(res_path), "%s/%s/mon_features", INFO_PATH, resource); inf = fopen(res_path, "r"); @@ -753,7 +766,7 @@ bool validate_resctrl_feature_request(const char *resource, const char *feature) bool test_resource_feature_check(const struct resctrl_test *test) { - return validate_resctrl_feature_request(test->resource, NULL); + return resctrl_resource_exists(test->resource); } int filter_dmesg(void) From patchwork Fri Feb 9 14:02:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 198885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp873365dyd; Fri, 9 Feb 2024 06:06:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVk9nX/pMKQ1QhK/y7IPShGDGBXb58lMTw0JMJVef2TBOcOdlCU9cHLe90wwxfDfPKVHzJDwLhZii6mpiUEA8k5OcjHWg== X-Google-Smtp-Source: AGHT+IHDw9B6TEfnm2N9Ur419kKMfOASJYub0zuUClRkZ/pAVFHBKJbAEZ2MSm0sVEttb2ySYz+U X-Received: by 2002:a17:902:ceca:b0:1d9:473e:f4e9 with SMTP id d10-20020a170902ceca00b001d9473ef4e9mr1917444plg.3.1707487571855; Fri, 09 Feb 2024 06:06:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707487571; cv=pass; d=google.com; s=arc-20160816; b=rtyj3TgyFvDB+US+UVUxyWSB58gQPsZVXkewUKwhItqcUQRSkLCJDQPwc4/jagK8mc li17Tp/ENz1hYZaOjNOQA6tcziLWhxpwzBB6ebCrKhDIkkEncTBMlt4T8ImWWliQk1U/ Drs5bC5VnRrlk6sw73jr6gPk2ATFOS0wme3SxCyZx7UxYOLrEX/ke/VFkYCvUgYh2hE4 YsjYFd+MNinEBYA9RWkgeAuhONl+XrZ9Xxdz5Vjc8H9+8bq2XuOQ7o+rHRQMjI9UnEbg Hf1p1i7oCxR3IuoW25Fo7awRudEQYnntIVALKlyX3mHMxu2jCsFjQnWdz/xn5EfxY7Gg OUyw== 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=DywJtCQ5FwFP/fSfCLyGRLz7VZLpJJhHbYl5SUe8FIA=; fh=J2mQJ06eQwmuuYTEtZnt5UEGWOswC1Pnxg5CBnQCqmM=; b=0Ot4yjkBrNLDOupsbwSZLdJzRwBP9SPovffvooebCtzDbGHyWWiggeRKhMCEKaon/3 uRtFFBa0naJw4GKdM9fzwWBVwSFcskBSRwicXC3TXNlQSmh01c+9NOu8x9HTJGxMEnpN 41shJYXDDeImJ2rBF0dneCcvTZfsmpGPODgTVyk3Qr8C8Pj0bkF1GHxdLzqeKJ/iFHwQ giLU49OARTbsCfwGilXTng7G1OAqZajrn73RDFYDKbD52+7bWoTulIuDG7EOCCgdnb72 QVfalbg+xiPYA7NGBJeY7FeKP9l4LA2j+cF+xw72feeOsyFTkZzm2QaC/Zs3rumZh+Ht MCyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nZuqxKSc; 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-59405-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59405-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWlxT+6YPppxqyrHxShSDByvkNDjj3vrW0BrJwMLA5jzUqwAkv91wmvCdVqeBUH5N/+SvfBUcLlzq/PkoChSq1ZAw9rxQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h14-20020a170902f54e00b001d6f89cfec9si1761280plf.348.2024.02.09.06.06.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:06:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59405-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nZuqxKSc; 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-59405-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59405-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 64A82B2569B for ; Fri, 9 Feb 2024 14:02:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 899A467E83; Fri, 9 Feb 2024 14:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nZuqxKSc" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 52D444F896; Fri, 9 Feb 2024 14:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487339; cv=none; b=r+NBoeYIDdHuZOR38UPmxZk5TI2fB2FiFgytxthJVwGLqaIexQwqxaiXTgZfp2eiefFnTW9XfubMFGqgK0toJ7T/3/K7sYUA9irh800XfyL5ab0u3oAZBH7GUw/E6teyi0UIVp7iqRjvojEnUQ9fL3ynUaxAdfP40O0Lx3G6PoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487339; c=relaxed/simple; bh=fDcuvxUGfdeYto3CEUVfGG+0DKqciD1V5YbuX8YWUjE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MJsvzg//xmVWst/qRyow7J9ucxYtZ555XIjXhGdqnW3EAFrvGScLoGe8McAYofX7Ju4CzzKVOmzl+5ag9f3FuWR5k5YHfzFuww7PBhhJKqiNxD6SWrqAh982PuGee97JB8f8KUIqEzvdVIEkp6zePSWOq2Ym9SJXCnDrAt+kvMg= 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=nZuqxKSc; arc=none smtp.client-ip=192.198.163.16 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=1707487338; x=1739023338; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fDcuvxUGfdeYto3CEUVfGG+0DKqciD1V5YbuX8YWUjE=; b=nZuqxKScB5bf6KleCa7uSN6598gmriC6BpOyUUCQof7Fyy7TLficAOA4 oNYSjLynEV0Z8LWDgpQmR5gVCIQ1P7bTyKBBIfbiju06QeqbSjQP/2rDI bCf5ERch+5yW5CmcZoYM5ixQQOisDiwDsLpS5nzAr3+wYV6nqXeD3Xex9 55whI6KUe9MtprbbaY/V67N7kko6TeC3WSUQQYP585FdymF18dYPUTPxx CieOSZggbPTx2p+/LVBq4NvX+T/YYVBZmmXf/iTo12QH/BrqlLR0AO2Nx H0ZBXRiYuJNLFvktGzDvqByvEb4hjXRhAQiyJVu5hNlONTLK1gEdAc9Hq Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1744520" X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="1744520" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:02:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="2245130" Received: from ldziemin-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.2.218]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:02:15 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, shuah@kernel.org, fenghua.yu@intel.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v5 4/5] selftests/resctrl: Add resource_info_file_exists() Date: Fri, 9 Feb 2024 15:02:01 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790430487828914196 X-GMAIL-MSGID: 1790430487828914196 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 Reviewed-by: Ilpo Järvinen --- Changelog v5: - feature -> file. (Reinette) - Redo return description and path in the comment. (Reinette) 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/resctrlfs.c | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index af4f800ab23d..0e930fc06ab5 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -764,6 +764,31 @@ bool resctrl_mon_feature_exists(const char *resource, 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 /sys/fs/resctrl/info/@resource/@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); From patchwork Fri Feb 9 14:02:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 198883 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp870716dyd; Fri, 9 Feb 2024 06:03:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVRAamEv3MzeOB58HRdK4VUD+69lZmSQuzjg3vIh5T6DqDsae8KNPkMPZzZDrx/t95SVtdztJSnSbncKSaEwszzs/8phg== X-Google-Smtp-Source: AGHT+IGlUNpz4ZiWJziy0En4mtZxrqFhxh0aLu+YYNc2nWnynRQc3L0WEmEhwxkE3Ki/BBauMNsm X-Received: by 2002:a17:906:40cc:b0:a3b:ebb3:29fc with SMTP id a12-20020a17090640cc00b00a3bebb329fcmr1152585ejk.21.1707487393982; Fri, 09 Feb 2024 06:03:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707487393; cv=pass; d=google.com; s=arc-20160816; b=zn+0FKBl5LLGCNkmTlOPG+/HEEoOgjlUG+fqnQywvGBw5BjiCzckam6OHA4vsVSwWg zreBUd07P5fwpW6LyES27i2vQf5D82o8NeobhfRDiEx7Gof6wJrLL2ILKxKMDByjd5v1 CgcjGBQA4216lA6Hzy/sXSpHhA6ZGZWHWqHxCd2zPctQ3RxU4sfUnicia6W8oJ4YQhtD V9/s0PvZthP5fJPd0hmPFFNFRZzkfSk86o8o0JiAgE6nhjxYws2qGjBRK2cIkeg8zIS9 NKTNfAd9s5LlZ08AXVlSGRQ8+PiutSH5GkXYTLqHqV0ixlDOokqzujybtB2usmyMlb1r guUA== 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=csQPsJtNT+RO7QuFTrv/cLo1gYHccexYSDrJ+t1utEU=; fh=TBCj+OoDcVzv0TEminjQASGPny/h4gYrFv/7iXuHNFc=; b=hDpeFB5OGwXbevcXZdRvnCQ+yeplBdy196Ccry47jlRQ6aGHjqRM8BPZ0HC/Ftrwdg VrvytjBuz8QsOb9QuMMLyHnIoMc9I82teFZx0eytQT1WHgI3U+AbRiEnG91gyL5S5Z+B mArtrLkeTaP6M/QXgj+wPmvjEElfBrLrxq5Wzjz/JzlKltQoLgRBLZBD7JbfCvEQyuui 5LQn2glNBVnJmuY8WM0ajwXfoHDIWv7AlYjY1vT0ZTLXvixbt5uvPaAjT0xvJKqpalYE 1WAS0f/PHwv8yboYlBx4jXd+VvZwglNtQheFuwW5mxfHXa3y63oqun9N+fv77o4/IhdO UcxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="lbgpae4/"; 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-59407-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59407-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXD0DCSYbCKjcgBA7YZYnqztwll/ed88cV27nFdH7HKxwy1hx9ixuO5LkmIt7+djt0L8Kndtqgg9T2kO3OWQ6YzbFIR4A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qk35-20020a1709077fa300b00a3857cf0301si972461ejc.452.2024.02.09.06.03.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:03:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59407-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="lbgpae4/"; 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-59407-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59407-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 65FAF1F21B53 for ; Fri, 9 Feb 2024 14:03:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1241692E1; Fri, 9 Feb 2024 14:02:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lbgpae4/" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 EB76157326; Fri, 9 Feb 2024 14:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487353; cv=none; b=HZnw6IXNq6HWXINtrd9OQYTIcJ40VA9XStC/6/2f4C9ozw1VhFEpdXO8dWJ++AW2V3rtycbZc8AnyOM6+CZA6CcP3PwzViAQIXZiCRRmU1TIhks7S19kOMa+ImD3inCnI8AL7khFLGYjaNyCRBEj4nO6Pd5LrXIJGk3FdwfpTKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707487353; c=relaxed/simple; bh=K6rMMQZvXeXM/c2DLOoBYHOlEwO+LI0vLpSgjCF0MuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cGLC3ReKZyoCafNFDO/mdBcuetAgQI3p96kX522K5nHZ6R1FlOqtCL8/34T+R6x7CTgRMI/OFCuZuKY04Krw5PQM4V/iMSMWeCDF7DyHboC1abDc0c23CZkW245Bn6F7aIFeBuam/Xp9RhcVe+YyfF9GGSj7WNDYirpvh9ywOcg= 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=lbgpae4/; arc=none smtp.client-ip=192.198.163.19 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=1707487352; x=1739023352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K6rMMQZvXeXM/c2DLOoBYHOlEwO+LI0vLpSgjCF0MuA=; b=lbgpae4/7ZA3SRc0b7PMn5ohVWISk5IOQiN1ftIPZ5PoEOpLIfmZFUSH 1jvWDPG9Cj2EUQwiJGxWfwR+1SSWmIrgVQ0RNU1+/SLmci1OPxyd1/hUc bQuKJIgMW+y+1iR6bclVu5wOib0FZ/DBLk3oJ/AKbWMUZszEJ/36nKJxL +7Ou45VCOKsicrnT8jV0gP6xriYd98bP42CzUEC95o/NrRUTkA1KFcF5f FlkmnzbMbHtL/OWsR0pkJ5NbV2CD+vNVbwp2lsB6iYWIO2+1UEd24Jtut HjJ86QM/CWLxHuguQ+SVP3GfcaAzfbf+AchMe+3LdyCtIvx6KwhxYI6X9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1328896" X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="1328896" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:02:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,257,1701158400"; d="scan'208";a="6596724" Received: from ldziemin-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.2.218]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2024 06:02:29 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, shuah@kernel.org, fenghua.yu@intel.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v5 5/5] selftests/resctrl: Add non-contiguous CBMs CAT test Date: Fri, 9 Feb 2024 15:02:18 +0100 Message-ID: <2c1011e7630605365b67caa6ddfe4e8ee2ba5bff.1707487039.git.maciej.wieczor-retman@intel.com> 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790430301652525460 X-GMAIL-MSGID: 1790430301652525460 Add tests for both L2 and L3 CAT to verify the return values generated by writing non-contiguous CBMs don't contradict the reported non-contiguous support information. Use a logical XOR to confirm return value of write_schemata() and non-contiguous CBMs support information match. Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Reinette Chatre Reviewed-by: Ilpo Järvinen --- Changelog v5: - Add Reinette's reviewed-by tag. - Make 0xf UL in case the CBMs get bigger in the future. (Ilpo) Changelog v4: - Return failure instead of error on check of cpuid against sparse_masks and on contiguous write_schemata fail. (Reinette) Changelog v3: - Roll back __cpuid_count part. (Reinette) - Update function name to read sparse_masks file. - Roll back get_cache_level() changes. - Add ksft_print_msg() to contiguous schemata write error handling (Reinette). Changelog v2: - Redo the patch message. (Ilpo) - Tidy up __cpuid_count calls. (Ilpo) - Remove redundant AND in noncont_mask calculations (Ilpo) - Fix bit_center offset. - Add newline before function return. (Ilpo) - Group non-contiguous tests with CAT tests. (Ilpo) - Use a helper for reading sparse_masks file. (Ilpo) - Make get_cache_level() available in other source files. (Ilpo) tools/testing/selftests/resctrl/cat_test.c | 81 +++++++++++++++++++ tools/testing/selftests/resctrl/resctrl.h | 2 + .../testing/selftests/resctrl/resctrl_tests.c | 2 + 3 files changed, 85 insertions(+) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 39fc9303b8e8..d4b7bf8a6780 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -294,6 +294,71 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param return ret; } +static int noncont_cat_run_test(const struct resctrl_test *test, + const struct user_params *uparams) +{ + unsigned long full_cache_mask, cont_mask, noncont_mask; + unsigned int eax, ebx, ecx, edx, ret, sparse_masks; + char schemata[64]; + int bit_center; + + /* Check to compare sparse_masks content to CPUID output. */ + ret = resource_info_unsigned_get(test->resource, "sparse_masks", &sparse_masks); + if (ret) + return ret; + + if (!strcmp(test->resource, "L3")) + __cpuid_count(0x10, 1, eax, ebx, ecx, edx); + else if (!strcmp(test->resource, "L2")) + __cpuid_count(0x10, 2, eax, ebx, ecx, edx); + else + return -EINVAL; + + if (sparse_masks != ((ecx >> 3) & 1)) { + ksft_print_msg("CPUID output doesn't match 'sparse_masks' file content!\n"); + return 1; + } + + /* Write checks initialization. */ + ret = get_full_cbm(test->resource, &full_cache_mask); + if (ret < 0) + return ret; + bit_center = count_bits(full_cache_mask) / 2; + cont_mask = full_cache_mask >> bit_center; + + /* Contiguous mask write check. */ + snprintf(schemata, sizeof(schemata), "%lx", cont_mask); + ret = write_schemata("", schemata, uparams->cpu, test->resource); + if (ret) { + ksft_print_msg("Write of contiguous CBM failed\n"); + return 1; + } + + /* + * Non-contiguous mask write check. CBM has a 0xf hole approximately in the middle. + * Output is compared with support information to catch any edge case errors. + */ + noncont_mask = ~(0xfUL << (bit_center - 2)) & full_cache_mask; + snprintf(schemata, sizeof(schemata), "%lx", noncont_mask); + ret = write_schemata("", schemata, uparams->cpu, test->resource); + if (ret && sparse_masks) + ksft_print_msg("Non-contiguous CBMs supported but write of non-contiguous CBM failed\n"); + else if (ret && !sparse_masks) + ksft_print_msg("Non-contiguous CBMs not supported and write of non-contiguous CBM failed as expected\n"); + else if (!ret && !sparse_masks) + ksft_print_msg("Non-contiguous CBMs not supported but write of non-contiguous CBM succeeded\n"); + + return !ret == !sparse_masks; +} + +static bool noncont_cat_feature_check(const struct resctrl_test *test) +{ + if (!resctrl_resource_exists(test->resource)) + return false; + + return resource_info_file_exists(test->resource, "sparse_masks"); +} + struct resctrl_test l3_cat_test = { .name = "L3_CAT", .group = "CAT", @@ -301,3 +366,19 @@ struct resctrl_test l3_cat_test = { .feature_check = test_resource_feature_check, .run_test = cat_run_test, }; + +struct resctrl_test l3_noncont_cat_test = { + .name = "L3_NONCONT_CAT", + .group = "CAT", + .resource = "L3", + .feature_check = noncont_cat_feature_check, + .run_test = noncont_cat_run_test, +}; + +struct resctrl_test l2_noncont_cat_test = { + .name = "L2_NONCONT_CAT", + .group = "CAT", + .resource = "L2", + .feature_check = noncont_cat_feature_check, + .run_test = noncont_cat_run_test, +}; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index f434a6543b4f..2051bd135e0d 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -209,5 +209,7 @@ extern struct resctrl_test mbm_test; extern struct resctrl_test mba_test; extern struct resctrl_test cmt_test; extern struct resctrl_test l3_cat_test; +extern struct resctrl_test l3_noncont_cat_test; +extern struct resctrl_test l2_noncont_cat_test; #endif /* RESCTRL_H */ diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 3044179ee6e9..f3dc1b9696e7 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -19,6 +19,8 @@ static struct resctrl_test *resctrl_tests[] = { &mba_test, &cmt_test, &l3_cat_test, + &l3_noncont_cat_test, + &l2_noncont_cat_test, }; static int detect_vendor(void)