Message ID | 647fbfd449f8b0e0ad6cfe58bb280ff44ee162b8.1706180726.git.maciej.wieczor-retman@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-38492-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1565423dyi; Thu, 25 Jan 2024 03:17:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1qZig5LY4M7Bc3kNPyP9dMOtkhX0i8IG/3o2HnVGp73kF8rkV3KNkMumEsbLg1NMsEvZV X-Received: by 2002:a05:6214:2681:b0:686:955d:8910 with SMTP id gm1-20020a056214268100b00686955d8910mr844582qvb.45.1706181451718; Thu, 25 Jan 2024 03:17:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706181451; cv=pass; d=google.com; s=arc-20160816; b=h3UO7rCUaEf27C2VKHQyLErJDrLbHCzl5dAJGvOEVBiudWTPw6lpEH/YS6SEiJtX00 peKblrd/yu2wrsB8Bls4guWnD7tXlFXOPEBvkdejzC9eJsFZpmrR7b7ykDPQFkxROfDQ vtpjMXmBmS+BLnxVAWTUQJ9Q9MWeia6cwNzL30kshqBlUtNxAFBuRnQSMPjRZHPBr96H NsN7RKbhMzvjWzrWqreq/mWI4erRY54b5g1Zh1GvnQjRgAJtZ833t2ie92Lp8vILU3P9 jcVfyU4kDkqCk1H8ql+FnFeoE3infP4bMXqzcdAlF2n24PJzyKGw38zWnae7omfOEQDB RJKw== 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=8kjNGD277B/PKVzZOcrg9HdajB/CNBBHw9Betc3wIwI=; fh=XecgLwbghP1RJXOXr8/t+UNgfnXIFsitIr7f8CTtVmE=; b=NIt9/ROXCHa8dTXOMrxFURdD5gXIWsydenLQN9wIewSz4gJUjiuqgAKXm8Lh3TeEvG mOsx+YtnV1gxbi3LJdq88yJnSFPYKO+QAmGR4P56/DmNShiNwTtpa1ghMdn2csxnnF2F +8vTZzF7ZChaeCWcRBa7wrqeZhoGsDVssXomEDCDFT6pt0u9GAoVRqttSwy8McGAQ+gb eGGXXnKO5fkjGDb7e3f1snvZDCA6oKuhSd1fjEJ1QIlFXOMfxrgRirLJ0q9sIzzZkmyc uu0Y8c4+eItF2iMXgszi63ZvmyrD7Akabbt51t0Am/pFgT9GrNsUu1/XUyObZivkfaAq d9Cg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BPbFMRmb; 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-38492-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38492-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y14-20020a0cf14e000000b0068171ee32bcsi12237676qvl.451.2024.01.25.03.17.31 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:17:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38492-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=BPbFMRmb; 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-38492-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38492-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 6E0A41C20BE9 for <ouuuleilei@gmail.com>; Thu, 25 Jan 2024 11:17:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39BCC55C3E; Thu, 25 Jan 2024 11:13:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BPbFMRmb" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 8DB2D55C06; Thu, 25 Jan 2024 11:13:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181216; cv=none; b=GRXGEC1J3l/r2RWGBUQ3PLIC7H2YBnV08FNOF1xs+nSZPetYtu+BQWYNjAzHEHG1L90NhriDIXPQy/9pTamXRqv63nh1zVfcZU/EkfSdfoycqtee3e/rPjbQjts89ErrdwtqaR6FGSGQhpeWSFdduG5maL4b8ORtOk6Qn36EvuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181216; c=relaxed/simple; bh=wvPvlJpDpd/QxRlMnz5Gl6xGp3XTyHaDNtoD/6HTHOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vFxplZA8wLFkDMjYlSafQwlAej2V1Naelq25QOOJ/Pus3BPhfHewb6giTHlNttwQlOHS38wtJLcp8oIrP0hFkf+m5ygVSSWPehexnqzfGK7dDpya5tvVpnXXWl4RVbYtKx+wg2uDCRHWyYxfK1FiZKcTFVFpJ+Bo5IPBp00Wi0s= 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=BPbFMRmb; arc=none smtp.client-ip=198.175.65.13 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=1706181215; x=1737717215; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wvPvlJpDpd/QxRlMnz5Gl6xGp3XTyHaDNtoD/6HTHOQ=; b=BPbFMRmbtrkwp3z+ygHstZIHNvA2QNg6p2QzkofD0FvT5g0i8LhAG8iE reqByJbImi7+SEl16gkCOptcYV58BJuhLnTlfPhgUAZnKzTKpaVQ1ODcE +U8B0/jlMEzTG3nODwrKsv84L0t0mtfbVJJLPbMttcxV9UaWfUn2Qu9+6 hIZ1O9bGSITIkcsIzHP52oQFRfO+YF0d5amlzDV/d5KFfRGLRTNLEkvta 2lJncC+oy07Jo/Vmp5Nlbq/fVigGTCMDrLVbNzhhtX2tuB6zEk/7DHf4a fSuTvgGDDBRFMeWTnEHDpMx7QQ0OaXv2WyN74tK9yB9ZaGR//KLTieXr+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="9244677" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="9244677" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:13:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="959823461" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="959823461" Received: from apejovix-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.0.239]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:13:31 -0800 From: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> To: fenghua.yu@intel.com, reinette.chatre@intel.com, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v3 5/5] selftests/resctrl: Add non-contiguous CBMs CAT test Date: Thu, 25 Jan 2024 12:13:16 +0100 Message-ID: <647fbfd449f8b0e0ad6cfe58bb280ff44ee162b8.1706180726.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <cover.1706180726.git.maciej.wieczor-retman@intel.com> References: <cover.1706180726.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-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789060921622724275 X-GMAIL-MSGID: 1789060921622724275 |
Series |
selftests/resctrl: Add non-contiguous CBMs in Intel CAT selftest
|
|
Commit Message
Maciej Wieczor-Retman
Jan. 25, 2024, 11:13 a.m. UTC
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 <maciej.wieczor-retman@intel.com>
---
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(+)
Comments
Hi Maciej, On 1/25/2024 3:13 AM, Maciej Wieczor-Retman wrote: > 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 <maciej.wieczor-retman@intel.com> > --- > 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..9086bf359072 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; If I understand correctly this falls into the "test failure" [1] category and should 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 ret; .. although here I think the goal to distinguish between test error and test failure falls apart since it is not possible to tell within the test if the failure is because of error in the test or if test failed. Reinette [1] https://lore.kernel.org/all/33787043-5823-6de4-4e5c-a24a136ba541@linux.intel.com/
Hi! On 2024-01-26 at 13:10:18 -0800, Reinette Chatre wrote: >Hi Maciej, > >On 1/25/2024 3:13 AM, Maciej Wieczor-Retman wrote: >> 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 <maciej.wieczor-retman@intel.com> >> --- >> 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..9086bf359072 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; > >If I understand correctly this falls into the "test failure" [1] category >and should 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 ret; > >... although here I think the goal to distinguish between test error and test failure >falls apart since it is not possible to tell within the test if the failure is >because of error in the test or if test failed. Is there even a distinction between test error and failure in resctrl selftest? I've been looking at it for a while and can't find any instances where ksft_test_result_error() would be used. Everywhere I look it's either pass or fail. By grep-ing over all selftests I found only five tests that use ksft_test_result_error(). Furthermore there is this one "TODO" in kselftests.h: /* TODO: how does "error" differ from "fail" or "skip"? */ If you meant the distintion less literally then I'd say the sparse_masks comparison to CPUID would be a failure. What I had in mind is that it tries to validate a resctrl interface relevant to non-contiguous CBMs. If it fails there is probably something wrong with the code concerning non-contiguous CBMs. On the other hand writing contiguous CBMs shouldn't fail as far as the non-contiguous CBMs in CAT test is concerned. So if that fails there might be something wrong on a higher level and I'd say that can be more of an error than a failure. But I'm just saying how I undestood it so far. If there is some clear distinction between error and failure definitions I could try to separate it more explicitly. > >Reinette > >[1] https://lore.kernel.org/all/33787043-5823-6de4-4e5c-a24a136ba541@linux.intel.com/ >
Hi Maciej, On 1/31/2024 4:55 AM, Maciej Wieczor-Retman wrote: > On 2024-01-26 at 13:10:18 -0800, Reinette Chatre wrote: >> On 1/25/2024 3:13 AM, Maciej Wieczor-Retman wrote: >>> 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 <maciej.wieczor-retman@intel.com> >>> --- >>> 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..9086bf359072 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; >> >> If I understand correctly this falls into the "test failure" [1] category >> and should 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 ret; >> >> ... although here I think the goal to distinguish between test error and test failure >> falls apart since it is not possible to tell within the test if the failure is >> because of error in the test or if test failed. > > Is there even a distinction between test error and failure in resctrl selftest? There is such a distinction in the current tests (and from what I understand the reason behind the logical XOR used in this test) . In existing tests the running of the test precedes and is clearly separate from determining of the test pass/fail. All the current tests have a clear "run the test" phase where data is collected to a file, followed by an analysis (aka "check results") phase that looks at collected data to determine if the test passes or fails. Note how all the "check results" return either 0 or 1 to indicate test pass or fail respectively. Specifically, you can refer to: mbm_test.c->check_results() mba_test.c->check_results() cmt_test.c->check_results() cat_test.c->check_results() > I've been looking at it for a while and can't find any instances where > ksft_test_result_error() would be used. Everywhere I look it's either pass or > fail. By grep-ing over all selftests I found only five tests that use > ksft_test_result_error(). Yes, from the user perspective there is no such distinction. This seems to be entirely internal to the resctrl selftests (but I do not think that this should or can be a hard requirement). > > Furthermore there is this one "TODO" in kselftests.h: > > /* TODO: how does "error" differ from "fail" or "skip"? */ > > If you meant the distintion less literally then I'd say the sparse_masks > comparison to CPUID would be a failure. What I had in mind is that it tries to > validate a resctrl interface relevant to non-contiguous CBMs. If it fails > there is probably something wrong with the code concerning non-contiguous CBMs. Wrong with which code? As I understand this particular check compares the resctrl view of the world to the hardware realities. If this check fails then I do not think this is an issue with the test code (which would make it a test error) but instead a resctrl bug and thus a test failure. > On the other hand writing contiguous CBMs shouldn't fail as far as the > non-contiguous CBMs in CAT test is concerned. So if that fails there might be > something wrong on a higher level and I'd say that can be more of an error than > a failure. I think that the write_schemata() can fail for a variety of reasons, some may indicate an issue with the test while some may indicate an issue with resctrl. It is not possible for the caller of write_schemata() to distinguish. > But I'm just saying how I undestood it so far. If there is some clear > distinction between error and failure definitions I could try to separate it > more explicitly. I do not think it is possible to clearly distinguish between error and failure. These are already lumped together as a ksft_test_result_fail() anyway so no risk of confusion to folks just running the tests. I think the final test result may be confusing to folks parsing the resctrl selftest internals: run_single_test() { ... ret = test->run_test(test, uparams); ksft_test_result(!ret, "%s: test\n", test->name); ... } above means that a test returning negative or greater than zero value is considered a test failure and resctrl tests may return either in the case of an actual test failure ... but from user perspective there is no difference so I do not think it is an issue, just lack of consistency in the resctrl test internals in cases like write_schemata() failure where a possible test fail is captured as a test error. I do not think it is required to be strict here. Keeping "test returns negative or greater than zero on test failure" seems reasonable to me. Reinette
Hello! On 2024-02-01 at 11:47:44 -0800, Reinette Chatre wrote: >Hi Maciej, > >On 1/31/2024 4:55 AM, Maciej Wieczor-Retman wrote: >> On 2024-01-26 at 13:10:18 -0800, Reinette Chatre wrote: >>> On 1/25/2024 3:13 AM, Maciej Wieczor-Retman wrote: >>>> + if (sparse_masks != ((ecx >> 3) & 1)) { >>>> + ksft_print_msg("CPUID output doesn't match 'sparse_masks' file content!\n"); >>>> + return -1; >>> >>> If I understand correctly this falls into the "test failure" [1] category >>> and should 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 ret; >>> >>> ... although here I think the goal to distinguish between test error and test failure >>> falls apart since it is not possible to tell within the test if the failure is >>> because of error in the test or if test failed. >> >> Is there even a distinction between test error and failure in resctrl selftest? > >There is such a distinction in the current tests (and from what I understand the reason >behind the logical XOR used in this test) . In existing tests the running of >the test precedes and is clearly separate from determining of the test pass/fail. >All the current tests have a clear "run the test" phase where data is collected to >a file, followed by an analysis (aka "check results") phase that looks at collected >data to determine if the test passes or fails. >Note how all the "check results" return either 0 or 1 to indicate test pass >or fail respectively. Specifically, you can refer to: >mbm_test.c->check_results() >mba_test.c->check_results() >cmt_test.c->check_results() >cat_test.c->check_results() > >> I've been looking at it for a while and can't find any instances where >> ksft_test_result_error() would be used. Everywhere I look it's either pass or >> fail. By grep-ing over all selftests I found only five tests that use >> ksft_test_result_error(). > >Yes, from the user perspective there is no such distinction. This seems to >be entirely internal to the resctrl selftests (but I do not think that this >should or can be a hard requirement). Okay, thank you, that's what I wanted to know. > >> >> Furthermore there is this one "TODO" in kselftests.h: >> >> /* TODO: how does "error" differ from "fail" or "skip"? */ >> >> If you meant the distintion less literally then I'd say the sparse_masks >> comparison to CPUID would be a failure. What I had in mind is that it tries to >> validate a resctrl interface relevant to non-contiguous CBMs. If it fails >> there is probably something wrong with the code concerning non-contiguous CBMs. > >Wrong with which code? As I understand this particular check compares the >resctrl view of the world to the hardware realities. If this check fails >then I do not think this is an issue with the test code (which would make it a test >error) but instead a resctrl bug and thus a test failure. I also meant a resctrl bug. I was thinking about the kernel resctrl code that handles taking the CPUID information about non-contiguous CBMs and putting it in the sparse_masks file. If there was a hardware problem and CPUID returned wrong information, then the check wouldn't fail as sparse_masks relies on CPUID too and both values would match. So in view of this I thought that this check could make sure that the resctrl kernel code handles CPUID returned information properly. So should this check be moved from the "run the test" phase to the end of the function ("check results" phase) to signify that it's not an error but a failure? > >> On the other hand writing contiguous CBMs shouldn't fail as far as the >> non-contiguous CBMs in CAT test is concerned. So if that fails there might be >> something wrong on a higher level and I'd say that can be more of an error than >> a failure. > >I think that the write_schemata() can fail for a variety of reasons, some may >indicate an issue with the test while some may indicate an issue with resctrl. >It is not possible for the caller of write_schemata() to distinguish. > >> But I'm just saying how I undestood it so far. If there is some clear >> distinction between error and failure definitions I could try to separate it >> more explicitly. > >I do not think it is possible to clearly distinguish between error and failure. >These are already lumped together as a ksft_test_result_fail() anyway so no >risk of confusion to folks just running the tests. >I think the final test result may be confusing to folks parsing the >resctrl selftest internals: > > run_single_test() > { > ... > ret = test->run_test(test, uparams); > ksft_test_result(!ret, "%s: test\n", test->name); > ... > } > >above means that a test returning negative or greater than zero value is >considered a test failure and resctrl tests may return either in the case of >an actual test failure ... but from user perspective there is no difference >so I do not think it is an issue, just lack of consistency in the resctrl >test internals in cases like write_schemata() failure where a possible >test fail is captured as a test error. > >I do not think it is required to be strict here. Keeping "test returns >negative or greater than zero on test failure" seems reasonable to me. Okay, so the approach I applied in noncont_cat_run_test() with write_schemata() is acceptable? > >Reinette
Hi Maciej, On 2/2/2024 2:17 AM, Maciej Wieczor-Retman wrote: > On 2024-02-01 at 11:47:44 -0800, Reinette Chatre wrote: >> Hi Maciej, >> >> On 1/31/2024 4:55 AM, Maciej Wieczor-Retman wrote: >>> On 2024-01-26 at 13:10:18 -0800, Reinette Chatre wrote: >>>> On 1/25/2024 3:13 AM, Maciej Wieczor-Retman wrote: >>>>> + if (sparse_masks != ((ecx >> 3) & 1)) { >>>>> + ksft_print_msg("CPUID output doesn't match 'sparse_masks' file content!\n"); >>>>> + return -1; >>>> >>>> If I understand correctly this falls into the "test failure" [1] category >>>> and should 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 ret; >>>> >>>> ... although here I think the goal to distinguish between test error and test failure >>>> falls apart since it is not possible to tell within the test if the failure is >>>> because of error in the test or if test failed. >>> >>> Is there even a distinction between test error and failure in resctrl selftest? >> >> There is such a distinction in the current tests (and from what I understand the reason >> behind the logical XOR used in this test) . In existing tests the running of >> the test precedes and is clearly separate from determining of the test pass/fail. >> All the current tests have a clear "run the test" phase where data is collected to >> a file, followed by an analysis (aka "check results") phase that looks at collected >> data to determine if the test passes or fails. >> Note how all the "check results" return either 0 or 1 to indicate test pass >> or fail respectively. Specifically, you can refer to: >> mbm_test.c->check_results() >> mba_test.c->check_results() >> cmt_test.c->check_results() >> cat_test.c->check_results() >> >>> I've been looking at it for a while and can't find any instances where >>> ksft_test_result_error() would be used. Everywhere I look it's either pass or >>> fail. By grep-ing over all selftests I found only five tests that use >>> ksft_test_result_error(). >> >> Yes, from the user perspective there is no such distinction. This seems to >> be entirely internal to the resctrl selftests (but I do not think that this >> should or can be a hard requirement). > > Okay, thank you, that's what I wanted to know. > >> >>> >>> Furthermore there is this one "TODO" in kselftests.h: >>> >>> /* TODO: how does "error" differ from "fail" or "skip"? */ >>> >>> If you meant the distintion less literally then I'd say the sparse_masks >>> comparison to CPUID would be a failure. What I had in mind is that it tries to >>> validate a resctrl interface relevant to non-contiguous CBMs. If it fails >>> there is probably something wrong with the code concerning non-contiguous CBMs. >> >> Wrong with which code? As I understand this particular check compares the >> resctrl view of the world to the hardware realities. If this check fails >> then I do not think this is an issue with the test code (which would make it a test >> error) but instead a resctrl bug and thus a test failure. > > I also meant a resctrl bug. I was thinking about the kernel resctrl code that > handles taking the CPUID information about non-contiguous CBMs and putting it in > the sparse_masks file. > > If there was a hardware problem and CPUID returned wrong information, then the > check wouldn't fail as sparse_masks relies on CPUID too and both values would > match. So in view of this I thought that this check could make sure that the > resctrl kernel code handles CPUID returned information properly. > > So should this check be moved from the "run the test" phase to the end of the > function ("check results" phase) to signify that it's not an error but a > failure? I do not think this test matches the "run" and "check" phases of previous tests, unless you create a new test for every scenario checked within this test. Just returning 1 when the check (if (sparse_masks != ((ecx >> 3) & 1))) fails should be ok, no? >>> On the other hand writing contiguous CBMs shouldn't fail as far as the >>> non-contiguous CBMs in CAT test is concerned. So if that fails there might be >>> something wrong on a higher level and I'd say that can be more of an error than >>> a failure. >> >> I think that the write_schemata() can fail for a variety of reasons, some may >> indicate an issue with the test while some may indicate an issue with resctrl. >> It is not possible for the caller of write_schemata() to distinguish. >> >>> But I'm just saying how I undestood it so far. If there is some clear >>> distinction between error and failure definitions I could try to separate it >>> more explicitly. >> >> I do not think it is possible to clearly distinguish between error and failure. >> These are already lumped together as a ksft_test_result_fail() anyway so no >> risk of confusion to folks just running the tests. >> I think the final test result may be confusing to folks parsing the >> resctrl selftest internals: >> >> run_single_test() >> { >> ... >> ret = test->run_test(test, uparams); >> ksft_test_result(!ret, "%s: test\n", test->name); >> ... >> } >> >> above means that a test returning negative or greater than zero value is >> considered a test failure and resctrl tests may return either in the case of >> an actual test failure ... but from user perspective there is no difference >> so I do not think it is an issue, just lack of consistency in the resctrl >> test internals in cases like write_schemata() failure where a possible >> test fail is captured as a test error. >> >> I do not think it is required to be strict here. Keeping "test returns >> negative or greater than zero on test failure" seems reasonable to me. > > Okay, so the approach I applied in noncont_cat_run_test() with write_schemata() > is acceptable? In general I'd say a write_schemata() failure's return code will be acceptable, but you should be consistent in this test. There are two write_schemata() calls in this test, one treats an error return as a failure and the other treats an error return as an error. Considering this inconsistency I would thus rather suggest that you always treat write_schemata() error return as a test failure. Reinette
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 39fc9303b8e8..9086bf359072 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 ret; + } + + /* + * 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 = ~(0xf << (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 c39105f46da9..8cb97f278459 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -210,5 +210,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)