Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2142307rdb; Mon, 20 Nov 2023 03:19:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxmeu0BxQQIUrR+GAgW7nQY3sfhT8J8hgLkQYV4SmK/z9XXdTc01UCrT8VfwfcDZZLdbPE X-Received: by 2002:a05:6870:9e92:b0:1f9:4da7:921c with SMTP id pu18-20020a0568709e9200b001f94da7921cmr1015505oab.9.1700479149279; Mon, 20 Nov 2023 03:19:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700479149; cv=none; d=google.com; s=arc-20160816; b=zDQ0WMaLAsVhlvtd1CJBtp9K9imkRDBnC3J33V+yfP5jfjobYu+/+0EeMUcZtlH/WM qyEEFl573JK88s1UrSZdU1ASzxg1D5A24ew777p6hT1i9qNXBeuWwcIQJvDv3DW3ErW+ yHqyby8M8tD5qT1QBkwKJDIBjvV/W4gs0VoVSBM2wkgQxgLOKQfeN6X62MpLVqCsI+r5 +fYJPfShzcNPXCMW4vtz0Bnyz3wXIJa4VRFEkabg9QQTfrh2/VShQgg4zfwrgBp5Qp9d VE1NY88BEkiqS8ugfWPgwnuqNd5Fl/Xzp8NRl3FXPQFdH6jBn81mS2XUwfC90zz0C2i9 EuBQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e9w+tZXinzVLvKxusdamg22h2wP/nVaLIg1ivC3dJeQ=; fh=gPQ6jqLSfsDb5bE3yrtO+AlT5R4d75RXkjC5xckz7Dk=; b=hcYT4Sqe7sGdsA27MnqFD83shw9DXSGfS3RpWoa3e+Tag+uI4lA69fOYQp4t/TA34A fSFPj6JWyOF4lPeMEESWhPGotnD675kuEyXBdQWjrjPyOubmZNrlWTzur8p5ZPXFsc0B MkhsRs8Gd2xYGR9QuZFGzO7kftoRUX4ZVUiYhFYFyACh1Ufu8bO6McrB7T05ui1/DLm8 grJmdmvmRmn646/2w4bEGAroC5rs3OcxtzO1Vqdalp9VG2zn3QYlXFX7eij+8MN0d3xm 3Z9RbtfI+HvsANYX03M2TprDUa9CqZURZ1QxPqdpuL+clZxcNJ05Q07TXP7WvDBRhZED /sag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OzNnbW3A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id fd39-20020a056a002ea700b00691019fd0efsi7943899pfb.75.2023.11.20.03.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:19:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OzNnbW3A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id A42E7805F9D4; Mon, 20 Nov 2023 03:16:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232775AbjKTLQM (ORCPT + 99 others); Mon, 20 Nov 2023 06:16:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233431AbjKTLPl (ORCPT ); Mon, 20 Nov 2023 06:15:41 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3DCF1AD; Mon, 20 Nov 2023 03:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700478935; x=1732014935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tVN/FhwY6NyA0nXfkYCvWVI9YZaBRRB4ulMKfSyM56g=; b=OzNnbW3A7f78BjWGZgZmIXVoA/ZyE7nlZUPNaBjmd8+t2VdwOAUxKK1M 5ienRbiL+U2BSC6uHrB7kQmz7mnZes+heRPmXWShg7poNOOhYFeeoUxMq ZQWdGg0OlD8Abywsc+vOtbFiYArILck9PXIdxLiLUEbUfbp9FYFhDgW3V AUKfxFq10Xjqbsm9RGzjlPy+pkA+F53VdyL/E6UVpHHAMLbZIQMOVHLk7 4E+2iiTYCFk3YPLGdnLDO4/gEVYM0esWQuaMEFKZ2pz8Hf4wPuod60CrB aGHIYtxCLghWFFww3OqE8gt/MT9x6yFMvM1Jfp2PvokRJf4akYndhEQnt Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="13151924" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="13151924" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:15:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="832238252" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="832238252" Received: from sc9itsct4906.amr.corp.intel.com (HELO localhost) ([10.249.46.107]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:15:30 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= , Fenghua Yu Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 12/26] selftests/resctrl: Consolidate naming of perf event related things Date: Mon, 20 Nov 2023 13:13:26 +0200 Message-Id: <20231120111340.7805-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231120111340.7805-1-ilpo.jarvinen@linux.intel.com> References: <20231120111340.7805-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 03:16:18 -0800 (PST) Naming for perf event related functions, types, and variables is currently inconsistent. Make struct read_format and all functions related to perf events start with "perf_". Adjust variable names towards the same direction but use shorter names for variables where appropriate (pe prefix). Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 42 ++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index aea4f54d32bd..52d37d1c380f 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -3,7 +3,7 @@ #include #include "resctrl.h" -struct read_format { +struct perf_event_read { __u64 nr; /* The number of events */ struct { __u64 value; /* The value of the event */ @@ -11,11 +11,11 @@ struct read_format { }; static struct perf_event_attr pea_llc_miss; -static struct read_format rf_cqm; -static int fd_lm; +static struct perf_event_read pe_read; +static int pe_fd; char llc_occup_path[1024]; -static void initialize_perf_event_attr(void) +static void perf_event_attr_initialize(void) { pea_llc_miss.type = PERF_TYPE_HARDWARE; pea_llc_miss.size = sizeof(struct perf_event_attr); @@ -30,34 +30,34 @@ static void initialize_perf_event_attr(void) } /* Start counters to log values */ -static void ioctl_perf_event_ioc_reset_enable(void) +static void perf_event_reset_enable(void) { - ioctl(fd_lm, PERF_EVENT_IOC_RESET, 0); - ioctl(fd_lm, PERF_EVENT_IOC_ENABLE, 0); + ioctl(pe_fd, PERF_EVENT_IOC_RESET, 0); + ioctl(pe_fd, PERF_EVENT_IOC_ENABLE, 0); } -static void initialize_llc_perf(void) +static void perf_event_initialize(void) { memset(&pea_llc_miss, 0, sizeof(struct perf_event_attr)); - memset(&rf_cqm, 0, sizeof(struct read_format)); + memset(&pe_read, 0, sizeof(struct perf_event_read)); /* Initialize perf_event_attr structures for HW_CACHE_MISSES */ - initialize_perf_event_attr(); + perf_event_attr_initialize(); pea_llc_miss.config = PERF_COUNT_HW_CACHE_MISSES; - rf_cqm.nr = 1; + pe_read.nr = 1; } -static int reset_enable_llc_perf(pid_t pid, int cpu_no) +static int perf_open(pid_t pid, int cpu_no) { - fd_lm = perf_event_open(&pea_llc_miss, pid, cpu_no, -1, PERF_FLAG_FD_CLOEXEC); - if (fd_lm == -1) { + pe_fd = perf_event_open(&pea_llc_miss, pid, cpu_no, -1, PERF_FLAG_FD_CLOEXEC); + if (pe_fd == -1) { perror("Error opening leader"); return -1; } - ioctl_perf_event_ioc_reset_enable(); + perf_event_reset_enable(); return 0; } @@ -141,15 +141,15 @@ static int perf_event_measure(const char *filename, int bm_pid) int ret; /* Stop counters after one span to get miss rate */ - ioctl(fd_lm, PERF_EVENT_IOC_DISABLE, 0); + ioctl(pe_fd, PERF_EVENT_IOC_DISABLE, 0); - ret = read(fd_lm, &rf_cqm, sizeof(struct read_format)); + ret = read(pe_fd, &pe_read, sizeof(struct perf_event_read)); if (ret == -1) { perror("Could not get perf value"); return -1; } - return print_results_cache(filename, bm_pid, rf_cqm.values[0].value); + return print_results_cache(filename, bm_pid, pe_read.values[0].value); } /* @@ -205,7 +205,7 @@ int cat_val(struct resctrl_val_param *param, size_t span) if (ret) return ret; - initialize_llc_perf(); + perf_event_initialize(); /* Test runs until the callback setup() tells the test to stop. */ while (1) { @@ -216,7 +216,7 @@ int cat_val(struct resctrl_val_param *param, size_t span) } if (ret < 0) break; - ret = reset_enable_llc_perf(bm_pid, param->cpu_no); + ret = perf_open(bm_pid, param->cpu_no); if (ret) break; @@ -235,7 +235,7 @@ int cat_val(struct resctrl_val_param *param, size_t span) return ret; pe_close: - close(fd_lm); + close(pe_fd); return ret; } -- 2.30.2