From patchwork Mon Dec 11 12:17:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 17844 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7001462vqy; Mon, 11 Dec 2023 04:19:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsI5Lp0ZpBQf2LLIRaY0jzQPKyX3W981xLpUk55fOkFY9pNGpDumUd9Mtsp14fXmrje/QK X-Received: by 2002:a17:902:650c:b0:1d2:f458:b9e with SMTP id b12-20020a170902650c00b001d2f4580b9emr1555183plk.135.1702297142723; Mon, 11 Dec 2023 04:19:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702297142; cv=none; d=google.com; s=arc-20160816; b=t4A/SuzXzy5Z6aKqFhf78Unx3FbW1WEX12I71whrvmTajxj/dTSv9TZOTftf93fikN ybMMzsuuHH+VY/072sdYFKDCS6Qa2JWlXysEbw8TNq7Wz/r+Dd4TjhrHmn4mdLpzMiN8 fzGoTHMLmBEX0aqKrs80KZbV7mmeXMQuhRpZoxf9zX02sdUhSDA91WaCmRJrhwajATVu wjZXS/auCwBh3bpKNJCbEqRSIABgiimmIqzKxktPWvp30X1Eqnjk1vX1kVgejAjRut2P /TUj1fEpNMBQ3exCkiqBgksSvJvbvXI4rfibHKbl9I61AkoBFZEtBDerI+XX278Tlk5D 1pPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=GvSY3aFVyPVXlr/ScDDIZTD0kXtl/45xZ+5V7Hc8Ntw=; fh=gPQ6jqLSfsDb5bE3yrtO+AlT5R4d75RXkjC5xckz7Dk=; b=rW3tpkbq1lsmljKFiaoKJ5bRbz/7u97/2TBjZsV0xnb2hG9FrsKUwL7LE78osZ9d4K 9xVd+WbYrRYrpzKvsi+xzWyERPa5FaOSQYkV06RftWnLt+EC/XGXBFRP/AF9lmGdUv7Q YQ70kMBFtwv2FsBE6xWm8V4XVnN0sNvBluzl5jeiUHoccTU564z2DjhTvlkCas7VPshl LR7u7h7QMkDMyOjj8G0JC8wMuZ3qG5Ysm9BwxdbuIsH/DzOzH1mcRL1V1t8A1GYhA9jL gkvGJAjhX3FAhbvEVHKDRjNS7u9YeQ64Mmv+jx3epm5J7Evn/iv3kH+gaEUp9swhffcW 4vqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C+QQp+fU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id y18-20020a170902b49200b001d07d6916fesi5956602plr.88.2023.12.11.04.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 04:19:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C+QQp+fU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6C6FC809580A; Mon, 11 Dec 2023 04:18:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234861AbjLKMSh (ORCPT + 99 others); Mon, 11 Dec 2023 07:18:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234333AbjLKMSf (ORCPT ); Mon, 11 Dec 2023 07:18:35 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0D66CD; Mon, 11 Dec 2023 04:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702297122; x=1733833122; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=WoCyP7/eVs07Uaxg+Z6bbeKyFt0c/ppUNHZy+vX7I+w=; b=C+QQp+fU30b9FokY+LYJkgJC2H6H7f7aaGMnn3YGozetZ14f7P8JiZIA RSz6DQuzKqF2LIssYpo5+GhBmjrt5jR0r4vNYsswltkgoKPHnG3ed3QnE /IJ6Xxb3D7pJYicWtOejJpoMF8wgpWiznuhDKDLvc22dg/v0MUAVGzpCA mear1ywTP3/YENWvRR0Jd5Becy21+uYO1sshKmTQvs/EPMhEbI7RYb4T3 pqfLPvU4cyQqzUDzO+8uBXLZGpIRiTpEhXlSuI0QGyAbOEMnaKKWImTVV cmpy9332D0QN2cZkrTuVSnQe2IQALRBRo4m0vTYgoeRwhoETOjEAuAWfT g==; X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="7992227" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="7992227" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 04:18:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10920"; a="916826074" X-IronPort-AV: E=Sophos;i="6.04,267,1695711600"; d="scan'208";a="916826074" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.246.50.188]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 04:18:38 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , =?utf-8?q?Maciej_Wiecz=C3=B3r-R?= =?utf-8?q?etman?= , Fenghua Yu Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v3 00/29] selftests/resctrl: CAT test improvements & generalized test framework Date: Mon, 11 Dec 2023 14:17:57 +0200 Message-Id: <20231211121826.14392-1-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 04:18:55 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784987928687072417 X-GMAIL-MSGID: 1784987928687072417 Hi all, Here's v3 series to improve resctrl selftests with generalized test framework and rewritten CAT test. As agreed, v3 does not include the group naming patch which will become part of Maciej's non-contiguous serie. The error handling cleanups (return errno, perror() & return value comment cleanups) and CPU affinity restore for CAT test add to the patch count. The series contains following improvements: - Excludes shareable bits from CAT test allocation to avoid interference - Replaces file "sink" with a volatile variable - Alters read pattern to defeat HW prefetcher optimizations - Rewrites CAT test to make the CAT test reliable and truly measure if CAT is working or not - Introduces generalized test framework making easier to add new tests - Lots of other cleanups & refactoring This serie have been tested across a large number of systems from different generations. v3: - New patches to handle return errno, perror() and return value comments - Tweak changelogs - Moved error printout removal to other patch - Zero bit CBM returns error - Tweak comments - Make get_shareable_mask() static - Return directly without storing result into ret variable first - llc -> LLC - Altered changelog and removed "the whole time" wording because llc occu results are still unsigned long - Altered changelog's wording to not say "a volatile pointer" - Make min_diff_percent and MIN_DIFF_PERCENT_PER_BIT unsigned long - Add patch to restore CPU affinity after CAT test - Move uparams clear into init function - Add CPU vendor ID bitmask comment - Use test_resource_feature_check(test) in CMT - "feature" -> "resource" in function comment v2: - Postpone adding L2 CAT test as more investigations are necessary - Add patch to remove ctrlc_handler() from wrong place - Improvements to changelogs - Function comments improvements & comment cleanups - Move some parts of the changes into more logical patch - If checks: buf == NULL -> !buf - Variable naming: - p -> buf - cbm_mask_path -> cbm_path - Function naming: - get_cbm_mask() -> get_full_cbm() - cache_size() -> cache_portion_size() - Use PATH_MAX - Improved cache_portion_size() parameter names - int count -> unsigned int - Pass filename to measurement taking functions instead of resctrl_val_param - !lines ? : reversal - Removed bogus static from function local variable - Open perf fd only once, reset & enable in the innermost test loop - Add perf fd ioctl() error handling - Add patch to change compiler optimization prevention "sink" from file to volatile variable - Remove cpu_no and resource (the latter was added in v1) members from resctrl_val_param (pass uparams and test where those are needed) - Removed ARRAY_SIZE() macro - Add patch to rename "resource_id" to "domain_id" Ilpo Järvinen (29): selftests/resctrl: Convert perror() to ksft_perror() or ksft_print_msg() selftests/resctrl: Return -1 instead of errno on error selftests/resctrl: Don't use ctrlc_handler() outside signal handling selftests/resctrl: Change function comments to say < 0 on error selftests/resctrl: Split fill_buf to allow tests finer-grained control selftests/resctrl: Refactor fill_buf functions selftests/resctrl: Refactor get_cbm_mask() and rename to get_full_cbm() selftests/resctrl: Mark get_cache_size() cache_type const selftests/resctrl: Create cache_portion_size() helper selftests/resctrl: Exclude shareable bits from schemata in CAT test selftests/resctrl: Split measure_cache_vals() selftests/resctrl: Split show_cache_info() to test specific and generic parts selftests/resctrl: Remove unnecessary __u64 -> unsigned long conversion selftests/resctrl: Remove nested calls in perf event handling selftests/resctrl: Consolidate naming of perf event related things selftests/resctrl: Improve perf init selftests/resctrl: Convert perf related globals to locals selftests/resctrl: Move cat_val() to cat_test.c and rename to cat_test() selftests/resctrl: Open perf fd before start & add error handling selftests/resctrl: Replace file write with volatile variable selftests/resctrl: Read in less obvious order to defeat prefetch optimizations selftests/resctrl: Rewrite Cache Allocation Technology (CAT) test selftests/resctrl: Restore the CPU affinity after CAT test selftests/resctrl: Create struct for input parameters selftests/resctrl: Introduce generalized test framework selftests/resctrl: Pass write_schemata() resource instead of test name selftests/resctrl: Add helper to convert L2/3 to integer selftests/resctrl: Rename resource ID to domain ID selftests/resctrl: Get domain id from cache id tools/testing/selftests/resctrl/cache.c | 287 +++++---------- tools/testing/selftests/resctrl/cat_test.c | 337 +++++++++++------- tools/testing/selftests/resctrl/cmt_test.c | 80 +++-- tools/testing/selftests/resctrl/fill_buf.c | 132 ++++--- tools/testing/selftests/resctrl/mba_test.c | 30 +- tools/testing/selftests/resctrl/mbm_test.c | 32 +- tools/testing/selftests/resctrl/resctrl.h | 126 +++++-- .../testing/selftests/resctrl/resctrl_tests.c | 197 ++++------ tools/testing/selftests/resctrl/resctrl_val.c | 138 +++---- tools/testing/selftests/resctrl/resctrlfs.c | 321 +++++++++++------ 10 files changed, 936 insertions(+), 744 deletions(-)