Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2374596lqo; Mon, 13 May 2024 17:14:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1Dh/a8IUpMS5D94/QfwseGUhJyX60z9TCOHuR815uHP8DbtD2S6VrpEdySIe7wsD+2lGDu3UtQME+j9cONxee8oyc+gefNVMESPuPxA== X-Google-Smtp-Source: AGHT+IFvsDCUWJYvSI8uHfJIxFi1bvEqQ5xyPJzb2UfQvteklKiqK3K3+LYKD8ZUvR2O8/xZKbQ/ X-Received: by 2002:a2e:be84:0:b0:2df:6cb8:c911 with SMTP id 38308e7fff4ca-2e51ff5e437mr85004611fa.24.1715645690656; Mon, 13 May 2024 17:14:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715645690; cv=pass; d=google.com; s=arc-20160816; b=bs2XfKd+3EZHU9h/vw2RiVYtFbQNkgyT+82HOUslFqVJuZhDPNj38r+FKnTu3xe6/5 Qp9woIHEkPHa0ylxy5hzH8yiiAyEcZENNFJDy6/6LixCl6Z0P+Pc4DTyA5/5NoficKf5 /TvW+iNUD5TwZdixJY87C7sdTQ736nWkLmsGpmSJeGPzqoB5RE6DwuRmgZIWgE/dO3PG Dh3cp224uHQFMBwq13LpWhei1RjGXy+kFvXalJxE4yLY3nas4gdkZ1vtYTsrqK9KI4jI iadlQ2P1w/lu9LUVS++e+2jwLpFQlKfCpTEipZzYBoIWhE0YmPOq0soCvICRL6O7LHZa Xpsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=3ibaSSKUEQIFW2f5/BFmJXtUec1nP88z8Ady4qrNXWk=; fh=I5QF3XibTKG9JrR71P5/cfYKImlQMj9GVWvb3Q9bJkI=; b=HGhal0JMNNk+ctmUHd8Y/ZBXInMkWgbirAF3abGoL9bGQB/Ln6Z2JkkCfM7gmxqT4M RwdTl8rS3KguC92Fw5mRFB5Ec+a6OWP6BhyM9Jy3ETAK5YyRoPi5iGNghhA/c9KSD31M GjH4egeKj4hyDQPrslR/Ce5mXV2KwXZR8CSTJzzHnKb15qtYxzJ55SHLZlCQiGEFQ8cW DfSmqNYWPvS1aAlOoHDZsVLz0Jiu7RekP6PHXCkwJQKWzYWvpJgnq2Qf+ySKsBVOBQS3 pzIX0PImwN52xjf3gzsltcu23lFSnW/BCeY32mhrmYBGnZwuq3CtOsEYG6ya7+2rbyng MHxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="E/vqW6+Y"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-178203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-574bd40f1f7si2456705a12.443.2024.05.13.17.14.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 17:14:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="E/vqW6+Y"; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-178203-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 37D111F23DCD for ; Tue, 14 May 2024 00:14:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 079FF17EF; Tue, 14 May 2024 00:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="E/vqW6+Y" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9571A1878 for ; Tue, 14 May 2024 00:14:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715645671; cv=none; b=NwgHKRonGG7WtkH9nssg+Z+/jY9c2gzhnCdxWydpARTwzCkwA9bTYYiMQNZIizmW4hT/fcK60n0wz2GzCEisNcrI7jrgdkdcaXv36AJF4SRGOiIClMj46zqChtcd5cXK+9ZznWhwAEYaGemR34+YgMNf5/wZfSN3yk2WTnbEok8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715645671; c=relaxed/simple; bh=SBrw0mlZryE7xylBjlOJomhP4bSWNQippGud3TNQfaY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=hKF1P+fF/oMsNpDKjb+sX8fLkCbwgZWGlAmXizFTryghZSnIDDBshzhU9A4JaLkCZyXfumF7VEBXyOph7MAvETgjuL6mOeNk9mV+cLhHvE1d1Zm1lFVKk9zoY2/E0b0ELMlNm84lcoyg+Dc/Pg2l0JJZkKxy5aTzTo/brUMEr2Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=E/vqW6+Y; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-61bed763956so93988657b3.3 for ; Mon, 13 May 2024 17:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715645668; x=1716250468; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=3ibaSSKUEQIFW2f5/BFmJXtUec1nP88z8Ady4qrNXWk=; b=E/vqW6+Y6wXW04rouZNH/c1WmrzFTYqAS6k+dcSGAXATeN6oQtfuwpJYRsQkJwsRQd UZ+cej8JOIUsAr7KAkYBTd+8aM0zHepVoCr2pFGOpCby/O+RZKH+4ltDr3F4U7YaaSxH FjpaxbXDRfjm/SMH+aMf4TneC2Px4SUm/6L7M094TBPmP/cLCKuiQLfYdwTKUixNrueO mnGIppPLODR4WQy+dpDYDrQC8i5A9o+hE31ux0Er1v+bA+uF0de7wm3OgveVCvF5vnhC d16iGfSUntv+tho0jhf4uOPgrlgnYlK0XwwvUX3vc9Iq/LpFp/mN8kEMMMDrlJFO+NGh n/2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715645668; x=1716250468; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3ibaSSKUEQIFW2f5/BFmJXtUec1nP88z8Ady4qrNXWk=; b=e0gw3BGcbfCraCEwELLqqjjAlzk7vzWpNFDfB5pNZ9kRS9Lb35KrUCmE7QBaGM+TA/ 098tdg07pkgMiWo/WFPwZuEYvhdFnEWJwQe9EaFP+NGqgTkAldzBwdGVJ/xBjeiY3/f/ kFTCQFV/Vbvqx6Ssik0GNGP5mpP/h5g+xh/HJDFvDTlavYqnXi6L+nvgGWT5CvyMhnBF 45EdmrLbK5+B3J5R3kG939brr7TwMIoTr8TF+I4zAGDZ0clipkejkxF/thDU7BR7nhdd znFzloN/m6iAKDI1JdhvxVMGiXqwIiStQQQe6SGIMzLYkftiCg6O9KN4AN5l1805py81 djag== X-Forwarded-Encrypted: i=1; AJvYcCUcOdImJ8kheOfC0wl+ERVawERwG3pFQ6l8XS+qCbDoSxg0moLsQcxAL6eKvlL8O3Jd07BK8wUb0FR+wJAXPih77jEr/AV7N9wrHFTA X-Gm-Message-State: AOJu0Yzv5Mp1HtVPD7tc3BGiYUWJhQa2dEgUnvvOK9hDqOqkMGqQ3soH o1hTpmcBk46Pzx8XHn+yMexiE1Qau8UvWJ5ohN60uB6v1sClEjcwnUi+aScI0E4upErGx7XvTKy +YaZcOA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:6e66:3031:b400:2dc8]) (user=irogers job=sendgmr) by 2002:a05:690c:6c87:b0:61b:e15c:2b84 with SMTP id 00721157ae682-622afff942fmr31967487b3.6.1715645668705; Mon, 13 May 2024 17:14:28 -0700 (PDT) Date: Mon, 13 May 2024 17:13:59 -0700 In-Reply-To: <20240514001359.2882951-1-irogers@google.com> Message-Id: <20240514001359.2882951-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240514001359.2882951-1-irogers@google.com> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Subject: [PATCH v4 2/2] perf tests: Add some pmu core functionality tests From: Ian Rogers To: Tuan Phan , Robin Murphy , Thomas Richter , Bhaskara Budiredla , Bharat Bhushan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Ravi Bangoria , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Test behavior of PMU names and comparisons wrt suffixes using Intel uncore_cha, marvell mrvl_ddr_pmu and S390's cpum_cf as examples. Signed-off-by: Ian Rogers --- tools/perf/tests/pmu.c | 99 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c index 06cc0e46cb28..cc88b5920c3e 100644 --- a/tools/perf/tests/pmu.c +++ b/tools/perf/tests/pmu.c @@ -3,6 +3,7 @@ #include "evsel.h" #include "parse-events.h" #include "pmu.h" +#include "pmus.h" #include "tests.h" #include "debug.h" #include "fncache.h" @@ -340,10 +341,108 @@ static int test__pmu_event_names(struct test_suite *test __maybe_unused, return ret; } +static const char * const uncore_chas[] = { + "uncore_cha_0", + "uncore_cha_1", + "uncore_cha_2", + "uncore_cha_3", + "uncore_cha_4", + "uncore_cha_5", + "uncore_cha_6", + "uncore_cha_7", + "uncore_cha_8", + "uncore_cha_9", + "uncore_cha_10", + "uncore_cha_11", + "uncore_cha_12", + "uncore_cha_13", + "uncore_cha_14", + "uncore_cha_15", + "uncore_cha_16", + "uncore_cha_17", + "uncore_cha_18", + "uncore_cha_19", + "uncore_cha_20", + "uncore_cha_21", + "uncore_cha_22", + "uncore_cha_23", + "uncore_cha_24", + "uncore_cha_25", + "uncore_cha_26", + "uncore_cha_27", + "uncore_cha_28", + "uncore_cha_29", + "uncore_cha_30", + "uncore_cha_31", +}; + +static const char * const mrvl_ddrs[] = { + "mrvl_ddr_pmu_87e1b0000000", + "mrvl_ddr_pmu_87e1b1000000", + "mrvl_ddr_pmu_87e1b2000000", + "mrvl_ddr_pmu_87e1b3000000", + "mrvl_ddr_pmu_87e1b4000000", + "mrvl_ddr_pmu_87e1b5000000", + "mrvl_ddr_pmu_87e1b6000000", + "mrvl_ddr_pmu_87e1b7000000", + "mrvl_ddr_pmu_87e1b8000000", + "mrvl_ddr_pmu_87e1b9000000", + "mrvl_ddr_pmu_87e1ba000000", + "mrvl_ddr_pmu_87e1bb000000", + "mrvl_ddr_pmu_87e1bc000000", + "mrvl_ddr_pmu_87e1bd000000", + "mrvl_ddr_pmu_87e1be000000", + "mrvl_ddr_pmu_87e1bf000000", +}; + +static int test__name_len(struct test_suite *test __maybe_unused, int subtest __maybe_unused) +{ + TEST_ASSERT_VAL("cpu", pmu_name_len_no_suffix("cpu") == strlen("cpu")); + TEST_ASSERT_VAL("i915", pmu_name_len_no_suffix("i915") == strlen("i915")); + TEST_ASSERT_VAL("cpum_cf", pmu_name_len_no_suffix("cpum_cf") == strlen("cpum_cf")); + for (size_t i = 0; i < ARRAY_SIZE(uncore_chas); i++) { + TEST_ASSERT_VAL("Strips uncore_cha suffix", + pmu_name_len_no_suffix(uncore_chas[i]) == + strlen("uncore_cha")); + } + for (size_t i = 0; i < ARRAY_SIZE(mrvl_ddrs); i++) { + TEST_ASSERT_VAL("Strips mrvl_ddr_pmu suffix", + pmu_name_len_no_suffix(mrvl_ddrs[i]) == + strlen("mrvl_ddr_pmu")); + } + return TEST_OK; +} + +static int test__name_cmp(struct test_suite *test __maybe_unused, int subtest __maybe_unused) +{ + TEST_ASSERT_EQUAL("cpu", pmu_name_cmp("cpu", "cpu"), 0); + TEST_ASSERT_EQUAL("i915", pmu_name_cmp("i915", "i915"), 0); + TEST_ASSERT_EQUAL("cpum_cf", pmu_name_cmp("cpum_cf", "cpum_cf"), 0); + TEST_ASSERT_VAL("i915", pmu_name_cmp("cpu", "i915") < 0); + TEST_ASSERT_VAL("i915", pmu_name_cmp("i915", "cpu") > 0); + TEST_ASSERT_VAL("cpum_cf", pmu_name_cmp("cpum_cf", "cpum_ce") > 0); + TEST_ASSERT_VAL("cpum_cf", pmu_name_cmp("cpum_cf", "cpum_d0") < 0); + for (size_t i = 1; i < ARRAY_SIZE(uncore_chas); i++) { + TEST_ASSERT_VAL("uncore_cha suffixes ordered lt", + pmu_name_cmp(uncore_chas[i-1], uncore_chas[i]) < 0); + TEST_ASSERT_VAL("uncore_cha suffixes ordered gt", + pmu_name_cmp(uncore_chas[i], uncore_chas[i-1]) > 0); + } + for (size_t i = 1; i < ARRAY_SIZE(mrvl_ddrs); i++) { + TEST_ASSERT_VAL("mrvl_ddr_pmu suffixes ordered lt", + pmu_name_cmp(mrvl_ddrs[i-1], mrvl_ddrs[i]) < 0); + TEST_ASSERT_VAL("mrvl_ddr_pmu suffixes ordered gt", + pmu_name_cmp(mrvl_ddrs[i], mrvl_ddrs[i-1]) > 0); + } + return TEST_OK; +} + static struct test_case tests__pmu[] = { TEST_CASE("Parsing with PMU format directory", pmu_format), TEST_CASE("Parsing with PMU event", pmu_events), TEST_CASE("PMU event names", pmu_event_names), + TEST_CASE("PMU name combining", name_len), + TEST_CASE("PMU name comparison", name_cmp), { .name = NULL, } }; -- 2.45.0.118.g7fe29c98d7-goog