From patchwork Wed Nov 16 23:38:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp117873wrr; Wed, 16 Nov 2022 15:41:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4uG3tiFFtUFod1h4gl0cFXLm1Z9zd2l5osNxBuZu1PjDY+u7reQLHi0zI32TZRalXbMiNV X-Received: by 2002:a05:6402:4020:b0:461:9d22:348d with SMTP id d32-20020a056402402000b004619d22348dmr42288eda.76.1668642079050; Wed, 16 Nov 2022 15:41:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642079; cv=none; d=google.com; s=arc-20160816; b=r/CRzZni+gXi09Jac/MEgCBWnbScSGid7szWTvKay05b71JHVIUnt5hi+6TYOCbwmj 2spv3Qy8HF6sTRytpuhRI3bhpS58ClT5HRQN1TJJ8lv8l7r0/uYF5K3ZZLqK0MzJut6s c+2ziCLlGCfIKmfk9mekouag3h7wf9QBTT0jzqiz6imJk4nXUWXy5VP+ldTwClv4qR0J LJCHRRejAg216xclA31NIQ+Qm0MKWUIef60WL3iYdT7+KBdYU4WoHGOQADSXfA8LyR4l hLUcfu0DaTJ8c+9BSvFNiFTCH5ez5oDFOshJwkITLvs0EPK6cWb6DxXS333v6zX3Nc2x 17tA== 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:sender :dkim-signature; bh=tH9ILVQPbpPL5nSTMa8Bnv/nrDrzsZ52M2SrwHw2PME=; b=fwqTk7y9GaYV+vz5MmApLcJi24Iho7BCldCAPpI99eFO5dUxiLgZQvABu5Pj1SapPg 1qtZWw6G13hczEdTivfyp/m5fKo18ecYg/YeTAOY+lQJnNIjs0i6MveFHR99Z+3jgw+I F7Oqlw1Yp0vWdiW245ajwl2tK880aEIHX7QZev0kJOZT62IlXAJiRxgg0xcOvGPnso// 5KAmAIW5gMwJFl4dMf2ytGXNaTJD05J0dktRikBt5GhBRyizGqsW8FXiUGV1akEkoli5 u/AMoc9Qlba3f1kCwqE9y0xt9O/Mj/EHMRTkZju/3VibnxTgK4dTDCHRkoILuKu0QITf QfIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=m4xEihDd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a056402519200b0046627848e1fsi15565415edd.630.2022.11.16.15.40.55; Wed, 16 Nov 2022 15:41:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=m4xEihDd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234404AbiKPXjG (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234178AbiKPXjB (ORCPT ); Wed, 16 Nov 2022 18:39:01 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47321FC3; Wed, 16 Nov 2022 15:39:00 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id k7so5351pll.6; Wed, 16 Nov 2022 15:39:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=tH9ILVQPbpPL5nSTMa8Bnv/nrDrzsZ52M2SrwHw2PME=; b=m4xEihDdJqYogfuBZBlfb0sBJb6BVfmFoJ0L4OO2IG7JBsAgYc93fODmV0/AxhfgZh hQj+9tZt+V1ZtSBTycFanMzUEdnRcjh/HaHESTLM94kztVf3I9gC+vKqm7828ptyM2s1 RYTJzTxbgNNUjNdVrC0Gt9t/G+9U4AddQBgCD+aCtOE+2CDQ0WHvWd09ArMzuQGXBqws kRgzNpbjEzRRypSGxmGWwJEcuLuDkTYGzDfbDi+vDDtM61/WcrPwfo0NiuHQIHk3STK2 hGkNJN0e+u3YZ/74WS52L3zIvbip+4WUCQtbYA5HSJ5RNeSG/ef844hR9vrsOUdxlFRG XT2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=tH9ILVQPbpPL5nSTMa8Bnv/nrDrzsZ52M2SrwHw2PME=; b=CdEZLhwaSPLlVxYIcf5uY5+1V6CVcBP0+hx53aEknUoV6wRIzIfOTWuCUuibW7Yjvk a7n0uQF9WZIRJYsIwZO3I90XqsGERhJ6W/hyUKwrqxhzqfJNIEQHiQ+rK07IjSI1kfHS 4dmBYPthD45mIlrYOw6bpnbWRBiU/ND4UL1REnDzCOaOFIkvMD7j/m82KMe6/oSt1tpH /j9OzcX+EyxOJQqIMFkBmOsAJSPIvtoNhZOrtf93Tkpq2MN/J2IJjh/JJEpCmh1RdfVO iqb2n5VORq4Z+gORiQrjo9cM6hhLqdAB3uyKyGkkM6xPU5jO/ApUwGg/Hqkh/btKYOWh Ke8Q== X-Gm-Message-State: ANoB5pmIr+AE2mScaQfz1xUa4sMPSdAEGdrU64Ukk3nrDGlmt/bg2V7m KuVNO0K520qtfBo5ik4zKyA= X-Received: by 2002:a17:90b:368d:b0:212:6a0b:7d55 with SMTP id mj13-20020a17090b368d00b002126a0b7d55mr138810pjb.16.1668641939546; Wed, 16 Nov 2022 15:38:59 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:38:59 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 01/12] perf test: Add -w/--workload option Date: Wed, 16 Nov 2022 15:38:43 -0800 Message-Id: <20221116233854.1596378-2-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698036499889203?= X-GMAIL-MSGID: =?utf-8?q?1749698036499889203?= The -w/--workload option is to run a simple workload used by testing. This adds a basic framework to run the workloads and 'noploop' workload as an example. $ perf test -w noploop The noploop does a loop doing nothing (NOP) for a second by default. It can have an optional argument to specify the time in seconds. Signed-off-by: Namhyung Kim --- tools/perf/tests/Build | 2 ++ tools/perf/tests/builtin-test.c | 24 +++++++++++++++++++++ tools/perf/tests/tests.h | 22 +++++++++++++++++++ tools/perf/tests/workloads/Build | 3 +++ tools/perf/tests/workloads/noploop.c | 32 ++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 tools/perf/tests/workloads/Build create mode 100644 tools/perf/tests/workloads/noploop.c diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index 2064a640facb..11b69023011b 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build @@ -103,3 +103,5 @@ endif CFLAGS_attr.o += -DBINDIR="BUILD_STR($(bindir_SQ))" -DPYTHON="BUILD_STR($(PYTHON_WORD))" CFLAGS_python-use.o += -DPYTHONPATH="BUILD_STR($(OUTPUT)python)" -DPYTHON="BUILD_STR($(PYTHON_WORD))" CFLAGS_dwarf-unwind.o += -fno-optimize-sibling-calls + +perf-y += workloads/ diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 7122eae1d98d..ce641ccfcf81 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -118,6 +118,10 @@ static struct test_suite **tests[] = { arch_tests, }; +static struct test_workload *workloads[] = { + &workload__noploop, +}; + static int num_subtests(const struct test_suite *t) { int num; @@ -475,6 +479,21 @@ static int perf_test__list(int argc, const char **argv) return 0; } +static int run_workload(const char *work, int argc, const char **argv) +{ + unsigned int i = 0; + struct test_workload *twl; + + for (i = 0; i < ARRAY_SIZE(workloads); i++) { + twl = workloads[i]; + if (!strcmp(twl->name, work)) + return twl->func(argc, argv); + } + + pr_info("No workload found: %s\n", work); + return -1; +} + int cmd_test(int argc, const char **argv) { const char *test_usage[] = { @@ -482,12 +501,14 @@ int cmd_test(int argc, const char **argv) NULL, }; const char *skip = NULL; + const char *workload = NULL; const struct option test_options[] = { OPT_STRING('s', "skip", &skip, "tests", "tests to skip"), OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('F', "dont-fork", &dont_fork, "Do not fork for testcase"), + OPT_STRING('w', "workload", &workload, "work", "workload to run for testing"), OPT_END() }; const char * const test_subcommands[] = { "list", NULL }; @@ -504,6 +525,9 @@ int cmd_test(int argc, const char **argv) if (argc >= 1 && !strcmp(argv[0], "list")) return perf_test__list(argc - 1, argv + 1); + if (workload) + return run_workload(workload, argc, argv); + symbol_conf.priv_size = sizeof(int); symbol_conf.sort_by_name = true; symbol_conf.try_vmlinux_path = true; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 5bbb8f6a48fc..d315d0d6fc97 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -180,4 +180,26 @@ int test__arch_unwind_sample(struct perf_sample *sample, DECLARE_SUITE(vectors_page); #endif +/* + * Define test workloads to be used in test suites. + */ +typedef int (*workload_fnptr)(int argc, const char **argv); + +struct test_workload { + const char *name; + workload_fnptr func; +}; + +#define DECLARE_WORKLOAD(work) \ + extern struct test_workload workload__##work + +#define DEFINE_WORKLOAD(work) \ +struct test_workload workload__##work = { \ + .name = #work, \ + .func = work, \ +} + +/* The list of test workloads */ +DECLARE_WORKLOAD(noploop); + #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build new file mode 100644 index 000000000000..f98e968d4633 --- /dev/null +++ b/tools/perf/tests/workloads/Build @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +perf-y += noploop.o diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c new file mode 100644 index 000000000000..940ea5910a84 --- /dev/null +++ b/tools/perf/tests/workloads/noploop.c @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include +#include +#include "../tests.h" + +static volatile sig_atomic_t done; + +static void sighandler(int sig __maybe_unused) +{ + done = 1; +} + +static int noploop(int argc, const char **argv) +{ + int sec = 1; + + if (argc > 0) + sec = atoi(argv[0]); + + signal(SIGINT, sighandler); + signal(SIGALRM, sighandler); + alarm(sec); + + while (!done) + continue; + + return 0; +} + +DEFINE_WORKLOAD(noploop); From patchwork Wed Nov 16 23:38:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21333 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118572wrr; Wed, 16 Nov 2022 15:43:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf7w5tP1YChkj9oBWkb2utKuPVpH4BQxx5YTYLH7XW6uxBa2AnwaxBQcWevQ+BGl5ccQ/XB7 X-Received: by 2002:a17:906:2998:b0:78d:3ff8:6ec8 with SMTP id x24-20020a170906299800b0078d3ff86ec8mr79106eje.568.1668642179890; Wed, 16 Nov 2022 15:42:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642179; cv=none; d=google.com; s=arc-20160816; b=lj+B+RdT4szlAmvGkXhqRtI03/uO1/O76p8ZX6cmuMrqL3EzPq96ydKaWbyP+nm3p0 1vPxNjFxtt14NNz40ZTxdsdvroNAbf0fC2fLFuxRkCrGNDm69eB7pyKFlfuE/Vgbf0j2 lClMOkPniLHHcK/DQwLdQ9l4fQue3NdKrjFo+/BxE9zNAzNABn4mgAotlKW6P1RkY/cM 7fZjB6y+VVAtkmpZ0cqju+SbxFnEbK7ufhub6zJ+REc/Pq9G+XLopJB7+gmvmI4hCJyN 6gM0MZ0BVfMbsATtNISeytVmOi57A69DltGX3PrygOzX5kWqAVeTvtXHRD3/Yl7Id3gP sbhA== 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:sender :dkim-signature; bh=e32OqBWuzlRvRYqEyrLxtjOglgwrHLuTqyHep2+BwGY=; b=qJ8bSARisqVsUVkbdF+AFiOHFiLkFgTfif5rqilTh1MbWU6UDamVXHnJ6gMw0VLcN3 oOgahOifASa/1gx1RJNRAz3PJXWiVBHuyEQPaxNClhHkEFgDaT/XdOMJjEnDrj4izMhQ Xue42pklwQ1ANMgdPG5/qskYSx9OIWASdkCXwYhqpwpE/9wVpbyOBR3QD2GMDYYRvstw ujMQhzxLTPQQeCK1h3+IVoSs6gp41rYekuG2syOe/yRqSrJ+UGr8Z5AJYj/LpgDeELKq iYMSVLNHH7pQfo2F15VCCuFf+4hZX1zjhZp+Q1n3phM3YVSFylbyUuu5bMdxvjkM9mma wd3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FWxyJJVi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg19-20020a170907a41300b0073c0169863dsi15693440ejc.465.2022.11.16.15.42.37; Wed, 16 Nov 2022 15:42:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FWxyJJVi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234455AbiKPXjM (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234207AbiKPXjC (ORCPT ); Wed, 16 Nov 2022 18:39:02 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81F852735; Wed, 16 Nov 2022 15:39:01 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id g10so552550plo.11; Wed, 16 Nov 2022 15:39:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=e32OqBWuzlRvRYqEyrLxtjOglgwrHLuTqyHep2+BwGY=; b=FWxyJJVilgcjlTlzSRL0hSHGUP5IZ9FYJ6TUCpzf13Zyj2bOgzWZwmlH+rJPZt2oKH KL5Xm9n5PUqDpOMoybYP+wTYNzB82M/q7+iq0Wxv+9jOlbUnr4X4W6fKvb5qMmHD1lq2 FmFbYB8AP7/7cmVM++vQK+aKGdzvEz0hTS7mfgCFgAH1RtdJRsFHXghj0SqrTaNkmseG sKwo9m/EFCVw8pcZInRctMBsBxSAbAFMsrDc3x87+rw7QyLVyE+oZUi3dlDSsAIZlk6F 15sp5c0KdRKbC+i52eSS52vIqp2FW5WAwvSKQmsHUaQ2KkV6TclSWRAu4Hu6H0VdE8Jd RNGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e32OqBWuzlRvRYqEyrLxtjOglgwrHLuTqyHep2+BwGY=; b=Y4fmlmE4/HKkyfl6RY57LhIs7W9D08bDm5dmrBBX1XUWS3TTKEfp86FN8Je1wW2z6Z dTEt30O2Ciatcn11jd7LNY4MMaw+WUne/DrqaQ7gPXGwqVzZydPISo0+u07mD8FPrGEH A3hPIGyK/Awcf/bI1D8VRY0bToHClQZvjoxCGtHCHKvtOjZmXSLe3aDJZ3rjTk5hSJ9A bTevu5chR2MzXEg4cXjnV8w9TeASVIJhWWp+IbO3rwg4RGEqDo22k46M9YvOybxLYwGM dYd0WyEVxdFcFzTQhmIrk4l1RqFR84r+CP3UK/xfN94mjLoHtQLKwZqnvK04jQb0cUB2 4VHQ== X-Gm-Message-State: ANoB5pn2bIBZ1PptvcZmLfOyQgg616sMdNIKNT6YqvcjEl8xSOEl8Dfg QNTfLyrO9Rm1F5DFdvkTWbU= X-Received: by 2002:a17:902:bb8b:b0:188:d4bf:dbfe with SMTP id m11-20020a170902bb8b00b00188d4bfdbfemr210164pls.31.1668641940900; Wed, 16 Nov 2022 15:39:00 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:00 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 02/12] perf test: Replace pipe test workload with noploop Date: Wed, 16 Nov 2022 15:38:44 -0800 Message-Id: <20221116233854.1596378-3-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698142235453910?= X-GMAIL-MSGID: =?utf-8?q?1749698142235453910?= So that it can get rid of requirement of a compiler. Also define and use more local symbols to ease future changes. $ sudo ./perf test -v pipe 87: perf pipe recording and injection test : --- start --- test child forked, pid 748003 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] 748014 748014 -1 |perf [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] 99.83% perf perf [.] noploop [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] 99.85% perf perf [.] noploop [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.160 MB /tmp/perf.data.2XYPdw (4007 samples) ] 99.83% perf perf [.] noploop test child finished with 0 ---- end ---- perf pipe recording and injection test: Ok Tested-by: James Clark Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/pipe_test.sh | 55 ++++++----------------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/tools/perf/tests/shell/pipe_test.sh b/tools/perf/tests/shell/pipe_test.sh index 1b32b4f28391..8dd115dd35a7 100755 --- a/tools/perf/tests/shell/pipe_test.sh +++ b/tools/perf/tests/shell/pipe_test.sh @@ -2,68 +2,33 @@ # perf pipe recording and injection test # SPDX-License-Identifier: GPL-2.0 -# skip if there's no compiler -if ! [ -x "$(command -v cc)" ]; then - echo "failed: no compiler, install gcc" - exit 2 -fi - -file=$(mktemp /tmp/test.file.XXXXXX) data=$(mktemp /tmp/perf.data.XXXXXX) +prog="perf test -w noploop" +task="perf" +sym="noploop" -cat < -#include -#include - -volatile int done; - -void sigalrm(int sig) { - done = 1; -} - -__attribute__((noinline)) void noploop(void) { - while (!done) - continue; -} - -int main(int argc, char *argv[]) { - int sec = 1; - - if (argc > 1) - sec = atoi(argv[1]); - - signal(SIGALRM, sigalrm); - alarm(sec); - - noploop(); - return 0; -} -EOF - - -if ! perf record -e task-clock:u -o - ${file} | perf report -i - --task | grep test.file; then +if ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep ${task}; then echo "cannot find the test file in the perf report" exit 1 fi -if ! perf record -e task-clock:u -o - ${file} | perf inject -b | perf report -i - | grep noploop; then +if ! perf record -e task-clock:u -o - ${prog} | perf inject -b | perf report -i - | grep ${sym}; then echo "cannot find noploop function in pipe #1" exit 1 fi -perf record -e task-clock:u -o - ${file} | perf inject -b -o ${data} -if ! perf report -i ${data} | grep noploop; then +perf record -e task-clock:u -o - ${prog} | perf inject -b -o ${data} +if ! perf report -i ${data} | grep ${sym}; then echo "cannot find noploop function in pipe #2" exit 1 fi -perf record -e task-clock:u -o ${data} ${file} -if ! perf inject -b -i ${data} | perf report -i - | grep noploop; then +perf record -e task-clock:u -o ${data} ${prog} +if ! perf inject -b -i ${data} | perf report -i - | grep ${sym}; then echo "cannot find noploop function in pipe #3" exit 1 fi -rm -f ${file} ${data} ${data}.old +rm -f ${data} ${data}.old exit 0 From patchwork Wed Nov 16 23:38:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp117786wrr; Wed, 16 Nov 2022 15:41:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5AyrPM1Agpzqm0UdBroJtQ2chLBvYjEJtaeizWEyLbt+P8dYASKxYeN3wwe9IsGdTxhNr/ X-Received: by 2002:a17:906:3385:b0:7a2:b352:a0d3 with SMTP id v5-20020a170906338500b007a2b352a0d3mr89643eja.399.1668642063396; Wed, 16 Nov 2022 15:41:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642063; cv=none; d=google.com; s=arc-20160816; b=hPzYXFM7YSyc4bzxLkeYX9AieE6QOdIUioSpAkCjCbLBItmEC1PzMNHSV4+EbsK1hV 8ycJWZLDEKChy5QjPagIjQBT2sgrmzEwgh6w1tM1G2cWwv1PMJw4nOjzD1JDliKy5Qnv Uud4dYKjnYh6K7VsRB+Ea9Hg4SN6u4nuOIb6gP9stefcTk35udnz+3J2nmmCivs6KUNP 4BrBD2tknPhFqBnS9w2uG+zGGVT/l6l/8Dj7doibSVpTpOjkaW2fqvdBy42noavt9xxQ W/7RaZiA9zIhHS00GW/ISJN3WQ3rhqLZfb6e7sekxBauDsVz5bLVbe9C+EE76HygdMwS Q6lA== 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:sender :dkim-signature; bh=hV9u5PxVvqmV+BpGh3+8lIJe2BvSUrc7KFHFFdwiD9k=; b=WRRzpunji7a3kixgqiQTvE4TyAGzfJ1IETvSPvgTG/xLc7+hrmyDogqRf1iFNsfLhq jLAtegtn1JfO1diUVXh5K3/qXJTxDC+mlH5HLTr7MXYcfyTotB2+cw+erhplfyfBmRST uV5/uyfiOkbMbQdcW7gON/0k083wb/hEH3nUiIMWv2l/fGaxvkb06/5V2YJpFrFCtNf9 biCvUvdL6sFJjy1uwv2LEMysw2Gn74FTCswRqZQpmUlXDlN7aFDFLM6zB8zueffqurFV Qto63C1l2JEIFfC6upB8rfQSKg1kPUAtBqQRo2YZtVzunMVumEW8/RvVW1q4531C+JJg Gu4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="EVKtp/j2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a17090633ce00b0078de536a3cdsi12239712eja.119.2022.11.16.15.40.40; Wed, 16 Nov 2022 15:41:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="EVKtp/j2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234507AbiKPXjQ (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbiKPXjD (ORCPT ); Wed, 16 Nov 2022 18:39:03 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBE2ABE2B; Wed, 16 Nov 2022 15:39:02 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso291845pjt.0; Wed, 16 Nov 2022 15:39:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=hV9u5PxVvqmV+BpGh3+8lIJe2BvSUrc7KFHFFdwiD9k=; b=EVKtp/j2eht2QovsgJ3wqzLdIVzxwPf117oXwcO7GIUJ/wtopHywSHAnzOfQblWHN6 BEf5plioroWg37zahPDrFKtc/LNRP00oiuvXIvtid1oQhMfQNxcRMncKJqOa+vVNXgnX GH8UhH6mLTz6o9facoKElJxdlnahcWuuXolG0MMqVUimnsgXfszfvX0MW63x2Ehbw6+r 3Ed4Pjx2Xc6EWtKFnxWdg38XyYjxSI66Xy/0jygfpGuMla3WzhIXEW2qzYM1y5eJBzmM tm9uNu3yghimo91s2N1j83lWijAQUyZXwnhX3Ham5tg9FYQYJATBfu8+US5hkTaE4dEd ckxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hV9u5PxVvqmV+BpGh3+8lIJe2BvSUrc7KFHFFdwiD9k=; b=IBqfZBKwbk80EoXXhiezYIRG81FaFRCow6vbbVDox9K3Cxzsbg9WbYqgGvdl+1AfXo QpRgMiYklL3PQwBqNyDwMRvNXEtCqpr+uzWEUZDcaUWEMp3Me5cXRo3JIciLmbQbqF5F iDHPCRyNj+ihd1rvPrwue3xG5Hf0R3wgTxGngLOwtUGHbAAoxiRgfB11XDomua5uytIH /vw2biqj2nio/02tboSY1Pc6tddVgYjm46AcWJn8172D4sFXT/bfUbJi+Y7yTA2ByqGh jkLnBm+QjMzsEnANrmHxxRHnpUIX3JtGKWEQufnNbqSHxLc+HRMzYN5PqPfsElys6xbl hN7A== X-Gm-Message-State: ANoB5pn/vIbXhN1D0sbB9QaktagIIMoUiWspOz0dnzv7eOMK9L0DPl+3 7LPfBufAW0GMNjTsu4Y3ytw= X-Received: by 2002:a17:90b:1892:b0:218:8f2:5af9 with SMTP id mn18-20020a17090b189200b0021808f25af9mr5982135pjb.65.1668641942168; Wed, 16 Nov 2022 15:39:02 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:01 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 03/12] perf test: Add 'thloop' test workload Date: Wed, 16 Nov 2022 15:38:45 -0800 Message-Id: <20221116233854.1596378-4-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698020237799653?= X-GMAIL-MSGID: =?utf-8?q?1749698020237799653?= The thloop is similar to noploop but runs in two threads. This is needed to verify perf record --per-thread to handle multi-threaded programs properly. $ perf test -w thloop It also takes an optional argument to specify runtime in seconds (default: 1). Signed-off-by: Namhyung Kim --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 1 + tools/perf/tests/workloads/thloop.c | 53 +++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 tools/perf/tests/workloads/thloop.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index ce641ccfcf81..161f38476e77 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -120,6 +120,7 @@ static struct test_suite **tests[] = { static struct test_workload *workloads[] = { &workload__noploop, + &workload__thloop, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index d315d0d6fc97..e6edfeeadaeb 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -201,5 +201,6 @@ struct test_workload workload__##work = { \ /* The list of test workloads */ DECLARE_WORKLOAD(noploop); +DECLARE_WORKLOAD(thloop); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index f98e968d4633..b8964b1099c0 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 perf-y += noploop.o +perf-y += thloop.o diff --git a/tools/perf/tests/workloads/thloop.c b/tools/perf/tests/workloads/thloop.c new file mode 100644 index 000000000000..29193b75717e --- /dev/null +++ b/tools/perf/tests/workloads/thloop.c @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include +#include +#include +#include "../tests.h" + +static volatile sig_atomic_t done; +static volatile unsigned count; + +/* We want to check this symbol in perf report */ +noinline void test_loop(void); + +static void sighandler(int sig __maybe_unused) +{ + done = 1; +} + +noinline void test_loop(void) +{ + while (!done) + count++; +} + +static void *thfunc(void *arg) +{ + void (*loop_fn)(void) = arg; + + loop_fn(); + return NULL; +} + +static int thloop(int argc, const char **argv) +{ + int sec = 1; + pthread_t th; + + if (argc > 0) + sec = atoi(argv[0]); + + signal(SIGINT, sighandler); + signal(SIGALRM, sighandler); + alarm(sec); + + pthread_create(&th, NULL, thfunc, test_loop); + test_loop(); + pthread_join(th, NULL); + + return 0; +} + +DEFINE_WORKLOAD(thloop); From patchwork Wed Nov 16 23:38:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21331 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118078wrr; Wed, 16 Nov 2022 15:41:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7g/kqAM3TB5005B2DPP0BSh3VPGxE2GxdyZJHIjeswFJ1RyKabb8xRFNcUcAR18i8GKZQ8 X-Received: by 2002:a17:906:a416:b0:7ad:923a:b849 with SMTP id l22-20020a170906a41600b007ad923ab849mr64746ejz.677.1668642111101; Wed, 16 Nov 2022 15:41:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642111; cv=none; d=google.com; s=arc-20160816; b=dK7wGahW2C9ODJq2h4NXqVexFxQZ/Z9cqL9a91GLUuEJKG/zA5aLyqUmQQWG7LlKtV C3xexD4Z7MTNLrlr2VEwvN5bXU+YNCJbNEG0x38xHMiH1WW9CofWkPCmEhdPoIAC150q NWf/XQLf7pPkDy4ppMDRjim53jgkR5KDoSctg8OVqDrosP+WfIGTWGM8iT5Ic+4PwY1U evdAhrtunOxwmSgVkQ4Gn93Ecv1IP2mFPxF2uSXbkgfpefRXh87STW5tGGFDFx8KhoNh R4ZWYXX4AqHXBRI0X3UXTnU373Sm3169DEOityZuIwAqHo8gqAHZnk4d3hCBbvn1qFhN 8NNg== 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:sender :dkim-signature; bh=eJxyXYhhzgIeHuBQXESNxNIqNBrSSrRkKX/giDhK4aM=; b=t29shsC1yvqTWEzGkKxGm7bYfJ+NE+STjuSAOWI4l7l98l2mDUPQboYrh2cgdCzILW IG1SEiANVrkzwHMSO6cuGnV1ocwoDGSxGduHi5nD1U8oCf+JQ3BHrikFPgIFxyBSa59a QHFnJlzYVqYZ6tTBPHZun3wFl/ShXk1RdTPGpM/4HQ81aTIAnPV3dD/aOgF5C25tGBZm hlVdSPDti5DjoATDEHPemVn5g/oAgZhsaBMmQQzI2JFShmPsMtiPQfjOjtD8nP2BP/p+ joaGulEd0ert/rS8Jvm1XAqz/JMWD2GL2gmXoJZKl+fFAvoGcOK3QXU48GfdkEf09bGQ 52og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MgBzJ1j4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di13-20020a170906730d00b007b273d1f664si5309644ejc.128.2022.11.16.15.41.27; Wed, 16 Nov 2022 15:41:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MgBzJ1j4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234677AbiKPXjU (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234081AbiKPXjE (ORCPT ); Wed, 16 Nov 2022 18:39:04 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1049ABE2B; Wed, 16 Nov 2022 15:39:04 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id y4so20308plb.2; Wed, 16 Nov 2022 15:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=eJxyXYhhzgIeHuBQXESNxNIqNBrSSrRkKX/giDhK4aM=; b=MgBzJ1j4wC/4bFO/NNOLeJxd6XLPRONHzpzcq1e3R96YYREGdqSs2UHBzfaT2WcgXb li9yoRi35ieBRHA2BGciShpI2i9bpI1BMBCqGnoHOCCzc4ELU++/RGkmpJLnHWZprDCR IE3fLZ5o45ViZHbPI12vuu7al158vkwOB1o0Rb7treKPpstCsngU59tZmZuOa0i7zud0 qsKAzg4tJGhZgG+aGAi0NJl+cydzW94jSqRMutCuGWkwopkI5zKGWECdNRVTRbJiVDTL 8ZfmS04rNwKRbmi/Ej7AtjivQDxs3Zy9vy38hIYRFtBRwRcf7tm8WAcPte+Ism6NKGaR 27Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eJxyXYhhzgIeHuBQXESNxNIqNBrSSrRkKX/giDhK4aM=; b=DFTC4f/C1REcZAiU1pMCQpaPWHAVwBIN0cp+Y+MS3/XV7R7uE33VXBXIbtq0CiRzlt eSDyAkbY4ugBS6Kdg0GO2IgjEnOrN/p+3KbxRp9QPkejOhz39Murxi2i7DfORJnAWhTz yFcog0ooDZGxnL3bI3XkZ1ZUKNnT+rOaW193P0JUVUenRz+q8c0gh5w9bElD+1UXAWhL nRBzv1cxirVyleKlfOrQwkGxyGf/moK5iPw5jGh4qpYpRCNU5Jb3JmFmXlbj17u+6rXu EopZWdCFq6vVxKzsMQ6R39lQh0w1CaxW894Gx5pZW7d5lh3vlvtu0b9cFw5mFwIVH1Xn BS2A== X-Gm-Message-State: ANoB5pntgKBTSas2r0j9BhUbuoVt4uVuQm/eGzujnx+O1+fD5U50xtSm E+yx4mU9w8Ea+njR9X0sFzU= X-Received: by 2002:a17:90a:8d13:b0:213:c15:6f08 with SMTP id c19-20020a17090a8d1300b002130c156f08mr45947pjo.134.1668641943497; Wed, 16 Nov 2022 15:39:03 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:03 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 04/12] perf test: Replace record test workload with thloop Date: Wed, 16 Nov 2022 15:38:46 -0800 Message-Id: <20221116233854.1596378-5-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698070198779214?= X-GMAIL-MSGID: =?utf-8?q?1749698070198779214?= So that it can get rid of requirements for a compiler. $ sudo ./perf test -v 92 92: perf record tests : --- start --- test child forked, pid 740204 Basic --per-thread mode test Basic --per-thread mode test [Success] Register capture test Register capture test [Success] Basic --system-wide mode test Basic --system-wide mode test [Success] Basic target workload test Basic target workload test [Success] test child finished with 0 ---- end ---- perf record tests: Ok Tested-by: James Clark Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/record.sh | 59 ++------------------------------ 1 file changed, 3 insertions(+), 56 deletions(-) diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh index e93b3a8871fe..4dff89e3a3fd 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -9,17 +9,13 @@ shelldir=$(dirname "$0") err=0 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) -testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX) +testprog="perf test -w thloop" testsym="test_loop" cleanup() { rm -rf "${perfdata}" rm -rf "${perfdata}".old - if [ "${testprog}" != "true" ]; then - rm -f "${testprog}" - fi - trap - EXIT TERM INT } @@ -29,53 +25,6 @@ trap_cleanup() { } trap trap_cleanup EXIT TERM INT -build_test_program() { - if ! [ -x "$(command -v cc)" ]; then - # No CC found. Fall back to 'true' - testprog=true - testsym=true - return - fi - - echo "Build a test program" - cat < -#include -#include - -void test_loop(void) { - volatile int count = 1000000; - - while (count--) - continue; -} - -void *thfunc(void *arg) { - int forever = *(int *)arg; - - do { - test_loop(); - } while (forever); - - return NULL; -} - -int main(int argc, char *argv[]) { - pthread_t th; - int forever = 0; - - if (argc > 1) - forever = atoi(argv[1]); - - pthread_create(&th, NULL, thfunc, &forever); - test_loop(); - pthread_join(th, NULL); - - return 0; -} -EOF -} - test_per_thread() { echo "Basic --per-thread mode test" if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null @@ -96,8 +45,8 @@ test_per_thread() { return fi - # run the test program in background (forever) - ${testprog} 1 & + # run the test program in background (for 30 seconds) + ${testprog} 30 & TESTPID=$! rm -f "${perfdata}" @@ -205,8 +154,6 @@ test_workload() { echo "Basic target workload test [Success]" } -build_test_program - test_per_thread test_register_capture test_system_wide From patchwork Wed Nov 16 23:38:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118626wrr; Wed, 16 Nov 2022 15:43:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dqS9h95S7KOxlT1iNxdlxXslSNYZTn3KVK7SAvHGMLsIRtCuwrHm/RIKVtcEc51gblhsi X-Received: by 2002:a17:907:208d:b0:7ad:d662:f568 with SMTP id pv13-20020a170907208d00b007add662f568mr72352ejb.616.1668642189172; Wed, 16 Nov 2022 15:43:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642189; cv=none; d=google.com; s=arc-20160816; b=rBeNbsnuYNMWmzuOMONB0K0eq6DfrunqKXKvSWzb6nr55ts+Z9fKN02mOFRNEMLHPK oxilRLhoZ0+3R0ZuMUb+t8qWw+gtwzH6cta0X0UY7KpBkY5+U4UBwEj/FakvgQI2cN7t u1i2h04+iFuYhSHZs5RvpoaAaO5jqkMnwXfgrU/pevBZeb387Nh3KQjPImBeFgNRGjX0 tgsMrljIhbONO6I1k0+g83Nesnh//1sxu5Su+r5e+6g3INjuGv2jL61u+I3jz/0PBTqL j1rlP/w28iRgmrhvKydO7fI7m+M2SVg+DfTgOJ//w+FYF3DABq9K8LkGRAJyxC7/DGI4 rYMQ== 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:sender :dkim-signature; bh=P97FeOGLA96wHsbLefL56s9RPadISI4phF1+HGdaCPc=; b=eK+zHreYmvGMmouGrm0kIt2Wu1207DJrqVrfveml4irCmVpFcGj7AcZrYNGj6MxCLq zN/KZZVVt7RSoqTvVTY6kzYpp68qvK3kBtYnLgyWqyV9AET9ta6J0TLq9jXKk98KRLB4 Xl71HlA0HYl00uC+7OqtS1ttVgHxaIVYtXNq6oqq5ffcUXExfbVWc2+In0NHWPoWn7P4 x1WgyTRDO54GNl7T+XbO3gxmtL97E783QKDNqiNUsKdTNKxtkDEoiwfHmSFnCuqtCHNG HKEm7f9FjK/oVjsuh1Ih/ppf1Y06grKF9XJrzN45e8Gf+yelCH9P777pzKWm74DpFiSk SCmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RwHw2BwE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020a170906974d00b0073d8e4e8c77si15892119ejy.1005.2022.11.16.15.42.45; Wed, 16 Nov 2022 15:43:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RwHw2BwE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234554AbiKPXjW (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233862AbiKPXjH (ORCPT ); Wed, 16 Nov 2022 18:39:07 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60CFC68299; Wed, 16 Nov 2022 15:39:05 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id o7so124904pjj.1; Wed, 16 Nov 2022 15:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=P97FeOGLA96wHsbLefL56s9RPadISI4phF1+HGdaCPc=; b=RwHw2BwEHSGoTMuF7srFdB0iTSrzA5Co9VTFtPfLOesT5GtJEK+x1MBkPa+CtMTuvJ OwP4Js8lrEhxWpT3SZD8xoGEHrwrDyTB8ST+vgtBEqKzHk9qGGsOQm7LedjCysHf46dn BXhHddbyamCHzJoLz4TV28pufnBQGWda7k+jKuIP5Uk4VfHg9iHzONJSHg6N7bCOWAAZ h8euoDw7pWXt7hL2j8HlGCjS/u6zFlU2ipGfe37X7Cn6wcvYthXASQ3LFOaUJQfbJxTU CSZIRER9R8jqrCIWrSPPSialTSA64JgvczLcBYfh+C5AGr0ACEh1wYsgSSwNh9XKPr1O 4aRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=P97FeOGLA96wHsbLefL56s9RPadISI4phF1+HGdaCPc=; b=dA9EXCOF/ypPqEMt1Baj3bVwx0HTHWB44uorK+0d8bvXvq3rDc49czIffWwmEqDoWP 6VxFeAnwiFyaETG4SyOqU3m4s1BysySluE6Vd8zHXPBdnFdExEM4JsLA4sSZ1VvHTPpb GW6WQWlVnd1VETgjZla0ktIHXblyAr6vxYRvKJFVISERfb+4moNzybEYYIxiWKQTLUQg JFn5GRsYDHmrPsRtNqFXRX2zmCVDA/MXfgAiMx90AxaVfS9BMCO5UERlrm/r2LDdO/hm km58UutlAJXj/tq68mvfxFwiK17H8EZdtNBeAkkJEDoZ2gcCxAOcFd2rdWKf0VTXquCK 7TTw== X-Gm-Message-State: ANoB5pkhqwWaNiMULtCwRmg4LKwqcLBUdc5skjvHu77W141Jh/+jXynI nJDrTFk3wtR8VDqDSOmrtPpp9rsn3GU= X-Received: by 2002:a17:903:25d1:b0:176:71be:cc64 with SMTP id jc17-20020a17090325d100b0017671becc64mr53625plb.141.1668641944771; Wed, 16 Nov 2022 15:39:04 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:04 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 05/12] perf test: Add 'leafloop' test workload Date: Wed, 16 Nov 2022 15:38:47 -0800 Message-Id: <20221116233854.1596378-6-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698152277572951?= X-GMAIL-MSGID: =?utf-8?q?1749698152277572951?= The leafloop workload is to run an infinite loop in the test_leaf function. This is needed for the ARM fp callgraph test to verify if it gets the correct callchains. $ perf test -w leafloop Signed-off-by: Namhyung Kim --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 3 +++ tools/perf/tests/workloads/leafloop.c | 34 +++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 tools/perf/tests/workloads/leafloop.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 161f38476e77..0ed5ac452f6e 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -121,6 +121,7 @@ static struct test_suite **tests[] = { static struct test_workload *workloads[] = { &workload__noploop, &workload__thloop, + &workload__leafloop, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index e6edfeeadaeb..86804dd6452b 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -202,5 +202,6 @@ struct test_workload workload__##work = { \ /* The list of test workloads */ DECLARE_WORKLOAD(noploop); DECLARE_WORKLOAD(thloop); +DECLARE_WORKLOAD(leafloop); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index b8964b1099c0..631596bdb2b3 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -2,3 +2,6 @@ perf-y += noploop.o perf-y += thloop.o +perf-y += leafloop.o + +CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c new file mode 100644 index 000000000000..1bf5cc97649b --- /dev/null +++ b/tools/perf/tests/workloads/leafloop.c @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include "../tests.h" + +/* We want to check these symbols in perf script */ +noinline void leaf(volatile int b); +noinline void parent(volatile int b); + +static volatile int a; + +noinline void leaf(volatile int b) +{ + for (;;) + a += b; +} + +noinline void parent(volatile int b) +{ + leaf(b); +} + +static int leafloop(int argc, const char **argv) +{ + int c = 1; + + if (argc > 0) + c = atoi(argv[0]); + + parent(c); + return 0; +} + +DEFINE_WORKLOAD(leafloop); From patchwork Wed Nov 16 23:38:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118664wrr; Wed, 16 Nov 2022 15:43:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf4gklr3HNsGYl8r01Hs9W+ZLM3ZqiSp5eG/fseu1NdJ07/7ByjvfKBycGpq7mDaLW+L6O3R X-Received: by 2002:aa7:d446:0:b0:462:fb18:3b45 with SMTP id q6-20020aa7d446000000b00462fb183b45mr17306edr.243.1668642197814; Wed, 16 Nov 2022 15:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642197; cv=none; d=google.com; s=arc-20160816; b=eI28zduY2h8l1hsM2qjhLntXUcH5PlD3NeUkKQUntdzvcZ0HVlNvXVrZ7t1N8f/Fnh XadoLn4arb6JUFrQmc458AKvyrrR9O6a0yWgP7X3HVqCmrNJ3T7zeK/ttanUSx3g3Xnn v/hJ3oSmutBf9vNi1tPCOVs3sP3f+NQvDf94f2ggHBOerMIj02c9SdMdLUzNT9sMUTXa SluQ/sQo80wkoO7jRmhbjD6rr3SH4ApAHpvXsmYA5IYeQYyYWwUihqRYNnOD2huMY4u2 p5vbNZ64D3f6drymjMyhBTEjsKbfGOEOqG2vZn64O0Plg0eQbjekou/sKCP5c8DDg9xT gGDw== 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:sender :dkim-signature; bh=Kl5CORbtyeq6bL62pR/J7Hye71rdg9cfUGIiUjVmACc=; b=oauJBUHa76qP/7SAf9hzwAoZrgIXepKSMufOoRey8kRp1vas2CgspwnbiflTE4xyI8 djy6QBED/gxiw/vt3b0tnOJY8Qx8gute3vtxkgrVizv2XsOzUwEjVPhYg8xAKk9IrosJ lyO9ppMjcP13TfHFbytwrEPLw1G9iKKFu+jdxn0W19sGCYIU3vV335Y21JLdXVBKTtEJ rK75ikzRUTbLMkpY4YPS3ZJ4ng26ctk5szohiCF1CNHdCnWOMmx+x2cex18dqAjanMyX YtKNC1MJ7I0/XflXhG1x1BslRxXoUWXAnpch16UbwRgfkgrvHR1HWgfPXY/4ecW+iMDW WHsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lMoX6oWy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a056402349200b00462a87b0546si16882923edc.607.2022.11.16.15.42.54; Wed, 16 Nov 2022 15:43:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lMoX6oWy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234599AbiKPXjd (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234276AbiKPXjH (ORCPT ); Wed, 16 Nov 2022 18:39:07 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D25DB65E4B; Wed, 16 Nov 2022 15:39:06 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so3821034pjc.3; Wed, 16 Nov 2022 15:39:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Kl5CORbtyeq6bL62pR/J7Hye71rdg9cfUGIiUjVmACc=; b=lMoX6oWy3zqd7jliSssWvwdjFagbZKGt2pkPll3nIBB5To/tHcukd+z0XU7bbJvNh4 d+yfNHSU+LGHsQPFxKJRZBSe2NHNTAsHxNUPaOXTsu5yyRNKmoKYVGTgst2ybLU9bFHe TBU4O51yENG3q9dFooPwbmp8xf3LUTxOqfa6uu8CTHJKwXRQJsObHnU/ihmoqaowF8NP 3iMG2tXU4igHwrSS8S+h2coWlXBQF2NGl69NAaW4s3WlmRd1gakCKzeB/UGvWl05FpYY UYkj/jdIaeqIx0HJPhuK5r+VVqrG3O8K0Pujg1r6mN8unIx2uvFz1xH2MDZkwcjJ85o/ IU0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Kl5CORbtyeq6bL62pR/J7Hye71rdg9cfUGIiUjVmACc=; b=LSt48tO29jTFJZYfjqUHkQ+30qbKrlNq1kDQ92+ZGm0l6nhONFn1umQkpUwcES5yCF 3dCGzT6N6skaBZg+Y3NA1g134qL8yVTSDnNgWG0jhs3mx0F6izqGM4zdYb8Q4eIYY6fT d/5Wr9bQo51b/XnEBJaJYVTHQC0d41yttybuaZD6XkpwrUZcTlzVf9Xo+rku+NWSybs1 bPfOvAsy5OZUEOWRR5SK7ClZraNWP0Y9Pj75obu81MEdTg7D9kliJraU8YR3HLVy15Yv wL3Rsj9TpgfqwS6ac2wN50xtYjj2aSKD8CJmbiAWA4d9s9MZeSEnWaTCxINrXAYNFwtt 1aJQ== X-Gm-Message-State: ANoB5pmfxQoHvQS2qrW8OWlk6JLSCFk/wFgp2ea6ag1C8aKUvUYcW1sl l0E3dIRqnWPi7LMLb7oz7W4= X-Received: by 2002:a17:90a:6c25:b0:213:d1bc:9b74 with SMTP id x34-20020a17090a6c2500b00213d1bc9b74mr5798466pjj.229.1668641946124; Wed, 16 Nov 2022 15:39:06 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:05 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 06/12] perf test: Replace arm callgraph fp test workload with leafloop Date: Wed, 16 Nov 2022 15:38:48 -0800 Message-Id: <20221116233854.1596378-7-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698161267526373?= X-GMAIL-MSGID: =?utf-8?q?1749698161267526373?= So that it can get rid of requirement of a compiler. Reviewed-by: Leo Yan Tested-by: James Clark Signed-off-by: Namhyung Kim --- .../perf/tests/shell/test_arm_callgraph_fp.sh | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_callgraph_fp.sh b/tools/perf/tests/shell/test_arm_callgraph_fp.sh index ec108d45d3c6..e61d8deaa0c4 100755 --- a/tools/perf/tests/shell/test_arm_callgraph_fp.sh +++ b/tools/perf/tests/shell/test_arm_callgraph_fp.sh @@ -4,44 +4,16 @@ lscpu | grep -q "aarch64" || exit 2 -if ! [ -x "$(command -v cc)" ]; then - echo "failed: no compiler, install gcc" - exit 2 -fi - PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX) -TEST_PROGRAM_SOURCE=$(mktemp /tmp/test_program.XXXXX.c) -TEST_PROGRAM=$(mktemp /tmp/test_program.XXXXX) +TEST_PROGRAM="perf test -w leafloop" cleanup_files() { rm -f $PERF_DATA - rm -f $TEST_PROGRAM_SOURCE - rm -f $TEST_PROGRAM } trap cleanup_files exit term int -cat << EOF > $TEST_PROGRAM_SOURCE -int a = 0; -void leaf(void) { - for (;;) - a += a; -} -void parent(void) { - leaf(); -} -int main(void) { - parent(); - return 0; -} -EOF - -echo " + Compiling test program ($TEST_PROGRAM)..." - -CFLAGS="-g -O0 -fno-inline -fno-omit-frame-pointer" -cc $CFLAGS $TEST_PROGRAM_SOURCE -o $TEST_PROGRAM || exit 1 - # Add a 1 second delay to skip samples that are not in the leaf() function perf record -o $PERF_DATA --call-graph fp -e cycles//u -D 1000 --user-callchains -- $TEST_PROGRAM 2> /dev/null & PID=$! @@ -58,11 +30,11 @@ wait $PID # program # 728 leaf # 753 parent -# 76c main +# 76c leafloop # ... perf script -i $PERF_DATA -F comm,ip,sym | head -n4 perf script -i $PERF_DATA -F comm,ip,sym | head -n4 | \ awk '{ if ($2 != "") sym[i++] = $2 } END { if (sym[0] != "leaf" || sym[1] != "parent" || - sym[2] != "main") exit 1 }' + sym[2] != "leafloop") exit 1 }' From patchwork Wed Nov 16 23:38:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118627wrr; Wed, 16 Nov 2022 15:43:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5i7xQtkCnyFN7OlV4X0L3ftcAPFz4AKEV9x3kJ//pbVPC5gVuf/FjhB+a0EUmkLxD9LsSm X-Received: by 2002:a17:906:f2cf:b0:7ad:975f:b576 with SMTP id gz15-20020a170906f2cf00b007ad975fb576mr132728ejb.49.1668642189199; Wed, 16 Nov 2022 15:43:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642189; cv=none; d=google.com; s=arc-20160816; b=cCjDO7tB1KSe4WGOp8uvu4UvsXbKCJs/gFx7pjZ+6RnR9PyeAlI5H5gYV4I1xdxaLz HZtYOcVKrLOSilqGtfJ6QVgsPN7W+IqwFrvMmwfUVY0j6lcyxw4LV6KYZtjlo5VG1GRq bDh/o6yEH8uND6cSosTFeNRsUoHEbL727Sd6IjPKOrxk5PP8beDBfIgW4RTlkZ/QDVZ9 eQIxHv2Ikdssqih2FGGl6bdNTyqdv97fehqre298B0lXUpur3rP8zG17FT8i21csxULI qZujCSCg5C1C48RLzmSp1gkcITrVWeBAZ0GzV28Uib6LiX9JpcMmhpvHoW0Pc62HK6hn 4+Jw== 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:sender :dkim-signature; bh=TA+6dbtIStadvAuHvkrtYwI6bvKg5btHy1tHp0RwTqg=; b=ZFi1t132/pZrGLoZvxar5sgVfPcaAapLOUJNhYUz8kwHpNG8RpzNmuXhq6h2DELD/S Uh4fyEqOWekO+px1cV9N3k3d5Pfey3BLW++/wlLB3vmbO1CQ4/hWDNU8vgOjY0pcq1gN HDrS0cW1mL/gk3Q+KdiWJ+m7aKe/F9nUfjHkPhb7KQuAciQ+5sxlHK+p4JoLpMSjuwF3 kKD03+vjjE9PBwC8lvO1FnzXjNdj7jW1h/MQ+9UXYYz3RXJyVNEnBzUaWqk+PFhBP0A2 g2gl/0sxc646By/iZA6FYnsoUE8MHY+qCAeIaHpphAsSWnem//6XqRxJkuXMHCZijuPd AHNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HlsotV8a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq4-20020a170906d0c400b007abafd4d7d0si11964182ejb.702.2022.11.16.15.42.45; Wed, 16 Nov 2022 15:43:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HlsotV8a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234852AbiKPXj1 (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234379AbiKPXjI (ORCPT ); Wed, 16 Nov 2022 18:39:08 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A0DA45EFA; Wed, 16 Nov 2022 15:39:08 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id d59-20020a17090a6f4100b00213202d77e1so3852823pjk.2; Wed, 16 Nov 2022 15:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=TA+6dbtIStadvAuHvkrtYwI6bvKg5btHy1tHp0RwTqg=; b=HlsotV8aYsxQD2uYpIDy78RWOA0mzRu/W+zWyjxi3barQ6sK+PrklVvZwCCq//9Sqf 2QRwLW9mKrg7cPawjIgx+WjS8CBpEYZrnfkD3N6IkDmd3kmxeX63m25lEl1c+RlF354d tj/4oHywEqQtiGOj3Xmd9NQypUbG3JLFq0fxQ6918Z/FPslJN1JLMPk7x8NpYss9p4p9 pvzuO+6g8ms2JUU7fHeEKCQUOq5FuLfPr6lTYcJk1lnTZ62Kki+pTdiyC/cQZ+/Yee9G HnxgYcqxFQWzWKnUu2j0gfrwa8KL19IZ2Ihex65+MgRNDkzXMOZxmcOQnnDGNZqizgta P6zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TA+6dbtIStadvAuHvkrtYwI6bvKg5btHy1tHp0RwTqg=; b=x+q/tY5tWY1lfL5RxKyFamCXdiuJXzPXvNPbvYwy2BG2g8qBJPtG9b6cy/BsOwqR1d Xs0PqlOt5iXeJXZoXIJlySeGt3dV+Z/wKlaCil/roUud+0Cikr9oPJO7dpQMszUCuHet +DrKpz89bxOw6CQ4ia7BXyOJGC0R2ZCq+oanuTi6fKtRv0OgWd1zxSrDvYoHrVMY/nzp UwDfwkDkU0HnJSSv9B5wmbMC2s6TAVYs6NhJK+frSl4zYH3JORFBKg2m9pJTxRSa+rww NjROxbyFSqo5VWu+FnZiQaeNGIVayJdTpXAZAw0cleluwcsfR0FoywNrsyd/ebWHWhM6 gBsw== X-Gm-Message-State: ANoB5pmx0iUl4c8QC3uJ0N9MhL+VmrjPcyPPTI24vulzaXPBH1h3m539 gqdvWblSbtOWCqAGZvOsnd4= X-Received: by 2002:a17:90b:3c45:b0:20a:db08:8a8a with SMTP id pm5-20020a17090b3c4500b0020adb088a8amr5991480pjb.141.1668641947510; Wed, 16 Nov 2022 15:39:07 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:07 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 07/12] perf test: Add 'sqrtloop' test workload Date: Wed, 16 Nov 2022 15:38:49 -0800 Message-Id: <20221116233854.1596378-8-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698151816452424?= X-GMAIL-MSGID: =?utf-8?q?1749698151816452424?= The sqrtloop creates a child process to run an infinite loop calling sqrt() with rand(). This is needed for ARM SPE fork test. $ perf test -w sqrtloop It can take an optional argument to specify how long it will run in seconds (default: 1). Signed-off-by: Namhyung Kim --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 1 + tools/perf/tests/workloads/sqrtloop.c | 45 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 tools/perf/tests/workloads/sqrtloop.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 0ed5ac452f6e..9acb7a93eeb9 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -122,6 +122,7 @@ static struct test_workload *workloads[] = { &workload__noploop, &workload__thloop, &workload__leafloop, + &workload__sqrtloop, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 86804dd6452b..18c40319e67c 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -203,5 +203,6 @@ struct test_workload workload__##work = { \ DECLARE_WORKLOAD(noploop); DECLARE_WORKLOAD(thloop); DECLARE_WORKLOAD(leafloop); +DECLARE_WORKLOAD(sqrtloop); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index 631596bdb2b3..1ca95cb0fdb5 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -3,5 +3,6 @@ perf-y += noploop.o perf-y += thloop.o perf-y += leafloop.o +perf-y += sqrtloop.o CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer diff --git a/tools/perf/tests/workloads/sqrtloop.c b/tools/perf/tests/workloads/sqrtloop.c new file mode 100644 index 000000000000..1e44d541d737 --- /dev/null +++ b/tools/perf/tests/workloads/sqrtloop.c @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include +#include +#include +#include +#include "../tests.h" + +static volatile sig_atomic_t done; + +static void sighandler(int sig __maybe_unused) +{ + done = 1; +} + +static int __sqrtloop(int sec) +{ + signal(SIGALRM, sighandler); + alarm(sec); + + while (!done) + sqrt(rand()); + return 0; +} + +static int sqrtloop(int argc, const char **argv) +{ + int sec = 1; + + if (argc > 0) + sec = atoi(argv[0]); + + switch (fork()) { + case 0: + return __sqrtloop(sec); + case -1: + return -1; + default: + wait(NULL); + } + return 0; +} + +DEFINE_WORKLOAD(sqrtloop); From patchwork Wed Nov 16 23:38:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118697wrr; Wed, 16 Nov 2022 15:43:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf6295NfjA7g5gxPH+oLonmU2gbxs2SWZDKodf9J3j7XYDpdiKr82LWteXwngLoSHRIb6/6A X-Received: by 2002:a50:fb89:0:b0:461:ecca:e8a with SMTP id e9-20020a50fb89000000b00461ecca0e8amr36471edq.139.1668642206280; Wed, 16 Nov 2022 15:43:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642206; cv=none; d=google.com; s=arc-20160816; b=WBObTyLN+PcWKZG7Z7qAOUVHNLUJ2+kiYQp60cOfLyy8HKIpP8a8Bzq4oRPMNnFoyQ c+j+NTCdvrfIlKPvVrq/LxUUo9snHohfG3ypKPk5rcxah0idwVaEOF00zN6Arao85xAX 4DimV3K4NZUVZC9KAPWgaSSrNPLu5ehXqReNf8weu1DDO2ROqm5vZ30n5dEyydr2Djr5 jjNAfNqt2cP0dBRjPsmpF3PagC6FGSjC0WHm1sp1DDPOCAQUCZcDNndSgXeo2f5iAd7K ur70rjBK2cpwYq92Uuq/dDSO0uwQRejzuGi2zcJJWeWyNS+hb25j2Qwd2bdxFJ+7784d 0Eow== 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:sender :dkim-signature; bh=5B0JQCucRHYT7xdR8VvGZSXNFmNKxBu//apj1OM/otI=; b=uKp07wpC4NB2j9KYI/NLeq3D1+j1kLWB9PTE+/D1XjwKrFynXss83Kj2g8csFXIagW VBhul6rTSy8eHr+ADzud2p1a+Qj7ghS0jlBH7rzkQsd7T6mcggegC93YNRMuqw3rlMNc +jCJOw7yc5+IRueaOB/x+WpT7BoEFEXxyNoEnLeEsnqpewjA9agj2Pc51R43gGr+jzx6 PPgM9UA8L3GMv6bXTxioGGHlbLYodkMyXTmp7NwgE57oYvo77HY/eUF7Px/ZfEZNSy4x 4VmOk2e2HrzZzE1yiT8VWlwT2CBFpAo5X2c99Je8sQDpm2uf4fU3PLwEW2Q3t/2XMZQg 33bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RM9X4Zhu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z23-20020a17090665d700b007ad943d0608si12920869ejn.630.2022.11.16.15.43.02; Wed, 16 Nov 2022 15:43:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RM9X4Zhu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238829AbiKPXjm (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234083AbiKPXjS (ORCPT ); Wed, 16 Nov 2022 18:39:18 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BD5E5E9F3; Wed, 16 Nov 2022 15:39:09 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id n17so399578pgh.9; Wed, 16 Nov 2022 15:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=5B0JQCucRHYT7xdR8VvGZSXNFmNKxBu//apj1OM/otI=; b=RM9X4ZhuxQE0eTgHt6Bkzsehc3s28N9CD6mk3dzLOwMBSxOEFpVaMq2T1PaSydFzi4 uwQaIJR1oAqGr5m+NPxZKn8PdLgSZIUxDTYYEaPkv2AYdzUtnyGZ6bw7o4TSz194c3md NNJp0XaOJCghD+5VOA/a1SX/lRT/B1QrLvDNS5bg84DCfjEoMcVokjieODSY6d861ghY 6eJZJBD6fEs5ne+qj8ul9wzzrYQaC0Iob6Zpuv2Ppr8Nu+PgjsLFh04ncZPCrwa0GNLc Z3Hush6NSte7PvwFzenbk0Gr2YlyTIMI6jm1+RH9eL9K82ujF1p5RYJx7BxX2uZkvvGB dtew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5B0JQCucRHYT7xdR8VvGZSXNFmNKxBu//apj1OM/otI=; b=p4y1T8AgjvQD7CrrBA9WLYYMLBVfuYH5bSyddgKl1eLmN8Fxk2TcOClZHpHPMFrEU8 WEJTCSiXNC56T0JcPZ0fB5RZyyjg0Pgzlivm4I4mxaHjKjsw0m2vHc4bYLtyWiafUD2z DNr2+sTMiYAchZgRBzGOUPUv6LsbEQF/4FjcV2m+uXuUl/az0hKaZb9wWCVfOj+KhWCv JH6xS4t9zQ9U41ngTfzzceHyUQP8wx2GUIZDM+fD5rrZsmlanI5taYY7L+/BqAy26bDV aRC820djhBknfBYG7jNbtmELiiQ3+0AmpmaRyhC1vE2CKkeBucSiuws1Br3yPawzATtY JUMw== X-Gm-Message-State: ANoB5pl9k9+gAKUNR2bm+DYaFx0VbuC4hDdrL86P0C/aNCrgPbmz7qr4 2y/nfaAlapkd+48g/EIiNrU= X-Received: by 2002:a63:d611:0:b0:439:3ca9:94a with SMTP id q17-20020a63d611000000b004393ca9094amr22401064pgg.107.1668641948807; Wed, 16 Nov 2022 15:39:08 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:08 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 08/12] perf test: Replace arm spe fork test workload with sqrtloop Date: Wed, 16 Nov 2022 15:38:50 -0800 Message-Id: <20221116233854.1596378-9-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698170269926896?= X-GMAIL-MSGID: =?utf-8?q?1749698170269926896?= So that it can get rid of requirement of a compiler. I've also removed killall as it'll kill perf process now and run the test workload for 10 sec instead. Tested-by: Leo Yan Tested-by: James Clark Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/test_arm_spe_fork.sh | 44 +-------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_spe_fork.sh b/tools/perf/tests/shell/test_arm_spe_fork.sh index c920d3583d30..da810e1b2b9e 100755 --- a/tools/perf/tests/shell/test_arm_spe_fork.sh +++ b/tools/perf/tests/shell/test_arm_spe_fork.sh @@ -11,14 +11,7 @@ skip_if_no_arm_spe_event() { skip_if_no_arm_spe_event || exit 2 -# skip if there's no compiler -if ! [ -x "$(command -v cc)" ]; then - echo "failed: no compiler, install gcc" - exit 2 -fi - -TEST_PROGRAM_SOURCE=$(mktemp /tmp/__perf_test.program.XXXXX.c) -TEST_PROGRAM=$(mktemp /tmp/__perf_test.program.XXXXX) +TEST_PROGRAM="perf test -w sqrtloop 10" PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX) PERF_RECORD_LOG=$(mktemp /tmp/__perf_test.log.XXXXX) @@ -27,43 +20,10 @@ cleanup_files() echo "Cleaning up files..." rm -f ${PERF_RECORD_LOG} rm -f ${PERF_DATA} - rm -f ${TEST_PROGRAM_SOURCE} - rm -f ${TEST_PROGRAM} } trap cleanup_files exit term int -# compile test program -cat << EOF > $TEST_PROGRAM_SOURCE -#include -#include -#include -#include -#include - -int workload() { - while (1) - sqrt(rand()); - return 0; -} - -int main() { - switch (fork()) { - case 0: - return workload(); - case -1: - return 1; - default: - wait(NULL); - } - return 0; -} -EOF - -echo "Compiling test program..." -CFLAGS="-lm" -cc $TEST_PROGRAM_SOURCE $CFLAGS -o $TEST_PROGRAM || exit 1 - echo "Recording workload..." perf record -o ${PERF_DATA} -e arm_spe/period=65536/ -vvv -- $TEST_PROGRAM > ${PERF_RECORD_LOG} 2>&1 & PERFPID=$! @@ -78,8 +38,6 @@ echo Log lines after 1 second = $log1 kill $PERFPID wait $PERFPID -# test program may leave an orphan process running the workload -killall $(basename $TEST_PROGRAM) if [ "$log0" = "$log1" ]; then From patchwork Wed Nov 16 23:38:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118717wrr; Wed, 16 Nov 2022 15:43:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf6GrPrMFQ12sk2LPDUk7fQ2gjFO3HHeJuamMgZM5dwlHnx7K85CzNZ49SF0ZCnQRptDb+Be X-Received: by 2002:a17:907:bd5:b0:7ad:9ada:f32e with SMTP id ez21-20020a1709070bd500b007ad9adaf32emr75983ejc.591.1668642209640; Wed, 16 Nov 2022 15:43:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642209; cv=none; d=google.com; s=arc-20160816; b=GhzIhAAaUKtGfLOR8OplJiuSg12VG3iA+gYbxYfdDgjh0d1PDS+x4CT0mft/fNx+UH vTlFMWvMeJ/gwH5Lglqi7bGbNUAlJ6+AWLtWZCWNwU1BpT0wX7/iMN9hwU69tggNCw6W udQXIHoUhEpyHCl5L4gJ/Ff78qXPVbsNhGXxZrDcmLVeo8fJPn22Pe9Xw63HSIlfB2R4 +iMvyufRALQip/H5rVnEr/6gIv4dt6G9IkUFj543Lc+HDiNWH0qzw5vNiX2xTKIh9GYD l+dGelpPDVJTRgNErVK9wdz+kkzPZ2HdRACsNPlt8juzYjqOU4It1DXIhnyPh7FQ+4iH 97yQ== 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:sender :dkim-signature; bh=rrmrlQ/AAcwA49LE/YDY46PPOq6RVCXtH2b5XWXmDxM=; b=ICP01WkZyyHUXnuA6qtmStTYiBePu2IpWPgA+wixyr/4zy4jKQrdkWKpge20/qLRCV 3k3yAlJcRMWziMF7X5tpaTJCSn9l1b2ivwBCefBx/eoWVtbIKAD8aZSsZ72YccrHdV2R DRpNqO+V6lrQ7BubBjMi1AeEQB1nQXyiTNEUSrLg3pYrTVHWS+Xkd/Nd4o5Ekasdth5l LSeHY23LOKYq82/55jayRiwBOLCRWVNEpoPG7PVuyM6LXDa/EjaNhL7gfbAotFMWu0DM umtgNp9I1j98r0w9+d/GOhZ/UEBBVkNYB6KAhXR3j+gdKZFNFQgk3dtLT3kNTA6qhMMC uFLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="kZxKAA/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go32-20020a1709070da000b007ae2299a195si17660308ejc.815.2022.11.16.15.43.06; Wed, 16 Nov 2022 15:43:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="kZxKAA/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232804AbiKPXjr (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234561AbiKPXjS (ORCPT ); Wed, 16 Nov 2022 18:39:18 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9039169DE4; Wed, 16 Nov 2022 15:39:10 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id q1-20020a17090a750100b002139ec1e999so351264pjk.1; Wed, 16 Nov 2022 15:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=rrmrlQ/AAcwA49LE/YDY46PPOq6RVCXtH2b5XWXmDxM=; b=kZxKAA/bYyDmZeiqQWpjQlx5Kuapaak/srJrdnnSr34iHO7OOG4s2scDN/NggUyplA WnW0G9RfXpKUdZvaBl2at/8BHTuNprGrX3GMHM41HL6kTJLgV0gz8/yQzcPVIWDHoO6j o7BdNm4EQ0WSoKttavUuVT+ooYcZR22QWckd2FnvBU0PfQA5uw4OJuh2BtgUBQNMPLlb b9ECm+UifdukICwjg9xx4/5NKnjivUO2/VdlQgsQ0SDEDaInfmAokAtkynsPLa335h+I ONiO3suG2LF60BkuT2HADwVTcPkui5dNLk9BSxesH57tW3M8HS3nS35G9dIk+dIDn0u0 Kk0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rrmrlQ/AAcwA49LE/YDY46PPOq6RVCXtH2b5XWXmDxM=; b=U9nefKhMrqHTTgBgvW3q6dHMdQcPjI5MQOsu+lPQRr+b9WWCgxZmWQlSyToOLug339 /uxH7zTB/mP1MTuayH/s+OubvyYmNiN8pqkQvB3AebiM/SqW4DCqwT3bnCATM0SnA1eA nkUX5dG1qb82VWCwhFUeJi0atRH9/HBgRneTeuSCgNLP2kgCSkvAe/d9exqu6Vrmfczq TeGVWII02HWZ/0yJjpF0oRlDt4RGY5SPDQI1uJa9cs/UNMMinqIte5uDwGlxiHD2aOwx W/WMb6r7cDoZ2SAKy2GJAED0KpChQJMJp9uPMngO0Jx3tuygexfgk98+LcOkla0U7YhG t1Pg== X-Gm-Message-State: ANoB5pnjypEg348gOzyOeu6Kdzh8C1AKjj5jjBfP3xAf5hjZ6Wg0xboY abDkf2Djnb7zI9az02hSqCg= X-Received: by 2002:a17:902:8306:b0:187:31da:a27e with SMTP id bd6-20020a170902830600b0018731daa27emr72012plb.111.1668641950027; Wed, 16 Nov 2022 15:39:10 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:09 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 09/12] perf test: Add 'brstack' test workload Date: Wed, 16 Nov 2022 15:38:51 -0800 Message-Id: <20221116233854.1596378-10-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698173243643793?= X-GMAIL-MSGID: =?utf-8?q?1749698173243643793?= The brstack is to run different kinds of branches repeatedly. This is necessary for brstack test case to verify if it has correct branch info. $ perf test -w brstack I renamed the internal functions to have brstack_ prefix as it's too generic name. Signed-off-by: Namhyung Kim --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 2 ++ tools/perf/tests/workloads/brstack.c | 41 ++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 tools/perf/tests/workloads/brstack.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 9acb7a93eeb9..69fa56939309 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -123,6 +123,7 @@ static struct test_workload *workloads[] = { &workload__thloop, &workload__leafloop, &workload__sqrtloop, + &workload__brstack, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 18c40319e67c..dc96f59cac2e 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -204,5 +204,6 @@ DECLARE_WORKLOAD(noploop); DECLARE_WORKLOAD(thloop); DECLARE_WORKLOAD(leafloop); DECLARE_WORKLOAD(sqrtloop); +DECLARE_WORKLOAD(brstack); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index 1ca95cb0fdb5..c933cdcf91d1 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -4,5 +4,7 @@ perf-y += noploop.o perf-y += thloop.o perf-y += leafloop.o perf-y += sqrtloop.o +perf-y += brstack.o CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer +CFLAGS_brstack.o = -g -O0 -fno-inline diff --git a/tools/perf/tests/workloads/brstack.c b/tools/perf/tests/workloads/brstack.c new file mode 100644 index 000000000000..cd0386d58f97 --- /dev/null +++ b/tools/perf/tests/workloads/brstack.c @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include "../tests.h" + + +#define BENCH_RUNS 999999 + +static volatile int cnt; + +static void brstack_bar(void) { +} /* return */ + +static void brstack_foo(void) { + brstack_bar(); /* call */ +} /* return */ + +static void brstack_bench(void) { + void (*brstack_foo_ind)(void) = brstack_foo; + + if ((cnt++) % 3) /* branch (cond) */ + brstack_foo(); /* call */ + brstack_bar(); /* call */ + brstack_foo_ind(); /* call (ind) */ +} + +static int brstack(int argc, const char **argv) +{ + int num_loops = BENCH_RUNS; + + if (argc > 0) + num_loops = atoi(argv[0]); + + while (1) { + if ((cnt++) > num_loops) + break; + brstack_bench();/* call */ + } /* branch (uncond) */ + return 0; +} + +DEFINE_WORKLOAD(brstack); From patchwork Wed Nov 16 23:38:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118751wrr; Wed, 16 Nov 2022 15:43:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Wo0pUxC5b5vv+eS5ONX9DcQmN/R/h2T/FOIfWBoSp+vKXEaxtqMgFYO8ymzJrbNvQQYYy X-Received: by 2002:aa7:dd1a:0:b0:461:c2a4:c419 with SMTP id i26-20020aa7dd1a000000b00461c2a4c419mr20553223edv.399.1668642216999; Wed, 16 Nov 2022 15:43:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642216; cv=none; d=google.com; s=arc-20160816; b=kabKcU0KXgXbgr7PwLnxvJ2aPrMmizLjTX/1W6qrx7fxQgT9MEbW6/ZHBF2ah/NWYI XQy4mUY5PV+JWrZXLtCAJBeaVFofKk91JpSXf9oI/ErCKE3iNOOJONSrLTDxOMN8xjqm k24x2Dc0Dacl1E/qN/2BAmr61rNHtLfMcld2jP64EbY4aKDZn7RbYLyHu0kuB4CbzCMW a8aBeIo5s0D2jll/P6a/eGlZWeKtP4zNBuxSOqUoYUiYO1aXicDaTzzhiuVY7c+nNW9H rYQoDI0BIUx+lXb0X/hg2JEBUKy4DwOq3UrgdiMOQ+GxC8dWVvhb8TkoSVkvFNId0NE6 Hr8g== 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:sender :dkim-signature; bh=V1CvADQIw4wqzAoDn42X+sYR3xHbApFLyuTcEFkNEC0=; b=lddQmm4EA8cJdoXB9peglUaNBrCdnHJTgBVcNwS9iCHeixbx/hB0t1JnJo3jDUaFg8 UU1Vxj0JfB42yloqaF/tU8774q/KI4zOOCOje/IbfTPPX+Z6rpNUT5f4um8ga6qsGFoh rUk72AMbtwo9MQt/De1K6znA3P9mzT0T56s6MRl6VoYkHcJHV9zmJygM4oZFqO5ojSA7 qrqXPRCkyRFHrsyQ84k8JFNFhslfeavsLHnVT3wQpkKHByPBODdoXu6rrKTMATKfpuxW Cx5qJtYnPpOHTpt5JSJa5fFliYZfIMi4xokCAOzOrpW/gaRG2NA2HdoB08oJxXjbQMYq pfOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="UYmx1u/g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a056402084f00b004595af54eacsi17765501edz.226.2022.11.16.15.43.13; Wed, 16 Nov 2022 15:43:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="UYmx1u/g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234439AbiKPXjv (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234616AbiKPXjS (ORCPT ); Wed, 16 Nov 2022 18:39:18 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52186A689; Wed, 16 Nov 2022 15:39:11 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id s196so428108pgs.3; Wed, 16 Nov 2022 15:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=V1CvADQIw4wqzAoDn42X+sYR3xHbApFLyuTcEFkNEC0=; b=UYmx1u/g2Ycc3G++I+M/G5bolyXat0/Z3PzM0edwmbNJwMulmzMCxcAv8vGIaJbVu1 lV9AUP79Zzmu7VTUNmdD4oqDDodVbu8J2hU5Lh+DElo16WZt7ymuRB/7W518Nd/7wmaG /WHeYlnknOH0fKAEN8os+WnxY7lXh8UH+e5GECRnw/f4+K7GPWJbGcz5vN1n2UeJdx3N m9KG8QuF0sqhhoOto6bC48VU1WLimZMm21Bj+ImfrBci/qQsFavqGEjsAzRFNGr0+bTA rzIu3ZnmbqG5rzSFlreapE2tZoGRF/z8DnNDispS6CBj2n6TCrLx5YckxdP7ugCfnawP 7v7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=V1CvADQIw4wqzAoDn42X+sYR3xHbApFLyuTcEFkNEC0=; b=N6jSpxIhmvuPifVPWT8DEjH2mjCBwuVzP9XkdT/L0zvXSIQReQ7masc+1tUK74PXD5 sCGlee/L4HML9k0srJN4oN1MBT8eu8z5uLh/E4NJbYYoK/+fXy1D0jjc601NAAfLCIVg S6MSC1Hk1FmtBRwr+H3zgR/LwFr6uCC3nmm2d216aRVXt0zRp8UaHQiw1R3Qtgmhf4/c ywXiXGheSANKWFyhlbNhNyDKXIooZRj7zfgrGK2n11n2fPeo/ZVg2VFddBseILT3JoWk Idbw85/Ter3w1j0dVgTv4J8bBQfjestFQQDchCzo2fRWNwz+9HNGYOrJYxJiqoDqwhuj q8QA== X-Gm-Message-State: ANoB5pnBgB/9rp9+K4ywa9HaWoWG8WmpnkgTrooq5k4lu3yIwMO1VGLm QS3f0ZWlIUTesOm//1f03wA= X-Received: by 2002:a63:5242:0:b0:46b:3c3d:f618 with SMTP id s2-20020a635242000000b0046b3c3df618mr22038542pgl.423.1668641951283; Wed, 16 Nov 2022 15:39:11 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:10 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 10/12] perf test: Replace brstack test workload Date: Wed, 16 Nov 2022 15:38:52 -0800 Message-Id: <20221116233854.1596378-11-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698181655800370?= X-GMAIL-MSGID: =?utf-8?q?1749698181655800370?= So that it can get rid of requirement of a compiler. Also rename the symbols to match with the perf test workload. Acked-by: German Gomez Tested-by: James Clark Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/test_brstack.sh | 66 +++++--------------------- 1 file changed, 12 insertions(+), 54 deletions(-) diff --git a/tools/perf/tests/shell/test_brstack.sh b/tools/perf/tests/shell/test_brstack.sh index d7ff5c4b4da4..5856639b565b 100755 --- a/tools/perf/tests/shell/test_brstack.sh +++ b/tools/perf/tests/shell/test_brstack.sh @@ -4,13 +4,6 @@ # SPDX-License-Identifier: GPL-2.0 # German Gomez , 2022 -# we need a C compiler to build the test programs -# so bail if none is found -if ! [ -x "$(command -v cc)" ]; then - echo "failed: no compiler, install gcc" - exit 2 -fi - # skip the test if the hardware doesn't support branch stack sampling # and if the architecture doesn't support filter types: any,save_type,u if ! perf record -o- --no-buildid --branch-filter any,save_type,u -- true > /dev/null 2>&1 ; then @@ -19,6 +12,7 @@ if ! perf record -o- --no-buildid --branch-filter any,save_type,u -- true > /dev fi TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX) +TESTPROG="perf test -w brstack" cleanup() { rm -rf $TMPDIR @@ -26,57 +20,24 @@ cleanup() { trap cleanup exit term int -gen_test_program() { - # generate test program - cat << EOF > $1 -#define BENCH_RUNS 999999 -int cnt; -void bar(void) { -} /* return */ -void foo(void) { - bar(); /* call */ -} /* return */ -void bench(void) { - void (*foo_ind)(void) = foo; - if ((cnt++) % 3) /* branch (cond) */ - foo(); /* call */ - bar(); /* call */ - foo_ind(); /* call (ind) */ -} -int main(void) -{ - int cnt = 0; - while (1) { - if ((cnt++) > BENCH_RUNS) - break; - bench(); /* call */ - } /* branch (uncond) */ - return 0; -} -EOF -} - test_user_branches() { echo "Testing user branch stack sampling" - gen_test_program "$TEMPDIR/program.c" - cc -fno-inline -g "$TEMPDIR/program.c" -o $TMPDIR/a.out - - perf record -o $TMPDIR/perf.data --branch-filter any,save_type,u -- $TMPDIR/a.out > /dev/null 2>&1 + perf record -o $TMPDIR/perf.data --branch-filter any,save_type,u -- ${TESTPROG} > /dev/null 2>&1 perf script -i $TMPDIR/perf.data --fields brstacksym | xargs -n1 > $TMPDIR/perf.script # example of branch entries: - # foo+0x14/bar+0x40/P/-/-/0/CALL + # brstack_foo+0x14/brstack_bar+0x40/P/-/-/0/CALL set -x - egrep -m1 "^bench\+[^ ]*/foo\+[^ ]*/IND_CALL$" $TMPDIR/perf.script - egrep -m1 "^foo\+[^ ]*/bar\+[^ ]*/CALL$" $TMPDIR/perf.script - egrep -m1 "^bench\+[^ ]*/foo\+[^ ]*/CALL$" $TMPDIR/perf.script - egrep -m1 "^bench\+[^ ]*/bar\+[^ ]*/CALL$" $TMPDIR/perf.script - egrep -m1 "^bar\+[^ ]*/foo\+[^ ]*/RET$" $TMPDIR/perf.script - egrep -m1 "^foo\+[^ ]*/bench\+[^ ]*/RET$" $TMPDIR/perf.script - egrep -m1 "^bench\+[^ ]*/bench\+[^ ]*/COND$" $TMPDIR/perf.script - egrep -m1 "^main\+[^ ]*/main\+[^ ]*/UNCOND$" $TMPDIR/perf.script + egrep -m1 "^brstack_bench\+[^ ]*/brstack_foo\+[^ ]*/IND_CALL$" $TMPDIR/perf.script + egrep -m1 "^brstack_foo\+[^ ]*/brstack_bar\+[^ ]*/CALL$" $TMPDIR/perf.script + egrep -m1 "^brstack_bench\+[^ ]*/brstack_foo\+[^ ]*/CALL$" $TMPDIR/perf.script + egrep -m1 "^brstack_bench\+[^ ]*/brstack_bar\+[^ ]*/CALL$" $TMPDIR/perf.script + egrep -m1 "^brstack_bar\+[^ ]*/brstack_foo\+[^ ]*/RET$" $TMPDIR/perf.script + egrep -m1 "^brstack_foo\+[^ ]*/brstack_bench\+[^ ]*/RET$" $TMPDIR/perf.script + egrep -m1 "^brstack_bench\+[^ ]*/brstack_bench\+[^ ]*/COND$" $TMPDIR/perf.script + egrep -m1 "^brstack\+[^ ]*/brstack\+[^ ]*/UNCOND$" $TMPDIR/perf.script set +x # some branch types are still not being tested: @@ -91,10 +52,7 @@ test_filter() { echo "Testing branch stack filtering permutation ($filter,$expect)" - gen_test_program "$TEMPDIR/program.c" - cc -fno-inline -g "$TEMPDIR/program.c" -o $TMPDIR/a.out - - perf record -o $TMPDIR/perf.data --branch-filter $filter,save_type,u -- $TMPDIR/a.out > /dev/null 2>&1 + perf record -o $TMPDIR/perf.data --branch-filter $filter,save_type,u -- ${TESTPROG} > /dev/null 2>&1 perf script -i $TMPDIR/perf.data --fields brstack | xargs -n1 > $TMPDIR/perf.script # fail if we find any branch type that doesn't match any of the expected ones From patchwork Wed Nov 16 23:38:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118765wrr; Wed, 16 Nov 2022 15:43:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf62Le3sqvOvuQlYTsvdFeMHFdcBM7UDPtUpkSy9kuuUfQZvGnlLETdWn+G8H2KPm26lKVvq X-Received: by 2002:a17:906:5a61:b0:79e:9d9b:d41f with SMTP id my33-20020a1709065a6100b0079e9d9bd41fmr97953ejc.404.1668642221200; Wed, 16 Nov 2022 15:43:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642221; cv=none; d=google.com; s=arc-20160816; b=kHdHNpgTKjOSBha0/1EW/Vyr8a1G2ELWJJ1l0pfvvhvKoyUGaryRgFU6g//PDnxcGf Ls0kmw5c4uIVz3LPrkILY96ObqTHjshCf9nIL8BhGjoRzi/+R3qwTd/4lY+WHbstcIqJ 9pPPdrAaY3BqbFJ1NvsptzHuoT+qKBouvizYnIVLe1q3X3kjxZrxg+3i39TW8k6jKBpj /k9KbmKBMqBak+kIM3wQpEA52inmXTKeOqWvJJLqIIrpw5mNLbjwAOG8w+GHX9fhdNw3 0b8Ll6rpKIGdVRklnL9+p3t0ElxIY6o/3M+2xolvGYlBsmvXMoKK3tvzAL4KTp6Au+WH /KOA== 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:sender :dkim-signature; bh=gJqneQ9QTXZ2Nr4v/IOHJnQH13z85d8cJMd1dVW/GqE=; b=WY6GuIXW3lhiIaJsS+XrJLqWtlqirkyXBWVzTOULwvnkeUiOdiX1hqgC2KBpSTLLbu nBb6582Zf6JjhAdKvrcOh+ZY1YwFAIrfGF8+PPAaYGOHZhIE+M9BuSUqy+B82EhbXIH3 u45Q2+CTH4P+Ov4IRMDC+LT+TFO96+KVfIbts8e2ASIv/AAnYBF7muQY/6sSGwi/xaYd jAmTr4S9c3OokaX5Zk1kpxO1OduB/95fGkQ7PPA4/NeJXVUfUK9TtX/fEY8J32ceSpBD mhZ5XB6G5f65gsTbdTx7mOw18tUr8KhMX4vzuOGcUsXcyNqRsGUHuz6rjDYUlHbV+/+/ 9Rmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WxKKwD9A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gf14-20020a170906e20e00b0078e54eda758si7806133ejb.611.2022.11.16.15.43.18; Wed, 16 Nov 2022 15:43:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WxKKwD9A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238686AbiKPXj5 (ORCPT + 99 others); Wed, 16 Nov 2022 18:39:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234650AbiKPXjS (ORCPT ); Wed, 16 Nov 2022 18:39:18 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E5BA6A763; Wed, 16 Nov 2022 15:39:13 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id u8-20020a17090a5e4800b002106dcdd4a0so3865252pji.1; Wed, 16 Nov 2022 15:39:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=gJqneQ9QTXZ2Nr4v/IOHJnQH13z85d8cJMd1dVW/GqE=; b=WxKKwD9AP6JGdF8rPdym+94KFDGwSvA94zdVTpP+ka2zrbKN9gWpbo85Qu5kRRj2NK 8n+XifsJRDR+qhtLj4mtLEvSBldPeVCWTA6YBVpy3Xl6kp2U5E6NDEoCG5miB4sfHVL/ rAUBWLha9hBy1yw3qD2QIy5nArSHWW1BcRwniGjebCpvnDVc56vFjmTFBF5Tm8NIxxHi SJUM28Y15G8CsbP0DdfxJ6FJ9L0piqHPDz2Q29+Zib9m1B/VZxqKRborhxpJWV0a8xUz i+enn1tFDgSXcO9whAVyT9Yal9vQWakSCVATDf9zwyLaiFQUxeWf6dBNadPAMxMZwMci TJrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gJqneQ9QTXZ2Nr4v/IOHJnQH13z85d8cJMd1dVW/GqE=; b=ej5OJrspps2UddjZ4dzb1ZZHpwrYKB6NWR26Zdk5wEBSPV6sL3bkGjEzApoqe2ndQZ Kr/Os2uT5Fg132gF9nf+5X5HK3lQdbZ2Yxnh8+bo1UiISY7RynhQVE5uMlL19RgKXx15 zI1wTdk6vhqy3RdLL0/i866NrSqPnmpiNVsV41Q2hlYq3MZXLkoJsOgUS6Am4SqOOxDE e5str05iddQqLugYlARlaABsqK5ABrMBBYyTdjnpVG9flj2e6v5XYWnP40r0OhrG3Emx ZcnkZwATLdEwXsdrBHQHWQ7EW1+pEjOAvoSMyt/mLDAVqLpiV5XS4cMXQmax9nNuuUDC o76A== X-Gm-Message-State: ANoB5pn1QdTdOHLn5VUNrCm4059TdfOwVWl059JVBFz2p0u46I38ZLJL fZcWT4fVbnSJSml0dgdbLfo= X-Received: by 2002:a17:902:820b:b0:186:b3cb:3b85 with SMTP id x11-20020a170902820b00b00186b3cb3b85mr105421pln.96.1668641952542; Wed, 16 Nov 2022 15:39:12 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:12 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 11/12] perf test: Add 'datasym' test workload Date: Wed, 16 Nov 2022 15:38:53 -0800 Message-Id: <20221116233854.1596378-12-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698185736419508?= X-GMAIL-MSGID: =?utf-8?q?1749698185736419508?= The datasym workload is to check if perf mem command gets the data addresses precisely. This is needed for data symbol test. $ perf test -w datasym I had to keep the buf1 in the data section, otherwise it could end up in the BSS and was mmaped as a separate //anon region, then it was not symbolized at all. It needs to be fixed separately. Signed-off-by: Namhyung Kim --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 2 ++ tools/perf/tests/workloads/datasym.c | 24 ++++++++++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 tools/perf/tests/workloads/datasym.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 69fa56939309..4c6ae59a4dfd 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -124,6 +124,7 @@ static struct test_workload *workloads[] = { &workload__leafloop, &workload__sqrtloop, &workload__brstack, + &workload__datasym, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index dc96f59cac2e..e15f24cfc909 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -205,5 +205,6 @@ DECLARE_WORKLOAD(thloop); DECLARE_WORKLOAD(leafloop); DECLARE_WORKLOAD(sqrtloop); DECLARE_WORKLOAD(brstack); +DECLARE_WORKLOAD(datasym); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index c933cdcf91d1..ec3cb10c52ae 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -5,6 +5,8 @@ perf-y += thloop.o perf-y += leafloop.o perf-y += sqrtloop.o perf-y += brstack.o +perf-y += datasym.o CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer CFLAGS_brstack.o = -g -O0 -fno-inline +CFLAGS_datasym.o = -g -O0 -fno-inline diff --git a/tools/perf/tests/workloads/datasym.c b/tools/perf/tests/workloads/datasym.c new file mode 100644 index 000000000000..ddd40bc63448 --- /dev/null +++ b/tools/perf/tests/workloads/datasym.c @@ -0,0 +1,24 @@ +#include +#include "../tests.h" + +typedef struct _buf { + char data1; + char reserved[55]; + char data2; +} buf __attribute__((aligned(64))); + +static buf buf1 = { + /* to have this in the data section */ + .reserved[0] = 1, +}; + +static int datasym(int argc __maybe_unused, const char **argv __maybe_unused) +{ + for (;;) { + buf1.data1++; + buf1.data2 += buf1.data1; + } + return 0; +} + +DEFINE_WORKLOAD(datasym); From patchwork Wed Nov 16 23:38:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 21332 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118158wrr; Wed, 16 Nov 2022 15:42:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf42FnwpLb3i8GqgIhrCtRcSinMR33qsTLmFdtusRPGTVaqsuS+lkzv/tQvCo2+9ftsFg0+2 X-Received: by 2002:a17:907:1dda:b0:7ac:db50:90ed with SMTP id og26-20020a1709071dda00b007acdb5090edmr85277ejc.487.1668642122075; Wed, 16 Nov 2022 15:42:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642122; cv=none; d=google.com; s=arc-20160816; b=szCofW9Lnl7oqgdOiVbOcp1EhC5aJetd2xpQpaQREzylcrRj/WaNJ1xeiVe21cSW2B Yy8jeUEIR2WbsVLQvqzLWFUEYX1AjtTnnxlbe/2FJGizc25rSrd4f/a2buAa4RYTFX1m ESaC6+93Rw7g9tq7vSRjd+qffkSGbMc3D6zytfh4Fdyqqb1YXqMUnaLrQqzAeDC2yo/R dFqysSDY5JcxeOOI4gQzqIptO6bbPiJRtNmWAy3GNELESqHQ7K0pxlsCXvxFvPdeb7hL 3ciBda7Edrd7bdYVjQfGHaLufF110I4atC6Jj/H7pAq9McsBp1K+nrvqMt/tEW3nEwbC hLPw== 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:sender :dkim-signature; bh=y+MBjHLXrFB++GMwQ9Qm9dxDqVPjyqYA8sAvvb3VHA8=; b=uRvuNIZc1Q74ZXcsLKyFcSBWjcdyyQ7OsbdDZ0wZnMea0iPSCol/BBadyUzuTbLzOj o6gs7B7YHrISmGnSaB3b7ve0xOuQxoaZ/fNHXhsayENj8H51djeCAsyXENs5Zcs5XzRC KX+/fqdOqJakjOGVdzLLigazolPKa3IEw9lM4JnKCeMhFRtGwanQHlJS4lVn2Yp3k7iX i1HJha8EarhB41peN5jZ9sZw2NjOGpPHLqdY71lMaHTZXJXd5VT9lFEOj+MGXAt1zcAL D2W33l+4EHpuMOtk4UAZFsfQVSaFqqze85VGfwNlN4TX2X/E/7d/2yUaGwErrysSOplJ ljKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KO5GR2cR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb24-20020a1709077e9800b0078e1a6fbe12si17843173ejc.16.2022.11.16.15.41.39; Wed, 16 Nov 2022 15:42:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KO5GR2cR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233089AbiKPXkA (ORCPT + 99 others); Wed, 16 Nov 2022 18:40:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233893AbiKPXjV (ORCPT ); Wed, 16 Nov 2022 18:39:21 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7582E6AEDE; Wed, 16 Nov 2022 15:39:14 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id h14so105517pjv.4; Wed, 16 Nov 2022 15:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=y+MBjHLXrFB++GMwQ9Qm9dxDqVPjyqYA8sAvvb3VHA8=; b=KO5GR2cRgLhvf8OFPJYQf72Kn7B46DuZgskYrT1iCiFw/RVDAkik+Px1eM3W040SeT 0OfNnY+zr1G/FyTiOSN01zXMupTNaKoPplxN4tgDx1xaA3U9rI1pPSaa/+sFH10UOinu bsIjh7005H0PgciKL7SId0FARe/GYKuhLB+l8rJ3Llys8WwVk610mxKoFCHzQXEwqk8B xJwSliW7wOR8DpsylRCRDJtHSCkVD6tBtgDLX5cHLTta/UDAXhNTMgOmXx8l+u29fqLL CsQmmis9KgUrMiqC8joDavEzRljKyUkoMnFD8W6J8GmxSAIyuAR9A63m43RskhPoXZ8N 3zzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=y+MBjHLXrFB++GMwQ9Qm9dxDqVPjyqYA8sAvvb3VHA8=; b=jIaavhVKVL1GPVLhBUI8x8vPVOblAjYSEAh2JV3NU44mmgY1kKBiXXZVt1IuJx3BFS +UTNNsTw2uDWzv41apQjjf1eiAB5x9xTLUc0dlTIkWXq2PaR7/cnoF06S2eU72GqJN23 gRo6DcBpAvxU2yY+K65jO1M0a5acNA8XdrOFC9TlMihl8cajWZ2OetPchOPwBxvvIXSe Rq0FYvKgqB1JJWay73Wfa6/o9d4hEw7lXdx8WiQafiFCgiXei7Bqvx1+b77A61zhSbXD NbgsxXBBa2d/dTS8CQA7wbfSgw1bIAzopTsq/J0XGNgiVmxgR8DBjlXL0jWHbXStbZ37 4Hlg== X-Gm-Message-State: ANoB5pkB4mL8BRmbpwkqye3VM6Xctx2Kb35BCxwS6E0sU/iPYBCyQwqY czBAEX0l7uxb75iVvVzHm5Q= X-Received: by 2002:a17:902:f383:b0:188:4f86:e4d5 with SMTP id f3-20020a170902f38300b001884f86e4d5mr247842ple.16.1668641953822; Wed, 16 Nov 2022 15:39:13 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:13 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 12/12] perf test: Replace data symbol test workload with datasym Date: Wed, 16 Nov 2022 15:38:54 -0800 Message-Id: <20221116233854.1596378-13-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698081760866868?= X-GMAIL-MSGID: =?utf-8?q?1749698081760866868?= So that it can get rid of requirement of a compiler. $ sudo ./perf test -v 109 109: Test data symbol : --- start --- test child forked, pid 844526 Recording workload... [ perf record: Woken up 2 times to write data ] [ perf record: Captured and wrote 0.354 MB /tmp/__perf_test.perf.data.GFeZO (4847 samples) ] Cleaning up files... test child finished with 0 ---- end ---- Test data symbol: Ok Cc: Leo Yan Tested-by: James Clark Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/test_data_symbol.sh | 29 +--------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/tools/perf/tests/shell/test_data_symbol.sh b/tools/perf/tests/shell/test_data_symbol.sh index cd6eb54d235d..d871e6c743ef 100755 --- a/tools/perf/tests/shell/test_data_symbol.sh +++ b/tools/perf/tests/shell/test_data_symbol.sh @@ -11,13 +11,7 @@ skip_if_no_mem_event() { skip_if_no_mem_event || exit 2 -# skip if there's no compiler -if ! [ -x "$(command -v cc)" ]; then - echo "skip: no compiler, install gcc" - exit 2 -fi - -TEST_PROGRAM=$(mktemp /tmp/__perf_test.program.XXXXX) +TEST_PROGRAM="perf test -w datasym" PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX) check_result() { @@ -45,31 +39,10 @@ cleanup_files() { echo "Cleaning up files..." rm -f ${PERF_DATA} - rm -f ${TEST_PROGRAM} } trap cleanup_files exit term int -# compile test program -echo "Compiling test program..." -cat << EOF | cc -o ${TEST_PROGRAM} -x c - -typedef struct _buf { - char data1; - char reserved[55]; - char data2; -} buf __attribute__((aligned(64))); - -static buf buf1; - -int main(void) { - for (;;) { - buf1.data1++; - buf1.data2 += buf1.data1; - } - return 0; -} -EOF - echo "Recording workload..." # perf mem/c2c internally uses IBS PMU on AMD CPU which doesn't support