From patchwork Thu Jan 25 11:10:09 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: 192000 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1564961dyi; Thu, 25 Jan 2024 03:16:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbTJQaxtSGbNEEBrDTjzuJGURw0WABo90RjGi4B0r1QtPuoQRLVGaw8weEbCTM5+p3b15M X-Received: by 2002:ac8:5c0d:0:b0:42a:414f:c15e with SMTP id i13-20020ac85c0d000000b0042a414fc15emr807784qti.38.1706181395983; Thu, 25 Jan 2024 03:16:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706181395; cv=pass; d=google.com; s=arc-20160816; b=fH00Zgw6Ro3faAc4IyK1DrLSq2ttj86aoRMls/ulp3z70cF5ofAjFcCFbo43gK8zxz 9Yt01NqzujIj7SwrSnsAHvpcJLLwdGypDcdRP5I5agO3KIhILcH4jFSdnZF+MWb1glc1 YQyN19rp/GFFG0GcM7mBU3TJlj71KoLcTvABZ51/kWN6OqHW5RkA123OxaLoDfPVSAuz BlW0ly4sV93maK/uPcIGbOCgbypVyost9Z3MV6yOfULpQz0PrV/6AV5AiQkpm2Ms+sIL 4kykODhI/jExvX3RybYJ/ZOE3BE5hLigDqNtJCcAfyFlmiRfTqHU0dCa2lbpV178XtNB J+/w== 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=SePm7hdaFAkvNmuFVzoNGPM41lR8bzEfn69biyLTEpM=; fh=fnwFv1nS+x8hI9pZ0wUR4YbmriHn0jk42nwaadNtlEo=; b=F4UO2AODpNiogx7061qx3STsR6XXNSqwasVRO7ojgpA72Jf+lvfO4Kb3Dx7i0p4ddZ HVfpHw1J2+BK65ma2jR4DW5hXVRIG+8p6mm2lmKrEeZpPNDOPlqk58m76jbbsuAbHMHq ahIS8NPREB8+HuUIxsG8PiQUpz8AUhQJSBlYkY4iI/+FQRpd3IV3ZBexsE6WYFddp1tL erYdnA4xZSNQDlzXN5WVHmWseYBX3EEBYD8i11eOS5p2T6qbFJBnI+cA80zx3rFuSHa4 NB1I6f+R2aIarKj1LvSrrN0wMRQ3eiagh4I3mJ8OX/aFnge8izxny2q8O5fPIrSRAmrM +cmA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jSjv95FV; 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-38488-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38488-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 g21-20020ac87f55000000b0042a6cdffed6si751320qtk.486.2024.01.25.03.16.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:16:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38488-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=jSjv95FV; 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-38488-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38488-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 B50341C20AD5 for ; Thu, 25 Jan 2024 11:16:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F9355102C; Thu, 25 Jan 2024 11:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jSjv95FV" 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 0E0C451017; Thu, 25 Jan 2024 11:10:55 +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=1706181057; cv=none; b=hEz4mXhtcDUS6jdl5mZ1EYVfYO/qv1Wk21A2AUcI21DntLeBcJml5Ti2R9uTcC+StSV/GsWXUOAJXxP8GLncbXo3QVj+CwxvIk5m752CuzmIbotIksaUVeQc6U6vwkRx3TXekrpx/upZzvZQ5J/buU1gMmtiZdmVgPimF40L9jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181057; c=relaxed/simple; bh=zZN4cETb3MBIZuAuJx/wxgse1CPcOB28R3CvbuhlFiM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iah5fXhV0zVnyXtpTRNvt9B8jIssj7Sf3/Oo6XGoTxAz2/M4C64VdggikqvWv8o5e2n3n6fht8voqbmhDAVAg/nPVihVWdyrVUy0btfDBzukdgpnpI8hOO6urGOSBaHT+oOSWkw/x2S+PdmY5rYltXK9TynP29UqEizsRM+XGKI= 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=jSjv95FV; 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=1706181056; x=1737717056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zZN4cETb3MBIZuAuJx/wxgse1CPcOB28R3CvbuhlFiM=; b=jSjv95FVgT6btkMPgERI5FAAuWH3HF2gthpNaaZVZMeqjlE5SkugSSkb HPKMHU7hRy9uutnLJRtt0gamFCy80s70pPd0AgDsLaZMJv1SS3ZZwUfGe nM7zmX1WXdU4IxBpcseFS+HSTs0IU+RjSBhD7xlk1VNrfNiZeuV7eQFtl 0fZIRaxfCPA0WNDObLwkMt65zmn6ncKY36Oespv2jaUSjGMsolSM+S72U vMiXDfOPRG5lqezWpkNs/ci4jPMlJ0Nc8gS5QUaKuSawGoNDbh7cgd+KT PtFaJ1GuaBzPKMj+srByldq2s1wtugwBWdTvmVKYDX+VdU+Qnk6gb90Zi w==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="9244149" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="9244149" 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:10:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="959822713" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="959822713" 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:10:53 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, fenghua.yu@intel.com, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v3 1/5] selftests/resctrl: Add test groups and name L3 CAT test L3_CAT Date: Thu, 25 Jan 2024 12:10:09 +0100 Message-ID: <4462d207c35c7d22875ab58be6aecb1a899d254f.1706180726.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: 1789060863758687044 X-GMAIL-MSGID: 1789060863758687044 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 --- 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 Thu Jan 25 11:10:55 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: 192005 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1565720dyi; Thu, 25 Jan 2024 03:18:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4zdzzn0DIC6/0HkgABjsuQ5HCiKjojcPLY5v3igoo91lgYWdSbGDWKtzbavZ8A91hMqYS X-Received: by 2002:a17:902:b942:b0:1d7:1342:64cd with SMTP id h2-20020a170902b94200b001d7134264cdmr618591pls.10.1706181484907; Thu, 25 Jan 2024 03:18:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706181484; cv=pass; d=google.com; s=arc-20160816; b=uyQdWuq+HSea79EXUWK0YG4RbTpwWGF3S65MyHC6DOOaW0P9qkMgJ1DAEf6exbCxEb 5iHzMEqIor+TM/t0mjeSfilR4/7sHJs0xQN6jLHiow46go79HvZB7IiAnyWAddrL5d3W dUE+6jORQ+f5XzTj+lndoSLwxzI34T2WHw5yPyO6P9PVqiBI/qI7kfGSfaoYwaLkL5C2 s4+DA+5pnnY94kGfv6gjDdjZFq9n1z40gs+ukw3asfuQRsYDoQhYZBtqmJq33/0v1t7F lGOwBj65g1iScwzevDMfryqgOAQk1IkcZPOM9KLxq+MeaMMN74KKPVYlcRBliyH2EI5E Glzg== 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=HYMlGCgFO5vns8wtsQGKaR83HXE+jUT24KH8r+G2HnY=; fh=fnwFv1nS+x8hI9pZ0wUR4YbmriHn0jk42nwaadNtlEo=; b=pZAGpGic9gC0vltdyA7DCo/YiC0fEQViloyh+XFStCpRezYVrL8RPaqUHvNaEkAgYS 7PAsWc8k97Qyv0zq5KseLuF8mW66AagRK9g8eqHj1q002Kpdk0blgLI0jAQors+7AV0t owWX8eG7eJjlkuD0LJvPyUhYnt3O1jGa6Tf8o8S/H5fwMFWc5UXkouMgO2lhfH77PHxU +K5MnqUubUHmJy6u7T6YwbUFAAX7h40sJJgHCEQd86eAY3lpt4fIBgmvij7UD8dpEjLt lh5rJ/QVMju2YEtfqIbeAFcwK84MRHxZ2DMVk4BKnF67U0tlvzFNi8dsD7KgITFWHfgK YO9w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RkoI9W8M; 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-38489-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38489-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f13-20020a170902ce8d00b001ce5ba27888si223333plg.211.2024.01.25.03.18.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:18:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38489-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RkoI9W8M; 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-38489-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38489-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 271552979A0 for ; Thu, 25 Jan 2024 11:16:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2912E51038; Thu, 25 Jan 2024 11:11:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RkoI9W8M" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) (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 F01DF51C20; Thu, 25 Jan 2024 11:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.88 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181075; cv=none; b=ftXSwv2feydq3QG2go/H/0QdeDi/bhxTgMjxRRm26unpin85tr8zmxlKmRaMFuOZ/848pn1kL4XLGYPAiRwi2FvK918Tpo/ICzcaDHHaCpIDDg3m+1RZApKjY+27y/4gd8tgpnma06UJs3RyzeM7eujWTwlEx9LZkLbU98Wq0Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181075; c=relaxed/simple; bh=33NHf8hKMsj/l+cEJaT9H1sPZXBn7CyH0lKsCXmRwnY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XBiiepnmm8KvuzurBWcvCORJyf63cyDSGj/YXT9o5dAgGxsCqLLAdkRshTuAeyJnsOX2kqWxxAZFX+CVWdNGt52nnDsH45GsWniAGQadAl8sg3T9p2PVffFiooJOgNMa8lzjEgMB1+lvvvH0oa4eKs5JhkNktuVJeFxClnKEceA= 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=RkoI9W8M; arc=none smtp.client-ip=192.55.52.88 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=1706181074; x=1737717074; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=33NHf8hKMsj/l+cEJaT9H1sPZXBn7CyH0lKsCXmRwnY=; b=RkoI9W8Mz63QrjvG0brad1lZBbN6GfOeMDx/c0mMn40K0aeDT6FPfhKX BNkMAuK86Rp76B6PSrKSQ+ABUrblXjHHsOQGUZM0FtXKtO6CGXt4QJH5Q yCNflk1ywWurGCDcQUdxWZXUxZobJhQOmBlKuF9ohSx3mqVFrbkH0C4MO 7lPg8bO0X88L0pwfHr3AkSXVFrCyf9E+DuHf9ItRkStgYRzbLPxlQbgI6 bLF+Be1HV3wvEOt+Ds04jRuFs6vPuQBhA6IWh9BTMxCj4gI1vJm4NbzA+ HzN14ptn+VOj9tnPPf+Xy5kN6eoGpKPUJOumnWPjhtJawvvUDUb267wym Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="433286699" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="433286699" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:11:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="736286620" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="736286620" Received: from apejovix-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.0.239]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:11:10 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, fenghua.yu@intel.com, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v3 2/5] selftests/resctrl: Add helpers for the non-contiguous test Date: Thu, 25 Jan 2024 12:10:55 +0100 Message-ID: <85b1efc3ddd698b3ac81aa72a6dc987ee17da3e2.1706180726.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: 1789060956817691602 X-GMAIL-MSGID: 1789060956817691602 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 a file in /sys/fs/resctrl/info//. Signed-off-by: Maciej Wieczor-Retman --- 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 | 39 +++++++++++++++++++++ 2 files changed, 40 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..cb5147c5f9a9 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -249,6 +249,45 @@ static int get_bit_mask(const char *filename, unsigned long *mask) return 0; } +/* + * resource_info_unsigned_get - Read an unsigned value from a file in + * /sys/fs/resctrl/info/RESOURCE/FILENAME + * @resource: Resource name that matches directory names in + * /sys/fs/resctrl/info + * @filename: Filename of a file located in a directory specified with the + * 'resource' variable. + * @val: Variable where the read value is saved on success. + * + * Return: = 0 on success, < 0 on failure. On success the read value is saved into the 'val' + * variable. + */ +int resource_info_unsigned_get(const char *resource, const char *filename, + unsigned int *val) +{ + char reason[128], 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) { + snprintf(reason, sizeof(reason), "Error in opening %s file\n", filename); + ksft_perror(reason); + return -1; + } + + if (fscanf(fp, "%u", val) <= 0) { + snprintf(reason, sizeof(reason), "Could not get %s's contents\n", filename); + ksft_perror(reason); + 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 Thu Jan 25 11:12:11 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: 192002 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1565161dyi; Thu, 25 Jan 2024 03:17:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnnXB4NvU64ge0ABbgVEDBVMC628B6ZXiUMih8AbCpdFeD5V9P33Ui9ip4apsJZsoX+nx8 X-Received: by 2002:ac8:58c2:0:b0:42a:7031:bcd3 with SMTP id u2-20020ac858c2000000b0042a7031bcd3mr130193qta.126.1706181423517; Thu, 25 Jan 2024 03:17:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706181423; cv=pass; d=google.com; s=arc-20160816; b=b1+kyU2gpH7Y/fwR2BKZQ+rw8msEgFL3VkkPy33oD6jq0p/ASfbWJ52gOya2Fm+JlV AzdJ/02fGk0Ez99AYxay8MDuj/t9/k5dfU5lq2FkgZAH5rCkrLK8Ee63/3d9fwT8KYZs MWU28BPTNN0EP+XBBVWR56QMqX7v26K1LjIVB7pNEE4E1JKBbdwd1XQACFvJciMxLuUl qEmelXTfEkR8mbZ/F5hQ9Fy9Wi5GEMtif27hhNjYfqJpispAQTXVeCN2gmxFwlH4cT1z 4daw4Iv5aafDj/S1c+FuACknxFLs67+vYcl3wEXD2MYGbWff6FkPuaoSW6GlPcKBsdmw kLIw== 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=duCRkc/8geq2Jojg2u7IS5ikBKfLu7ktpgtjsACU0GM=; fh=eNkS6XcMxBX7jqqaCWKBjHPfznBhZVo4Re/mvAqqtp8=; b=VHjl0J8W46ibdLZfLbKgdOrEnSe+u5bU74sZnTw3ZzJ3oaEITHNRsnuNukxa0Q2e3g VJdscphgl7FPptKqOQeFy95n2NmexZNxgUecy2CpA6/AtoWeoxP7UaQwExiPZUWK1BHg 8gR7Uj+qAqQg+qdS0Bf2na9KcBD5Pi3axbmkHj0yrzO7hrxZhUn+TH3XGKnfyklSiLFd /0xm9U2tpq1N4Ks3PiNGcZkfwdIQHPyB1PwsD37dostrUI37WYEL3MHJe8k4wWZeSVkO wq/aKFwIY5MG4sToBEPkhjupPSldnlbfkL/ur/JZ2Tj87lYmlXhXXlEWCGCS6sHzvkA/ 5j3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="bLO/kufr"; 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-38490-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38490-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 h18-20020ac85852000000b0042a58895038si4586765qth.267.2024.01.25.03.17.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:17:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38490-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="bLO/kufr"; 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-38490-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38490-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 431001C20DDC for ; Thu, 25 Jan 2024 11:17:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B3D25465E; Thu, 25 Jan 2024 11:12:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bLO/kufr" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) (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 647EE45949; Thu, 25 Jan 2024 11:12:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=134.134.136.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181155; cv=none; b=JPem8cLQ3v2gfqw88c2pnYwI7N5uQf7UY1VWF4QtE130bciZoWt2fOCVu7+zKOsJ7wK+xC8n2V6SEx8BG3TgvWJ64lhwKD7YcpxLP8mttJDzMAl3AdR5O/ij9v7DP3asf5CdIGSIX6Dh0gQBV5OdbyVbFAUq6gZSlzr7VTQ8Lu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181155; c=relaxed/simple; bh=kZQi7qRqgWMe3fx6XtYYh/qZ7SHVk5oDrPpzUONn+7g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jqiR6cQ4LJT9KY8UBvLl7P4rPPKVVU7eDaUXBTI5/nwwe+j1OCd0dYR0lt+aYctSLApznIvlhUaLcGKDzgrqFKjFxlcONeW9RhTiNahpkbJ+Wo2Ww8zDE5Ec8aAnelH+VYKqGujeiDRHcggZsl0x0jtw3kPmbakRMt1LIwqgAuI= 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=bLO/kufr; arc=none smtp.client-ip=134.134.136.65 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=1706181153; x=1737717153; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kZQi7qRqgWMe3fx6XtYYh/qZ7SHVk5oDrPpzUONn+7g=; b=bLO/kufrVAXPe7mC9x2hHXAr9nCuFqRWNyGd1ElrTixS19LxUpZ8ZFIT mjzRtvkAPFWt49cIOjaF7DkgK+u/oYzaW4X8r9ETekpED7eTICsL5GB/M tjmqDsl+muWDn/V0/4rvqZ6BxjOTa/mnI2HNura5ut0X9kex4Ch0a31uX TuUot7++GDJNn1CMGnaeHivi3JlFxx9H1t17mSgpopoPFhiFjg1uiW9/u O3o+tszkeCEemSjKQINm3YH+2zuxlQjb6NrZ49SKWhLyymQ4xIxpYoo12 E/v2hyqzC3Xneb1WIDPllxFhw9BGJVyOREqLsUQWBcn4dOIIZpyxng4SM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="405881002" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="405881002" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:12:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="877017521" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="877017521" Received: from apejovix-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.0.239]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:12:29 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, shuah@kernel.org, fenghua.yu@intel.com Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v3 3/5] selftests/resctrl: Split validate_resctrl_feature_request() Date: Thu, 25 Jan 2024 12:12:11 +0100 Message-ID: <415cc65c113143c833ca2eaacd3a03c285c2e841.1706180726.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: 1789060892039794080 X-GMAIL-MSGID: 1789060892039794080 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/L3_MON/mon_features file. Signed-off-by: Maciej Wieczor-Retman --- 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 | 4 +-- tools/testing/selftests/resctrl/mba_test.c | 4 +-- tools/testing/selftests/resctrl/mbm_test.c | 6 ++-- tools/testing/selftests/resctrl/resctrl.h | 3 +- tools/testing/selftests/resctrl/resctrlfs.c | 33 +++++++++++++-------- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index dd5ca343c469..428de9df81c8 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -169,8 +169,8 @@ 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"); + return resctrl_mon_feature_exists("llc_occupancy") && + resctrl_resource_exists("L3"); } 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..e22285b80e37 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -170,8 +170,8 @@ 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"); + return resctrl_resource_exists(test->resource) && + resctrl_mon_feature_exists("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..9c885bc427ca 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("mbm_total_bytes") && + resctrl_mon_feature_exists("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..4603b215b97e 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -136,7 +136,8 @@ 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 *feature); bool test_resource_feature_check(const struct resctrl_test *test); char *fgrep(FILE *inf, const char *str); int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index cb5147c5f9a9..e4ba8614fb7b 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -711,20 +711,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) @@ -739,11 +735,24 @@ 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 L3_MON feature 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 *feature) +{ + 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"); + inf = fopen("/sys/fs/resctrl/info/L3_MON/mon_features", "r"); if (!inf) return false; @@ -756,7 +765,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 Thu Jan 25 11:12:44 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: 192036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1576562dyi; Thu, 25 Jan 2024 03:41:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtFefT9eGwCBx/lh/tz9ZnYGPNGmPJA8+2tWhQ852x38E5bVdk+Bo5B3odd2fAciQECn0x X-Received: by 2002:a17:902:aa4b:b0:1d6:f493:b219 with SMTP id c11-20020a170902aa4b00b001d6f493b219mr633778plr.137.1706182900959; Thu, 25 Jan 2024 03:41:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706182900; cv=pass; d=google.com; s=arc-20160816; b=pPYesp4jo/OIA0fNmWBaS62Br1iPPUFlLkW0GKIpCpuf3YL3OPSBnguWX1WqROu43e 9NJ9eXxXDkjVtBG8B1rvfZzi4B7CfWCXh1zdsl3m3nyteVKSEsTytBYwEJb03oFUiosJ yvoZ//Gb4ewlyXTNfdVFPZwV4UgYDLO67Coip75ceMMsRhipYsbsY6A1maR1isy6zock pcdx0cGh5bfoiko6xSb0xvVZfn3XV7A5IYf4f+KN2wa9q3KOCqw1Y5ql4vXUxJ4ICaNv g+tfgcxixbrlUSUlm3ASoleATzHcXwcZxSrSwAnWavwKzn4QKcrimDTyYfk0siebETW3 /qKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kR3kO8rJeyaYG7Bvs9hNyBFZpFeLxQ/gPa47a4FsZYk=; fh=eNkS6XcMxBX7jqqaCWKBjHPfznBhZVo4Re/mvAqqtp8=; b=hXkCuIS24QwZ4gDIN/Ma4laDTyNtw/xKaxmww6x4Ur68SMxFZUclI5NF/1gFuuz78d vkjr/fLwxx+tP3LQ9Usu2GCAGCzMD50ngDiZYTzMru5zVJi8rnzeA6Wy5EWqQ7vFK4SX dKIAKB49t8bSbVFlqpwXFNhEEcTID7t7r5eW9XTnyWH224RDjhrd8AwUoeuVPGAK4Npc 3TALLw6VFlkRc1Kepzio0Ezb7gcDRgKPMjMU9Th/89T1DZeOCQcEk/6Qe7Zbl/Y6kPUj vnCHZvkYybERSih4TSZkXo8d5ePoaG6B2Rr7RlVlDPC8dO1qGTKf3AVh26VaOAwcNvqr Uh0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vn3NfZf4; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-38491-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38491-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h15-20020a170902680f00b001d3f1b7685esi12986575plk.547.2024.01.25.03.41.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:41:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38491-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vn3NfZf4; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-38491-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38491-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 4CADFB31A27 for ; Thu, 25 Jan 2024 11:17:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 952EB54BE5; Thu, 25 Jan 2024 11:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Vn3NfZf4" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8594A54BC0; Thu, 25 Jan 2024 11:13:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.120 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181182; cv=none; b=f5crJA5wJ+oiw+v6c5SImW3VCI0WpjswrEKT6j5BR5GFi89NAhHN/cdcgiNvxk2ZPbHknJYzKna1DcH0YFgjkDFlF4oc09GLawMhLWaeXasUveoB4OiYUuI/OuaxqTN0ioNv7WP9vayTC9O+dAnEnd9thm9MmOXVi26hlWzLp8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181182; c=relaxed/simple; bh=SxRU7/I2LYttjmLWpA1g2TAp7MIA5p+HKBajTxhEzJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lGBifd8nUus7qBZDhAxIQAPd5cxSG8HQreIQtbZtEnwt9ad7zY9IfUyXcJ0WIi4ninAcxzqjN21sGBusbnp4jpElowbWwmE9JOa/5wxrBFaLJpm0ovC2B+KosgMohuZAi84MQJF+Wl8LqaFmerIrSYXXAMAYjP+nZAlQoQUKP10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Vn3NfZf4; arc=none smtp.client-ip=192.55.52.120 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706181180; x=1737717180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SxRU7/I2LYttjmLWpA1g2TAp7MIA5p+HKBajTxhEzJs=; b=Vn3NfZf4itAM/jGnV5273rCZEb6G7jXlC2qR69Zwp8dd8LChKxkgVvom fIhwPdquFkGsTE0PFmFhe0U1LqNi2kfwU35kiQwymmWmROrnEJ8Oiw4ZA fLMzVflcPYFCwSy9bSM8T96wWbAxOCm4+4v1tc/apYmLZAj213X6WncrH dszCTcMD2gAfH/NMKC5P3JU7fgCdTNQ9m5kiSUBAiVoexXX8oWJlrjsIk JZY/wlTjAmZAnsj4EwICtkgw5Nogu/6KgUyTnGm+Ygf4+ggM6KkQkFxhM mXhjYGUykNnYBZzc9P8nlA5t/KAFc9kDzIFmfefn+rEWXlrSpPhpml3aZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="400987627" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="400987627" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:12:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="909968606" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="909968606" Received: from apejovix-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.0.239]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 03:12:57 -0800 From: Maciej Wieczor-Retman To: reinette.chatre@intel.com, shuah@kernel.org, fenghua.yu@intel.com Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v3 4/5] selftests/resctrl: Add resource_info_file_exists() Date: Thu, 25 Jan 2024 12:12:44 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789062441767741061 X-GMAIL-MSGID: 1789062441767741061 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 v3: - Split off the new function into this patch. (Reinette) Changelog v2: - Add this patch. tools/testing/selftests/resctrl/resctrl.h | 2 ++ tools/testing/selftests/resctrl/resctrlfs.c | 26 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 4603b215b97e..c39105f46da9 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -138,6 +138,8 @@ int umount_resctrlfs(void); int validate_bw_report_request(char *bw_report); bool resctrl_resource_exists(const char *resource); bool resctrl_mon_feature_exists(const char *feature); +bool resource_info_file_exists(const char *resource, + const char *feature); bool test_resource_feature_check(const struct resctrl_test *test); char *fgrep(FILE *inf, const char *str); int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index e4ba8614fb7b..a6427732e0ad 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -763,6 +763,32 @@ bool resctrl_mon_feature_exists(const char *feature) return !!res; } +/* + * resource_info_file_exists - Check if a file is present inside + * /sys/fs/resctrl/info/RESOURCE. + * @resource: Required resource (Eg: MB, L3, L2, etc.) + * @feature: Required feature. + * + * Return: True if the file exists, else false. + */ +bool resource_info_file_exists(const char *resource, + const char *feature) +{ + char res_path[PATH_MAX]; + struct stat statbuf; + + if (!feature || !resource) + return false; + + snprintf(res_path, sizeof(res_path), "%s/%s/%s", INFO_PATH, resource, + feature); + + if (stat(res_path, &statbuf)) + return false; + + return true; +} + bool test_resource_feature_check(const struct resctrl_test *test) { return resctrl_resource_exists(test->resource); From patchwork Thu Jan 25 11:13:16 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: 192003 Return-Path: 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 (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 ; 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 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: 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: 1789060921622724275 X-GMAIL-MSGID: 1789060921622724275 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 --- 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; + } + + /* 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)