From patchwork Wed Nov 9 17:46:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp475750wru; Wed, 9 Nov 2022 09:52:26 -0800 (PST) X-Google-Smtp-Source: AMsMyM5LuoOytd//lC4zrrxvHBxlJFPtTvoMTJ6oQoY3RnvlRHt/xOhcVnQlbqkgS5KL6Hll0voV X-Received: by 2002:a17:907:75f7:b0:7ad:bc7e:3fb6 with SMTP id jz23-20020a17090775f700b007adbc7e3fb6mr53304483ejc.550.1668016345923; Wed, 09 Nov 2022 09:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016345; cv=none; d=google.com; s=arc-20160816; b=bKFyzYDb99f4cnYDmGwMBKBIxMHcbm7qzgL96YmgjQYzdO8BTF6t6l1yByN/e7HZdW UbsCnuud/l1n4L9EecDjVphbAc0To74b0Y4dx6XU/uUe0l0E06+cu6zaGi7u5L0u5MKK 8+YZJL27+aA+tBNrVh9NQVg+bBoRVt1fvsh2g28mi5gOGio6/AqtVJ+6NkDUyKysh2aJ CAc7ARk/q1CpNXMB2Z5IL5z3oTO8jsXqRRw7x9+OcpVzGa7qAnSLnLczadqghumnBh3+ qVZpySJEDgFLqfq7ul8SZ9FQQrtlO/kyDdXm/2QZYV+TI+4iOwu9f21jDfHHuwWULXqB tLpg== 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=ZI6aYo9FIIiIY/a14tjDWqXvcVQQ43A/4K5Y/rrZYfc=; b=xRrbbLAVsTb1OjVprQbLDuWHI+5HU0WTlkIPKRHA0Pq2VhufulOiuDLA5dlcKVILxS SiXgP3CC944O9L/I7IKEEVj8XWRc907o6Q/EGHus7XlPp5NpXW+TVx57UBdAfjZ7uWgi BGwEwjvVcSurRvRJtG1nj5XMNDzvYbWYHneNPgW73nm05dvnBrDFemsyRDlawtXxZtMv aQYP16TEfVrUeA+5x301DFa07ODjZrX8tng9ixkIVzsqSSMHZvbvM/LXS4eWRYpRBuwY fGmoD5tzttBIChUNTUXlFF0q2sIxifvAlkZF6qFr+YRBDndkNJyax5VjONJlRU8q4Csa qcfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="F9E/Ojqs"; 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 b14-20020a056402084e00b00461e5618305si19188767edz.280.2022.11.09.09.52.02; Wed, 09 Nov 2022 09:52:25 -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="F9E/Ojqs"; 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 S229516AbiKIRqp (ORCPT + 99 others); Wed, 9 Nov 2022 12:46:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbiKIRqk (ORCPT ); Wed, 9 Nov 2022 12:46:40 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8104564F9; Wed, 9 Nov 2022 09:46:39 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id c2so17753997plz.11; Wed, 09 Nov 2022 09:46:39 -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=ZI6aYo9FIIiIY/a14tjDWqXvcVQQ43A/4K5Y/rrZYfc=; b=F9E/OjqspCVLP2Y8q39sBB1wbThQQJpuE3/xdKc1ijYnIth0Kw3KkXbT5D9sHfztW/ CXDqgugI/NJQMUtVn6gwRlq7ASFWNUy+MUrwXx8Qr0IG6xwRbdKgPxKbZTi4FKnNq1do v0sWqq8qyJliUQCqO/cammVbhbysfxjgVGvZAKPsgpH0DJ8KSm/7/95llofx2QHO2Abn xDN5zl8ZEE3e+yCTgPOuj95HUqsNpID4CpKPPcLfyS6D/8gbDyoyfMyQjkYlTd2XnN6l 0QItIWO8kEElM+DsCHAGPwZttnoYsmq3sbo3lUizzOUUrGMDxPJ+arofjsl3JE2J8H7M 7hsg== 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=ZI6aYo9FIIiIY/a14tjDWqXvcVQQ43A/4K5Y/rrZYfc=; b=64YUhDiTMhXw0HNs9J2ABUV7fqSrXLHiuOvBHr6VUebjxsaznMfsSgVgvXCn/YtG/+ zQBryPxmdV618vjF4/6wbtX6lqC0rRtiK/4Xe1buDAPk3TiysZuFNxnRP2JRXNQlhylC ruNiRcF7k0Rcjlx+EKwzryrphyDdjDkmKhE7Wfn+Fff6+uCmdyhbW/jCIepvz5S0J0Vq d29YRJHKUNOL4yxGVDt27LoRDpx1QSAfSi293tq9zAQ0Miz+VyxP2YS6MDv+tMAcEApC RaSyWlqMCqvwP190JlaJBF5SrmU0fnXWksnAeJn40xKP5RBwPHaO/YxI6bKkE+KfjvW9 S6OA== X-Gm-Message-State: ACrzQf23CsCJAWsdQpZuA5hquXptTI+exvMQ3kz5LN5GpaliS65O1zuG xpNuHvMMilpAg7yCGcmMXhY= X-Received: by 2002:a17:90b:384e:b0:213:7c41:1018 with SMTP id nl14-20020a17090b384e00b002137c411018mr64623918pjb.63.1668015999046; Wed, 09 Nov 2022 09:46:39 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:38 -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 Subject: [PATCH 01/12] perf test: Add -w/--workload option Date: Wed, 9 Nov 2022 09:46:24 -0800 Message-Id: <20221109174635.859406-2-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041907807961744?= X-GMAIL-MSGID: =?utf-8?q?1749041907807961744?= 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..9e4d8d024259 --- /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 int 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 9 17:46:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp474857wru; Wed, 9 Nov 2022 09:50:25 -0800 (PST) X-Google-Smtp-Source: AMsMyM5gB7M6dfke2t5bREUlEbe/mCMJugQ4LrPaE+C49345RwRfYoe5cGCTxAOmGMEr4sNDv9Ay X-Received: by 2002:a17:906:4b50:b0:7ae:ea4:583c with SMTP id j16-20020a1709064b5000b007ae0ea4583cmr1301864ejv.587.1668016225532; Wed, 09 Nov 2022 09:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016225; cv=none; d=google.com; s=arc-20160816; b=ImGoJ3v2zpjv/pGmACQx9nc1VoGR3zSJyNFe3M8QTBX5T09iFuWK2opjqpZjNh8yqz cQpmP/UdVL96iwcX+om6fHPM7i9JIDFqJ7cSaf6kBmfvy9j/3qTiyPGB+0dAUKFLEbCT 4KS2VMkk50xRTpvkcOnicsEEsM7Hmhux2uTGG66cGcDLi2ze2IkKb8QX/baAXK/0fbxM n+6jojMR4b0TDPXNjykf1Vk0iw8WvjzhgroazLjT5i/UysU4AxSNU7+w/Oxo1sURWgNj l87R/pMWvhhouaXmjI9oSqz0td9ZyryEd55KE60S5Bk+v0IWyM7/uSR739d5STqBIOkX oU/Q== 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=xt+WoBEPSCbce4SU7k7Lvd7WOnbPXIYlVffaFzdNGBU=; b=mSHZthqA0JxJ8OpLQg9tnaUcmUfixagdT8r6boJ0lvnd9Tuom4dPmBMHQWQmCVHrcq JQM6g0ZNlAf1UnGzO8wR37gtPGFve328e32FvtJeYKkmGM93Oa56jKCl45YMzoC3oEDI p4fTTCy0dC+nETUdtGQ4DbxcrlYwgjmzLuq0vz5WjS67DetU3pm7HBy51rNhCf/hLKIl JLvGxa0ed02hHnuDq5Tvpm+vSvKXgZLlcrrKO5rG5++JZdd71xU9cWcU2HbsnuzGtf9s TVSpE90pxJCIcqWzEgqjWwaDDeD7wzI+udM0OFDY202GZHywymlTxhYam07BCXBScKsA zCDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jNWDt47U; 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 f18-20020a50fc92000000b004637e92aa81si14051740edq.355.2022.11.09.09.50.01; Wed, 09 Nov 2022 09:50:25 -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=jNWDt47U; 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 S231799AbiKIRqs (ORCPT + 99 others); Wed, 9 Nov 2022 12:46:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbiKIRql (ORCPT ); Wed, 9 Nov 2022 12:46:41 -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 B8FCBE70; Wed, 9 Nov 2022 09:46:40 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so2607445pjl.3; Wed, 09 Nov 2022 09:46:40 -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=xt+WoBEPSCbce4SU7k7Lvd7WOnbPXIYlVffaFzdNGBU=; b=jNWDt47UqufTjvRMGEX6BH/6RYZ0QfrGI7q6r3LGHQStZ91PZT32H/Lsxk1b8qtMgp BfWKREETEGMNcMX+FTrnJM8SDogq+UD9OZhVqM/BhQ90+xShOz6T7NSOx3N2+AjHuoha SwKCtSz5e6I7nsn/MJxadNzMMRYJ5YO0jCW/Lu2l0H4NU9fXLtFgBmPAg+yfhjI7KV5x W7bQNx51aInbL6PBDFc+FZQvhQzX1ZNsC8Kqtai4W4WOWnmni53sSzBPJHbeaLwSaqqN Iher7PbaBIgHn3DYXybYjlwh8qGv6kkKrzST9P9uJsCgbcqY5J6n01lXq0gGk06rNnsJ YkTA== 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=xt+WoBEPSCbce4SU7k7Lvd7WOnbPXIYlVffaFzdNGBU=; b=Wfbk+Sg9FPuD0IaqAOu8PP2vZXZRRmVseS7a2GlzHSyrNtEg3yKX33utWBZqRtZJrM jbxHbgXeaFYihYeF0r6blQMQsbdwDZg8HKaOTvZ7pC5xJBh9iY4Z94bk9qI2SsDEYrL+ yuV4NLFov5oB/yETtm6dqxIx56Telo14SzN9DQIa/Oal3hJz2cETEdvZbz0Qp3bif1qq HOYY5bMa/Hz92ZC9Zh8RGLFDfpMbPypHgvasIEl8LBX/V9Har6CivrvfgC2DpoO+MwcX QeGfDE2QHBMk7L+Vw/dl0S8x+H/h6kukvdMgGtmeDaoHHKEL/YlDUN7FUnvvF6Whytyd UmXw== X-Gm-Message-State: ACrzQf07IFn4xIcdjdTIppz6rC8Khq+m6FmXxXBKoel1D4OtE11dmAQw pokNNbA1HdgO/ZJp1ZSdWvQ= X-Received: by 2002:a17:90a:4dce:b0:213:9d22:8870 with SMTP id r14-20020a17090a4dce00b002139d228870mr65397473pjl.7.1668016000181; Wed, 09 Nov 2022 09:46:40 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:39 -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 Subject: [PATCH 02/12] perf test: Replace pipe test workload with noploop Date: Wed, 9 Nov 2022 09:46:25 -0800 Message-Id: <20221109174635.859406-3-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041781797544709?= X-GMAIL-MSGID: =?utf-8?q?1749041781797544709?= 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 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 9 17:46:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp474864wru; Wed, 9 Nov 2022 09:50:26 -0800 (PST) X-Google-Smtp-Source: AMsMyM7/xXU59SMj5lx/lSp7ibZNJGB2YweISjPp8rHB856GiQihL5bSPXChGHbopAnr2cyUiJsV X-Received: by 2002:a17:906:70c9:b0:7ad:f6ef:e6c8 with SMTP id g9-20020a17090670c900b007adf6efe6c8mr1330267ejk.541.1668016226482; Wed, 09 Nov 2022 09:50:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016226; cv=none; d=google.com; s=arc-20160816; b=0hAwwQsD7S8zOYf3zPBZgQqsI3IP+9QHUQusnKYlQ9ver/NgGp5x7EMaTJQaPDtY+1 sV5Bm4j/zadM2SgK6wXccTfVzlrAiId+P9XknOq8G0nst+l2TlpyWOpUnKzP/jA9B8X+ 2HT62ixogK/Z/iNDmQ5zjszq75Qt26fcOMqGPcN4cAgNoUbo7QZ9cWOIxTq9br4BVEdT ArjjsZb2fWcpb+5T8mBcsa+cqcgJMXL/zaR3sJ54etRKTe7cdA31HfSr9CEUxGSxUF/A HGapUDUlE8qsSUFZb9twJ+88/dVh9hMgRKUpLml2sNUfcebGERgVjsY6PWCiPHdjQXQX g5RA== 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=ltW1NL6crc5wy8bAufvr0Jgln5Zric5U8i/XdEa5r40=; b=H9GCqBrQ7kBXdXZoc1WVN1SBxAPWx7vlAiEUcKk/jws3rUln5HPw3qIQNq34dpZT0g pFXtvtAe4mc3a/rP2jTDXXpXcWqry1iqHjHThiIq0UAn/SJXsg1fvGDEt9Q4GaRK2r/d b3MJomVf1c/GiDeF+aj7g9nnFai+tAdwl1VTvCdSqhz++Fi3YU0iesNrNZxs91KxLSnY PCWaZ7iMbxsBLN8/sSR9+6JGPEJ3BWflOMmNQR0jbj0sidf77a3IGuY6OwahGxOkV2n/ fsmMIMyp28j8pdWNhBTk19SLrtjKVhFd9MWvEqSY3PQ9JlehFZTS38Z8mEFWtLkolYPP 3MbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gdfIDNhB; 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 nb35-20020a1709071ca300b00780e89aecd1si16799535ejc.849.2022.11.09.09.50.02; Wed, 09 Nov 2022 09:50: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=gdfIDNhB; 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 S229634AbiKIRqw (ORCPT + 99 others); Wed, 9 Nov 2022 12:46:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231756AbiKIRqm (ORCPT ); Wed, 9 Nov 2022 12:46:42 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC5C36564; Wed, 9 Nov 2022 09:46:41 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d20so16706910plr.10; Wed, 09 Nov 2022 09:46:41 -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=ltW1NL6crc5wy8bAufvr0Jgln5Zric5U8i/XdEa5r40=; b=gdfIDNhB+L6bLNfS3tYGVrMP040UPxU3xcv07PvbQpwl3aI1kp1ypWz4uXd+lgmsNU xO1IhwXON78OaxPX0kwjBvB1XSV4vOAXOJYbogttT97vRDCl6ZGsQRS5iW0AAjv4g8gM rMiRKwAbHL+lI/do+kPVHt9+qXIxaNiULWROn7T2ECLY8w6Lmt9++vXqXCfnOY2QlHjx dzdArNc/jKrAyvVXqOi/zvrxm2wnGh1gufkim7rrcZyspeFIkH+Go2DDlWipDZap5m+n /3c3goyPvQjUlGKpf8Mj1Cw8b106rjy9VxgMOTiLm7Cda0lTbukcP3ORubOEcNmHf7zC z9fg== 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=ltW1NL6crc5wy8bAufvr0Jgln5Zric5U8i/XdEa5r40=; b=5aliL/+hHm5hPzOQCuIAmyGP3J3I+o4JW544Nh4IWUWNw92luh6INrNSkJKiLFitiw RGFq/BGkbuAVzJBFgJnFHJB653n0+JBNHAc2zc1nhC8pLMxE9ne8b9czUqzOFjcWLzIv z6Ed3ieg3v4+a/xU+zksD6u05DOXeOOwLkLeiCIx7vRlaEy5A4Tb49tJEBO4jG+6uSUs LkLxK4OLIzHGUEUrSwSq8Hj0eJ7CF9AKGMKDeJjPWbFW+NUwf6rC03VDhkvWPfP/9PQ+ /Xuyi+kgVGArUf3cTemneQ/zoS1AGQ+cvzg1nPkYM3iW90UaJ1BbE3iyxShW/SGg6LWc pXYw== X-Gm-Message-State: ANoB5plI3cYRcPFOmbb/9CCL1I1MY8mpBsWgvHR9TAKfuvk4lnMlZUbW yt1hon9XQmiV8yx1QGQhP3c= X-Received: by 2002:a17:902:9042:b0:188:6fc9:1da with SMTP id w2-20020a170902904200b001886fc901damr25549304plz.162.1668016001395; Wed, 09 Nov 2022 09:46:41 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:41 -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 Subject: [PATCH 03/12] perf test: Add 'thloop' test workload Date: Wed, 9 Nov 2022 09:46:26 -0800 Message-Id: <20221109174635.859406-4-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041782523806542?= X-GMAIL-MSGID: =?utf-8?q?1749041782523806542?= 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..7fd3ac79e732 --- /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 int 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 9 17:46:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp474874wru; Wed, 9 Nov 2022 09:50:28 -0800 (PST) X-Google-Smtp-Source: AMsMyM5agreGMznnBnflgh5TgPv3JY4U0nuHXO5tO9zwJjzMDeO+OBFPyG5IJ5SKIutb+UFkrzX7 X-Received: by 2002:a17:906:40d2:b0:79e:8360:8c3d with SMTP id a18-20020a17090640d200b0079e83608c3dmr1543615ejk.146.1668016227963; Wed, 09 Nov 2022 09:50:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016227; cv=none; d=google.com; s=arc-20160816; b=zTzzA+V3hzch8pkXcpFsPIqf0OIZehRqBEjwgW+iDiSBwJtikyjheo3t9qVUy4w6AF hjU/GThA+kPK4thDpO7GbyNsgzVdh91KcPU+KDnic7uH2HMSyMVY1Lm+CFay0ss4DR8F h5oCuOfGGrNPLdxK0uF+0Dho7HJJotg0v8c179rGhtKMslzMzf9uAKZWTUknMOrZMUPh fr5R42zrdF1VqYawMF7LaePY8woiiJ84I12KFLPD81fhyYKlX00ss87VFAt5/g9brgt5 O72MUbzR0xq0YA8MOagQ5p9pFBZbfByB+RQPwngmL/YlwaKNAAmtlES47sE3VjMq1itz Ippg== 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=audwF3R26hO5/1tDhu1hZ0cjBE15kB3JCoKo0JD+sBo=; b=zJMBafeQjOEoPxY351xN1pefmZtyEc0CC2XKe41UPeNGxFewioEL5tHpnOe4sgPHtz +aAga6V71czQrakEz2jayVk6PKWPF2qqNMHfrNPBzwCp2l+5MaYyGIN4QaSaukRVJjTx lZQuEQtGxJqB3Uy8bEi/HFKbPyH1cnS39E5GkZtbLYGo6OwKFAnrooZZVtbM+ypBUZt6 Wk2g7E3fcAZgkyO3BVsshV+j60Hm6ElQLFBVYZ1YJqfIXUNQyVL9/H2E5lJQT+FeMWjg C81N8ZKUgdKcNuTemsK9dcOTQQi2i87FPZcQ1Qyvphl1G13uHEULgIx+1RInvtXuhTug 0NPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pxrvctkl; 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 j8-20020aa7c0c8000000b00461e685ce72si3331502edp.116.2022.11.09.09.50.03; Wed, 09 Nov 2022 09:50:27 -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=pxrvctkl; 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 S231816AbiKIRqz (ORCPT + 99 others); Wed, 9 Nov 2022 12:46:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbiKIRqn (ORCPT ); Wed, 9 Nov 2022 12:46:43 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 411B164F9; Wed, 9 Nov 2022 09:46:43 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id g62so17367912pfb.10; Wed, 09 Nov 2022 09:46:43 -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=audwF3R26hO5/1tDhu1hZ0cjBE15kB3JCoKo0JD+sBo=; b=pxrvctklMWfU4Gw5H7393MIwP0VxLN6JqplrrIb1uGKQrtemctjAlR3Xxor574z33L ybcyJGD/lI7c9Tx0zKswNiJm9pONqSSd4Luiw85JsK9CRQho004/05D+baCwCmOMNjDd ihMYeWMgXYo83+dv3f/CIJvBkpF+rLF0+s8xiBhlmpi9BJVnBywf+0r43LBbvBmqQ1i7 nDgXXM9SVo4KxeV/aZI/mWdy+jTyaLSTpTjjSg0KrsGzGeqpPWGhJVa1gcJ5ayCZ5Be/ M2o83nn07RSAm6oWSNu79EAjS7/RzUXQFzP2zfaPLN9s43x6l6FPZPlRnqACmYgvMmmX zMqw== 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=audwF3R26hO5/1tDhu1hZ0cjBE15kB3JCoKo0JD+sBo=; b=kmuylX+vLahydrhn9lmq5IlySG7BlbcWcGKYoe0OQmnxLog5bxD/CclrDyvElM5Fh7 dgQm2YXN8urjTuEa4S7iwUj8eQ12HGAreLLjN6RX5zySUYfwVSZyg39Kn/2ZhAlWRf5z vahkSEl4gI9DhYaLyDWzFTUCaCLjQm3sgXJZoNR69fD6+gVqBkEzh+Ed7jTpHln0M1+t Ze7TbeJfeT5uKNyDsMlCa95AxerKUdRsk8B1tH22qm44lB1JfJ08uNNT0TEfGdBzbifs jtnLkOK82vraYcn1GSllJgj8P42CdccI/AwBDanXCtLDTD1vVzxC9aOOOtwbMTsttv3i zMDQ== X-Gm-Message-State: ACrzQf008Sxzsw3mHbipF9MtWjsWXJG8Eiv+V8E7EHvVg/nAi3BQLvEM ECd/c1SKBsCJ/ICw0oLA5SA= X-Received: by 2002:a63:1748:0:b0:46f:18be:4880 with SMTP id 8-20020a631748000000b0046f18be4880mr52638669pgx.128.1668016002702; Wed, 09 Nov 2022 09:46:42 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:42 -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 Subject: [PATCH 04/12] perf test: Replace record test workload with thloop Date: Wed, 9 Nov 2022 09:46:27 -0800 Message-Id: <20221109174635.859406-5-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041784350786304?= X-GMAIL-MSGID: =?utf-8?q?1749041784350786304?= 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 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 9 17:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp474904wru; Wed, 9 Nov 2022 09:50:33 -0800 (PST) X-Google-Smtp-Source: AMsMyM6RhF6hXoowQ55TeYWXlnD/piMPWAlFGO7mnlF+OfYQjfXiKRpToEFA4RlKTVHh7diwiRz+ X-Received: by 2002:a17:906:8a68:b0:7ad:b78d:b1a2 with SMTP id hy8-20020a1709068a6800b007adb78db1a2mr52761283ejc.424.1668016233065; Wed, 09 Nov 2022 09:50:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016233; cv=none; d=google.com; s=arc-20160816; b=XPQ5VMNKlvC6J8UL5VGA9dt2HIp9k9I5IrDEWQppY55lgVzAoLwZGsRFUQW2CsEOYn j6/QslcHD2GI7ZK9HTGspqcQg2q5l4UlAhxB0/yNIBcBvQ0KWgTA/M5DwXcBxpfdjRwY ygHx8OfRl7Q1XP01vqlmE3EDX9xtLtuY/su8ee53oEHX1R0T2GkPfMfjBq/8g8QDBIRv Al6AYkzlksf0NGJlWVQtGVPhO/Wibwx2Yq8hF7tUdpU9fVgml//rOKFhGXG4sJC3tUws egBXF7PfdXY5mdLpHMEBXNfVrnA/2nvxO03WWiVgKtrfLQq/XwAVcIsPKGxPAGHCdvlL VDpA== 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=ekBIIhWuS/McjnSrAfG5owEyQPc2NQJYCb6tIV2JExs=; b=A3j/WLDS7/1Q5InvvbFpiSXlqd5ovZ0h8sAtztlsqZ/sw8WQF3M1Brz8G92dDAyCyy TXNGNrbh3MkzSeFQF/19+mQv35uMDG5XYvJrQMVXSXfHe5wHJyBkrwIgY+AhnrG2B8ro R+j2ZILPvC4KNRdbzN8O+sxwkeaw8qUf++dwGbzBV8SGQe/YS8wbVatvCUyvVUV9+Hcc 2/GOveUjKzavivVcuks/NJWdJZgpLcKRTEtYxf+6QkH7GQD1Xh9LAvPlKXeNvTWOxIeq 6aT3cGLvjvtc2dkUCXpOeeqN59xRPZqc+xsOtKk3bvNhCUsQVr53KNQJUI0AFYiedexZ +3gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qajXQrHH; 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 c17-20020a170906341100b0078d2f0bf546si2007139ejb.186.2022.11.09.09.50.07; Wed, 09 Nov 2022 09:50:33 -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=qajXQrHH; 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 S231828AbiKIRq7 (ORCPT + 99 others); Wed, 9 Nov 2022 12:46:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231786AbiKIRqp (ORCPT ); Wed, 9 Nov 2022 12:46:45 -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 8CC9B656A; Wed, 9 Nov 2022 09:46:44 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so2535333pjc.3; Wed, 09 Nov 2022 09:46:44 -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=ekBIIhWuS/McjnSrAfG5owEyQPc2NQJYCb6tIV2JExs=; b=qajXQrHHC/YSACOZC+77puLxlEZ+ohDov+N7tJCH2gZ3y9Za4tDul+D9HftTfkXgVS ZkADKrCg3t9ZelEiFcPQhAMnNGUAtfUA9sdiVOvaemwZ4em3dfOPrn0a8Hk8Vvib7GwI fxAR/TT7JllxYQ/nqbqkFvsCOEnUzVZpOyHeZYl6rb4jXNQBjQtLTN3IYQzBhX/TEpVG lReBse2V8JHcaT1M2Uxkpl/dur6oEGwPfbHPU4gX977RFaPaMWdfjnGBSFNeuZiq4O/I UhCrUgc5L2HOJOnWaVxkTR/TaMqZBijVsngJa0q68oBfJ83gI4uLwaIYlWxISOoMeSO9 zEpA== 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=ekBIIhWuS/McjnSrAfG5owEyQPc2NQJYCb6tIV2JExs=; b=o6n8JxfBmtCRJXqV6ZIBgbTWLxI+kkVxUecCeY24nokU2KPxz7Jz9gVRRBK5tlmIHE Jr8ibdT05mFTXtWIGRwAMI1mZDKsGqQcmq/iHuEuzpBIfwVPCA7B8/wzYwd3M01SlPgc V4kABr9OH80579G96JTEju/37OxVh2l8IoCU8253o/tY1S157Olyna+CqX7NS3loT3a5 3SPbpHbNhrkaXJrPsRZj54vfPr5SJLBgTokSzw6k+ffFzQ8lnD5PhVvIwgyWOHTGARTE BfxwLMzYoxPdRbJSIctawIUSU4Clm8+al9NXOE5bVFDuAsfiYeq+RhNmejC2spEc32Dw iWMA== X-Gm-Message-State: ACrzQf1Ze7QRVsxCD8x032/BnTfAAIm9CSGgst9NAQaf5ytRgUnM/qzd q6Pu08GSgI6byOb+0eCMJ/w= X-Received: by 2002:a17:902:7590:b0:187:29fe:bdb1 with SMTP id j16-20020a170902759000b0018729febdb1mr50187346pll.134.1668016004011; Wed, 09 Nov 2022 09:46:44 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:43 -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 Subject: [PATCH 05/12] perf test: Add 'leafloop' test workload Date: Wed, 9 Nov 2022 09:46:28 -0800 Message-Id: <20221109174635.859406-6-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041789641719337?= X-GMAIL-MSGID: =?utf-8?q?1749041789641719337?= 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 9 17:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp474905wru; Wed, 9 Nov 2022 09:50:33 -0800 (PST) X-Google-Smtp-Source: AMsMyM4y7dA37R59FhuWR/uKU9O3YEp3qONnq0+u1FzeG9+E/QovLhQ6iJ6VGo6SC2uuK00w9BCo X-Received: by 2002:a17:906:b303:b0:78d:9f46:5b6 with SMTP id n3-20020a170906b30300b0078d9f4605b6mr1453651ejz.158.1668016233023; Wed, 09 Nov 2022 09:50:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016233; cv=none; d=google.com; s=arc-20160816; b=hBJenKglZoPW+iU45rDMvk1uDE+JRSt0cGJ3CvpQhro58/85itwuxIvniEFx4Y5ggG Igt7AK3c7EcLuHa9XOQ/meS9H47nWfmJZyv/cYLxcOVl0dcdgm4ecVqt3ENYuCdaQCxe Xh0+ltfl+NZ8U8sW2fiQ6DNfEIUuwCs6V5wSru/IuZ0IVXdytZEdvDpUGIZnQLD10L5z mP2bXxwiKQ9Q1GoTXBjqSCX1aWVHI/rlWxwJe2ZHQD1W/YDAhIoibw7X47FAFASaL29h VcCxjRKnEBv+dmYbAC3MmJtwPMEepXcW20ndL+P+tJopcTJ3dg9K59ZSWjsK9QFaDed1 GdGw== 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=6wE8Me379mSupxG/Q4MDBJ3KdIEi26s+14+TmqgM5rk=; b=gzGVBeEXfHzJ3/HnIkygIoLmBNeJ9OAkF0opQ5nBHgsgMk54/dEtQ2zODSFW6lunNF RLRq3WcgtiZbiriKeUrKRi94bWj+e9JWL/Jg4E6pQCpPSipa5RQfb0wIjABd/jo9CmJT Yf3YYyJIa0T0VKnENG7oDthh4JquQu1LePgPETGl/DmOrI001rgMu7ZK6dpK3OWMKsXw WHf65iHWHiqt94oA/6jdtI5aqElj5jZafizPc4q7MZFP8pq/3inwZlEC+qYgYQiI+G03 UC4iMQLN7MFmQEspN6sUE0OVuK/ED+06NxH+mu209FKGa42uRfwaUOjsjfUwW9S+0wXf wkLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C+ttYSOx; 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 m17-20020a056402511100b00461b8e2c7f4si18327600edd.548.2022.11.09.09.50.07; Wed, 09 Nov 2022 09:50:33 -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=C+ttYSOx; 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 S231896AbiKIRrD (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231795AbiKIRqq (ORCPT ); Wed, 9 Nov 2022 12:46:46 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB7D5659F; Wed, 9 Nov 2022 09:46:45 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id i3so17363174pfc.11; Wed, 09 Nov 2022 09:46:45 -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=6wE8Me379mSupxG/Q4MDBJ3KdIEi26s+14+TmqgM5rk=; b=C+ttYSOxJxIEIEFyyJ5ogzydLA0DxS6DU3gqCqezxULR/kleYyHQlDuIrosSrqMJ4s dLvZOA+QPOdNUaNXXXWgiCVhb2WVxrGOPgss2tN6gdmcFD9GmjZ31r2Axkh0+icg5ryS A921XnKjvSB2uNdkAq3qy0Lp4ZeLFF5aX7UUHfn6L03UiBF6cGTqMCr8/4JgR1GNfjKj fsXOUZs/LzgMyr4irSpjayQvgsHLCd82kHjSE2ubCxOL4cTfFfeLgz301EuP0IJCQ1uD TYgbAIQVdDnF+jDjXobh1Ks9XiYABK0zWM1LBfw0O4wz9TxZh1+DaWd5nwHOanTVvq93 Kl6w== 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=6wE8Me379mSupxG/Q4MDBJ3KdIEi26s+14+TmqgM5rk=; b=jydHdMxCkHfl5DMbYT9ObWK22m0vj1vh2Q4DwwvBNUCrTVbwWXKUy49oH29G+gIa0A 0nPVgYxjfaxI8Q7o08XiSK5rlcY0AkBGKPL5Hl5UnM3C+/Z04XbGcZ0nqzKsBf8Ot4hC BcRo7AvKXZwdeCa0ZMj52NVSS9cG90qJZrn+wsLkkUzSK5ImKvdQAPp8eMNExU2NJc+f Kz3XgkuLWnzEYK1fADATZvsP0MbAUofwrN/67zPcFwwMG1zL9jssrHCCTNZUtfrHM5pl KT6FyCJyKR5meRsvNJku5924RAidpMbJR9GuM8KBX/W7PPOC//t4jBLR1w+RrNn7lAbF IC1A== X-Gm-Message-State: ACrzQf1LWDk8kktepI99WmEziUy0cwYtnfpiqvNnfHBeeO1MkyhziS7r P5DJnLInutEej2LhDhfDE4U= X-Received: by 2002:a63:90c9:0:b0:46e:dd5a:d921 with SMTP id a192-20020a6390c9000000b0046edd5ad921mr52329416pge.282.1668016005320; Wed, 09 Nov 2022 09:46:45 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:44 -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 Subject: [PATCH 06/12] perf test: Replace arm callgraph fp test workload with leafloop Date: Wed, 9 Nov 2022 09:46:29 -0800 Message-Id: <20221109174635.859406-7-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041789901072773?= X-GMAIL-MSGID: =?utf-8?q?1749041789901072773?= So that it can get rid of requirement of a compiler. Signed-off-by: Namhyung Kim Reviewed-by: Leo Yan --- .../perf/tests/shell/test_arm_callgraph_fp.sh | 30 +------------------ 1 file changed, 1 insertion(+), 29 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..9d6d1b2d99c5 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=$! From patchwork Wed Nov 9 17:46:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp475171wru; Wed, 9 Nov 2022 09:51:06 -0800 (PST) X-Google-Smtp-Source: AMsMyM4oXGYvBJBMm6ooshUq2JMWvyCdbFyay3DQgl7QDv2ysR66G/yDPnWx7H6FuWAEuiH2RWZ+ X-Received: by 2002:a05:6402:c45:b0:442:c549:8e6b with SMTP id cs5-20020a0564020c4500b00442c5498e6bmr61812050edb.123.1668016266764; Wed, 09 Nov 2022 09:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016266; cv=none; d=google.com; s=arc-20160816; b=nYi5bTXqHBWj0Y37JXhk0/kMOdw1a/E0IpQdcE3Bh7P6lLw4bbZeUuXsBdeaAkZGUr z2WczS6/sShlMT76nJj4D3pyYKdCL6UnvVSNtew//P49FZjbGEq2ZzLJjCi12t7WZ68/ SwKNO0l/fJoMScTX6RSlk0YcK/bM9Q+9B3RqQAsBqGLESx8b8nz1cFddfgUpQQfTuxv8 UrSqrWyxmRj2SOAs2watom+Nr5v/PCx/OZml0DIAAoHW6k4Jtx53q1hX4QSiNHlacI1G 6zAIICPH3NUW8bS1AzMb8kr6QiGMT6/Fjm6PoiexnJMffHPlf8BS3dLBWYlCfZFjyTCA 5ilw== 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=KiBUNwJw8FX8rn3PRRIvOQe7nPqm7jQrsYrGMfNGV4Y=; b=tIPFpz3B3yukoNp5GQMP7G2oTUqBSoz87PmEt2OOKbIyKE5aiylLXPI0XFsqNht0ph Ta43/GpvDeXL2yBnOrlLX2IMo6r6jROIYosIi56bNQFPfDl9QDZlq47cwmTQ2xNH0OBn Z97ia3PcRZDYFJCEBSY6SPW4h2JHSZzm++S2iABnrLQ926uf5JYX2nvrPxwx6Ep9g76c 3J9xkjt3fJ0Yesw4OZvnOKYARJ27+LOqoolqKCWdeukVouYmhcRx6XdF0MIylxWkssZw aHuFo2Xa5QlwjQVHMxEov9pvps3dUh4/If5GkHSwbslwDRO87RKSY6ykgIsgHpqj1Q7V mFtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N7hi0Ju5; 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 bw1-20020a170906c1c100b007833cbbb747si13325646ejb.578.2022.11.09.09.50.43; Wed, 09 Nov 2022 09:51:06 -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=N7hi0Ju5; 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 S231584AbiKIRrJ (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbiKIRqs (ORCPT ); Wed, 9 Nov 2022 12:46:48 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B1A4658D; Wed, 9 Nov 2022 09:46:47 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id y4so17785934plb.2; Wed, 09 Nov 2022 09:46:47 -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=KiBUNwJw8FX8rn3PRRIvOQe7nPqm7jQrsYrGMfNGV4Y=; b=N7hi0Ju56islhgWrcdkWJHhaovavX7G1GB77k8hhFvFgTeK2+kW8/lySo/LpamaWiz rujAMtlTGNFUxGRxTXhGFGm+6BO6wD6atL17wzrbndNR/TP8MyRHKJa1NbooE6k664nw aaX6PiwSnguFKqpHSrGK0PkeAnIup4ExEEvBMr7Tod2P480tWqRZMj9yXVAWmurKOtu9 Gnm1p+PrYIlnaExBn8lWxVCmOegiuVClACay77JEX5GspRCytEeNH8wJ4hye3OEa8UB5 oP6mF43j3K6e5zx66KqpYJDlhSujy8VLfxcrVl3HXjCyTkgxCYKvmfzvhURbLHKHg5Ak MWdw== 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=KiBUNwJw8FX8rn3PRRIvOQe7nPqm7jQrsYrGMfNGV4Y=; b=6PEDzGdeYBk8XzTnZajkWb/H8ByQy1I8E3UP455GGNKkAExFiJgNFuVzTlzZUwWYHZ akz/7eFD9U24/zW82lYu/WIUNPU6GMP8V/qqi0GDzsjKDovgGRuipk4c6KPeTmy2GkHh x6BN+8TYLyjsasYDtH98yDmPBBxQ4DceuzY8DYRakB/4iD/DRui3gAlFtpKkluV9xBC8 IBXonDPX/lQQRTwQ4ggn2a8n7Q9SlDkIax6LFEp0FyTOXUxzPklSMJ+PuzgUKwDtooTI A9b1xVK93h0HVJyBJKVW4bE6GEZ2BMG+r43eWsdzn7XF1PNVZMEbjn4M6jk8seEG2ijK RY3w== X-Gm-Message-State: ACrzQf1IMuYZZR0DK+rN3hQvyS331C4mkytCWXLwqHOcB8VGtk762fpz Q0ZYQFoV6gaJsSJ04I32HW4= X-Received: by 2002:a17:90b:84:b0:213:de0c:1253 with SMTP id bb4-20020a17090b008400b00213de0c1253mr55573904pjb.74.1668016006644; Wed, 09 Nov 2022 09:46:46 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:46 -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 Subject: [PATCH 07/12] perf test: Add 'sqrtloop' test workload Date: Wed, 9 Nov 2022 09:46:30 -0800 Message-Id: <20221109174635.859406-8-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041825244032604?= X-GMAIL-MSGID: =?utf-8?q?1749041825244032604?= 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 | 44 +++++++++++++++++++++++++++ 4 files changed, 47 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..f7d1f8d4867b --- /dev/null +++ b/tools/perf/tests/workloads/sqrtloop.c @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include +#include +#include +#include "../tests.h" + +static volatile int 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 9 17:46:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp475115wru; Wed, 9 Nov 2022 09:51:00 -0800 (PST) X-Google-Smtp-Source: AMsMyM4VRK0iq8Bh2e8e7+TGCN/C7Ww92li3mSSMyssKptRzLBdJRoiK7AoCKAllFp/MRwCYrMLA X-Received: by 2002:a17:906:368f:b0:7ad:ab0e:76aa with SMTP id a15-20020a170906368f00b007adab0e76aamr1447122ejc.435.1668016260135; Wed, 09 Nov 2022 09:51:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016260; cv=none; d=google.com; s=arc-20160816; b=mdDRtOBec36mlNkmwib/7u6DEKHKt3trenQ25kx1YJ+dWF5jcORP/7UB4FuPgkDwI5 a77Zox/rGMrEhBqDJR6fiPUpysU7rvUKVDcfKlf/s4YEhM5Bu/QB6GY8AsV7ZdMVWgP1 3kNwcq3EuLiDIG4TgyIFDBhD4yzJL28+FHLsQdJOe7PcdrBYxLaTQHkYoJKYRuT3lfvH nhnq9DeP2EnTq4WMZkMg0eJODpFuazTsMf5VPo/6x6hOJr8IHyq0UeI5suahc8H7UrDN OL0Vuowe+R3NRjrC99VFioKuBHwzW6dCZWI83j3Sj+juJjGsl6Qvs/CQXrOeXlH1f787 /idw== 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=ZnolDoJWoN1jSsgwiCbHUTF9CcTJ9HQuyPHUeyGhWlM=; b=ksQQZSQ8wbwqw2XjwILgKx4Tt4CsqfivLBimeqw0a3J1607UnTdzXwOKOtHpON5izi nhFQ1F35IYfQ8RRMJE4F6P4dTR5ym//5dk7EtxhODotoKd83yL/FAreSTnt8w5K2wWX7 XoBNV/UEH8zKOBW48Me9r3ZHcg7CkJwydJ60aLoZdiQ7ilbsQCwpSsOvwlPY+9NMN9Fz fWKQXxtbMHQUyGw3d57UYP+X+x8mrq1i9Hq4iJSqi0yv9PCKqaGF6NB/9hYiPMG5ofqe /tiDfVB68wvqkR8YTJ5AcA8LteoWkOm32NfFrcCBgFm1zR1Gpq5Jc2QzRHI7rAhEB1di HTPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hyFbfy3B; 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 nb5-20020a1709071c8500b007aa6ce58d9asi16670587ejc.712.2022.11.09.09.50.36; Wed, 09 Nov 2022 09:51:00 -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=hyFbfy3B; 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 S231864AbiKIRrU (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231807AbiKIRqt (ORCPT ); Wed, 9 Nov 2022 12:46:49 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716D59FCA; Wed, 9 Nov 2022 09:46:48 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id 78so16811777pgb.13; Wed, 09 Nov 2022 09:46:48 -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=ZnolDoJWoN1jSsgwiCbHUTF9CcTJ9HQuyPHUeyGhWlM=; b=hyFbfy3B8gm/SCbNi6Q5PNjxZM0cM7w11zxRzVEhg6Y5bLHA8iZkrJtxvO7/BSXOuM PVGy/A7ZXUjMUnIyiDCQC2SyTJK/HHYEVLLYlpcO3L/T8P6lT4oj6wkZLzRCblpFeEB0 Jd16IYN8aqQRbD7OAbdRPofZZHckqtJ9tPZyDpVdfIerQdLDseBkS30CgbCY3ijoP0tY tKLhOafU167M+f1ZV+owyVU4dEDuh8a6Zc60GaDzFPyKCjUOBgM2M7+fdpW6qPf34mxB mddvpK6b3tpHbdczghlZDBeL7/AJIrR89e+QMUp+WxaIs0s1QrK27Q2UjaT5lzYUW7DG YxCw== 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=ZnolDoJWoN1jSsgwiCbHUTF9CcTJ9HQuyPHUeyGhWlM=; b=4Jqzh2tn+aFtaHc9iTeDyd9caM1sqtWbOTDaNIH8vMBLPCSG3keGJ6UnxrYGiptDJd s5g2MkqXovUWs5zNM5dEKpNRx1cjvbJdm10A+XGotdK5Xrwfnz5BiGn2R8/BJkywsvUm 0/plT36BszwyJuLtqqFpfYVuzMc3eidYOUo1GTHTcq8LvhcJdb/S7C4n2INEY2cRVfkD k/Xe9P1d2YHMBV6w08dLOLQpPT9A3e2QmOHzN+Z4DGTbb9/hovL81Ye91/MQNMd//d2v cZ2zGWcCITBbC4ApU73K3Uz9kJsLZyx5pIM/QF77jrB1jntrhmuh+lUlOtdf83G0+p25 FROw== X-Gm-Message-State: ACrzQf2c/c1iWtlETIAwnnW9hcpbk5x4j1pQgOOHqaFM7mNwDV93mwYX /u5gKvY1NcjTDspdfdyJuag= X-Received: by 2002:a05:6a00:cd4:b0:56c:b47:a743 with SMTP id b20-20020a056a000cd400b0056c0b47a743mr61321304pfv.25.1668016007901; Wed, 09 Nov 2022 09:46:47 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:47 -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 Subject: [PATCH 08/12] perf test: Replace arm spe fork test workload with sqrtloop Date: Wed, 9 Nov 2022 09:46:31 -0800 Message-Id: <20221109174635.859406-9-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041818481006333?= X-GMAIL-MSGID: =?utf-8?q?1749041818481006333?= 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. Signed-off-by: Namhyung Kim Tested-by: Leo Yan --- 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 9 17:46:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp475097wru; Wed, 9 Nov 2022 09:50:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6MEvsJ+El/fwSBiVGcSe8x9AG5T616c2+GLnI8rbvmponC8LM0cJStGuhzg9U6ImBZmnL5 X-Received: by 2002:a05:6402:27d2:b0:462:8e41:569c with SMTP id c18-20020a05640227d200b004628e41569cmr19885335ede.191.1668016256911; Wed, 09 Nov 2022 09:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016256; cv=none; d=google.com; s=arc-20160816; b=TvWcPyxYV/1LYJAulreek8jRIsrXOjFBgS38KFoiJwK0mQe6gsPd4ByUPKUiNehsgx sACX8Wv6WuTM8AMD2XTMvlXVX1MdkKr4tvHiqQKgT8de+9IhKKNw7fnUmCqRh1GICKW7 m0sh2pwGwDm6OBZpJXr3M1/DMkO8CD/7g+a+ddwPivl22t6TO8btEUXnegV4K0HSEHme 8aRZXPJd2neNG+70xsKKft/dRyloAB0lg0t9n/X3Snny9QTg6AEvZy70LgtJJbOCMQuw ZBal1hoANAKv2WQlvp/Gg5ZEDoIeFQe8QAB7btWiCuuN5zVG8P929ky/le96BZV/2LQ6 4liQ== 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=6ybVelHPiskCNH6fllR2RvI9SCAjZ5b8Tt7/oz7w9lQ=; b=du1lxotJXTm9LZUIALaMH0q1R1B2Zf9AKLBm2FpRpCNNTafCu/2sDTU8sIl7j9Bmrt QjGx3JHdgspdax3z1T9icAY5Et5y3ecx2QDgJlmGenX2UqLz6SKWI9pshVNJEawcml2D rxLQqQH0nLw9SZ7dU1LXuPxizL6fuy0HgU7TXgW4PZKZkuUN485RAQqqDxg/JmP622VD AuLXIAHuXnsmB1wxiLY+GdFtf6zD5nEV13RvOJiTsBAsa0q9aZwIMTTEfoLH0E5y+LCp MZQw+kle9Txp6WoUGVPyak2TeZygREDzSCA+0weJEVCqBbKeRUGokW1FRuN8I7Acom0F coFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=geMmBOuP; 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 ga12-20020a170906b84c00b0078d9cec6a5asi12243519ejb.191.2022.11.09.09.50.33; Wed, 09 Nov 2022 09:50:56 -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=geMmBOuP; 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 S231856AbiKIRrP (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbiKIRqu (ORCPT ); Wed, 9 Nov 2022 12:46:50 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95ADC659C; Wed, 9 Nov 2022 09:46:49 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id b29so17354695pfp.13; Wed, 09 Nov 2022 09:46:49 -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=6ybVelHPiskCNH6fllR2RvI9SCAjZ5b8Tt7/oz7w9lQ=; b=geMmBOuPjKLU7pZSlNSnodyozLusn2++H+Pw70vxMxbmq15wKDGv6FL5Z/ll7loMfO mykYxcAlwZu+6RuzIUfhDrT4FqpyCcE6ArZQs+zEorfLZKbKzLQxNfzje7SNyx0BiM+k r1s9Jo9YixWegrENQn2JhWwexzwFrbZqqxt7vgD3ciVF775rFb+LZVa0RXSFnDE1ejWR p2LspXjdsXc1Rr1SeQKdKUk19DcSc5gxX0esRx7M4RA5Xb/rRZaokVDKpU2wkNnYR5j6 l0BEFwS64dW3GjiMKfidGR/FsI31Hq3ARg9vRtkKbn/oOefG1QFsoDnU4/zme6KSRCfk kk6Q== 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=6ybVelHPiskCNH6fllR2RvI9SCAjZ5b8Tt7/oz7w9lQ=; b=uh+eq9DYtTmyBE2o2SoMUGQBj2CIX/fE69/Geul6vfPVJ7/AfW/bqzqjQwDWA4gP9P uEXXGIw4EvS0XwpHIegyK9IsXxH0hWj+p4K0dlJq6pjX5CcVcgSKHRNT9G96bSu1LKZG cMFM8xAtG5L+Mf9sFpKm16FVHRkbU+kbIxr8Zvtdd/Jr4iFzNG6SkdyI0lbpfQS+ZwTz 6GCX8luIkJe9FzcViGXkTvYHs2OHNEGpVrJy31D7siGjC7Y3VhcaqLGiYRxojM/I7/96 A0hjjaH2uSOU71+3l0z5IvhgwImP7/2KlA9e704ORsKbp1UQ02tk7d3ERYuKZSWTYRdo 98Pg== X-Gm-Message-State: ACrzQf2gmbp4xy+5D96KozoCiKx8SKKxvsVzh7LeDleHbt9Qa71d7n0q HzmLqoPAqpHSxQpSmMWH1PDYJICamuk= X-Received: by 2002:a63:1206:0:b0:470:18c:1489 with SMTP id h6-20020a631206000000b00470018c1489mr36187235pgl.357.1668016009081; Wed, 09 Nov 2022 09:46:49 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:48 -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 Subject: [PATCH 09/12] perf test: Add 'brstack' test workload Date: Wed, 9 Nov 2022 09:46:32 -0800 Message-Id: <20221109174635.859406-10-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041814319041151?= X-GMAIL-MSGID: =?utf-8?q?1749041814319041151?= 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 | 39 ++++++++++++++++++++++++++++ 4 files changed, 43 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..61c9a9f24b43 --- /dev/null +++ b/tools/perf/tests/workloads/brstack.c @@ -0,0 +1,39 @@ +/* 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) +{ + if (argc > 0) + cnt = atoi(argv[0]); + + while (1) { + if ((cnt++) > BENCH_RUNS) + break; + brstack_bench();/* call */ + } /* branch (uncond) */ + return 0; +} + +DEFINE_WORKLOAD(brstack); From patchwork Wed Nov 9 17:46:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp475181wru; Wed, 9 Nov 2022 09:51:07 -0800 (PST) X-Google-Smtp-Source: AMsMyM6gUOElCKO/h/Gtu+Zy91pKW47WlnEam26F/Zrkt8bI5ynr/mHSp4gzOmmXSHo4lQMNrygB X-Received: by 2002:a17:906:bceb:b0:7ae:75e:3929 with SMTP id op11-20020a170906bceb00b007ae075e3929mr36325510ejb.400.1668016267660; Wed, 09 Nov 2022 09:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016267; cv=none; d=google.com; s=arc-20160816; b=qh87JsYo41oUs6BiS/JEzkIprpDEJ9UF96fyOy3jzlpIrfslLBEnGkjjPpCTBnvuSk WA2iQaIAjqpvf9SV5TRQcpJ9GJ6aLeEG3a4sydn3ReEU02REi9SkuWb5oA3G0wj244eW 1NV3xOJJiDSHzDnt8Xo9D/4GXVSn2HXwTptwb42/diABBtWxUiAqFseIxwq3lNMXtm1f RwvGxeQHXH6g/fiiopB73w8lPJM4De6/5DLT88xjp6ETGyfJetcHBwSOWdjiijdU546a ESSE3Y6F+qDjIZcAVA3G7J1ShVjq9YVo3CjPQallPAm7soxFvBETS1XjhrWexCQV1B4I NSQw== 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=CiF3YnCQsrF/gvWg4IJtalMbBErjLNwZf+63Zgv2mbg=; b=X51QgSR6eyxAGcNz5c3uYwX+4e4MYtt+egIDTcpvcAAcNNc9neAAUD/2hi6nM/Fs9T kKFCim/e/racTZLp8qMxSEld87l/KVVuRAKLlkMAZSqwWrJiiIPF6JFJAXXQJDFrWtb7 3C6Sla9lG108Vo07QYTzc4/Q02dsqvfiVplMOGEUC1n4PWfbfoTm8eyjagHUNwI+SsvB HixFDnWsk3MTD0wXCxpMl9GSdz4NuVw/BYAze7Mgo5FbP2mOh3IzM/Wu3OQDiBA5+okq CgX2npgHpIRCfoXidlBflGVBG16H9avK97pnwH2hdDBzMGVp+CvaqR6FVwgpu6SbGJJ1 IUXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hatPA4Xt; 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 ek16-20020a056402371000b0046453c385e4si13829157edb.365.2022.11.09.09.50.44; Wed, 09 Nov 2022 09:51:07 -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=hatPA4Xt; 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 S231886AbiKIRrY (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231836AbiKIRrA (ORCPT ); Wed, 9 Nov 2022 12:47:00 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B4726562; Wed, 9 Nov 2022 09:46:51 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so2532197pjs.4; Wed, 09 Nov 2022 09:46:51 -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=CiF3YnCQsrF/gvWg4IJtalMbBErjLNwZf+63Zgv2mbg=; b=hatPA4XtREHlwkvzVLI1nc18tp1XpKw8QO75TiIhdxakEb7zyL+K9819A20gtZd9Iz iDOEzWXNwExj2Ok1R2tYpZCP516eHXzdIRpBJeIyao/q5PvPFA24rT0CXywDscN5zReG bBFkRKyERzXOQ8AOnSIRkESnQjD1iHvV7zsvbW6Fr32vjxVta/8r//p8O5rq3tJ/wrwK y0k4M/Zq6a+fBTysACsAAhiYerzTF7hMvbn3uzeFx3XODCf6UPnt8TV/PflZouKJT6oN FdythhovjLJe836zD7bgZNpY+kbUnSQFK+9RfZ1PE8Ky70T+UadFOrw8e0QZkOgJUfI3 BtIA== 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=CiF3YnCQsrF/gvWg4IJtalMbBErjLNwZf+63Zgv2mbg=; b=YJjNtRM18DeJS0XMU9CSn1NkzKCEn8PL2zUASK75fLUj/kbjglo5BP+Srz2UdaLGO1 wMbWzGbARPn5n//2z2yr4U4OcRaPF1/gI7gAVKKUJpW5jPNzTk5g7yAa8tKTDyY39HfF N6YdoQepP2yBFG1bHzTKUwxV4+7yyxx0BrmRU+o1KH51kGnu36fLSSbErNJi/bSUkIf/ 019lW837OIcXb8QMOStZQP3Xcd9hw4mHhZ5VFnoeZxLl4eBqk7/CHuJ60uhEmqgjATpI 8vvPNzSBGMk5QV6XPJI+SPI0R1563zEpm46UP6+2q3iyUD/ZvZGxRHgxqWkioIjAmT8J iaHw== X-Gm-Message-State: ACrzQf3ff/NfI/wojz4TflpJQa7ZLs/uepISN+7flZBWbuge1GnJK/de g9a5bP6Ey51LBgauELl7DWQ= X-Received: by 2002:a17:90a:df91:b0:213:8a69:c504 with SMTP id p17-20020a17090adf9100b002138a69c504mr69026009pjv.82.1668016010394; Wed, 09 Nov 2022 09:46:50 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:50 -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 Subject: [PATCH 10/12] perf test: Replace brstack test workload Date: Wed, 9 Nov 2022 09:46:33 -0800 Message-Id: <20221109174635.859406-11-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041825952842442?= X-GMAIL-MSGID: =?utf-8?q?1749041825952842442?= So that it can get rid of requirement of a compiler. Also rename the symbols to match with the perf test workload. Cc: German Gomez 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 ec801cffae6b..a8a182dea25f 100755 --- a/tools/perf/tests/shell/test_brstack.sh +++ b/tools/perf/tests/shell/test_brstack.sh @@ -4,18 +4,12 @@ # 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 perf record -b -o- -B --branch-filter any,save_type,u true > /dev/null 2>&1 || exit 2 TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX) +TESTPROG="perf test -w brstack" cleanup() { rm -rf $TMPDIR @@ -23,57 +17,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\+[^ ]*/brstsack_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: @@ -88,10 +49,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 9 17:46:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp476003wru; Wed, 9 Nov 2022 09:52:58 -0800 (PST) X-Google-Smtp-Source: AMsMyM5E7Gcr8xR/YDYiNGASR9eERascNkbi0YSHWL7OnfVdnKUN9T6iWslTTAachE7JuJlUeiac X-Received: by 2002:a05:6402:1454:b0:461:9b5c:2fbc with SMTP id d20-20020a056402145400b004619b5c2fbcmr59511726edx.276.1668016378234; Wed, 09 Nov 2022 09:52:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016378; cv=none; d=google.com; s=arc-20160816; b=DJLc0l87zX7gBzZbVHbnoB3Hpv3Iqu89qgwfciFjVl9LQDlvYWv7b42gDLrXqKgGEh ahVAPfo5mcRfbZJyLSXMS+eVJB8jRfiK8CBFrQmgniKO2iOcQyWrtM9YTDBEyElr0xtI b/kjqHL6/7jaWk3ybUFw0TIAzuLdBbw9LqLhhyreLD4AuwIBa4KNlGAFYp9Rho6J028m LjiRS/sTAZXHhXpgYmmYycx+iIfTsrSFQLXQatAXXLu6phxq8ifNSssyDBgzzYV+5YyQ AbWcakJLsfMeF0ELZnJ8ejx3TPP9jsBnCFJns1Hy0HrcBxrFD92Rl9zhtZEooj82624y UomA== 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=qf7pwJ+tSfBXBsT3Fnhwy44UrI7lbOL4kA5MHT45Zio=; b=EydFSwy5ZeA9FLE9B1jCjqrgthp2/E+A/KXg+BPwNz3Zv7aufKNFZXEGCV+Ibl5Iz2 rIJ4Ih24jGwNh+LILE36CVp9hjBcvn9xe5UcBuQXy6q/vLXPTn6D7otS7uefx0j6jbKb k3dlSJoH1rqOXgzR67cPkCzg9q+qk9ar2/CuvkF41dBO2gIGOHUCaWp1Ki1Qw6J6B+dC mb9FHAr3ngCPO2C4NzrVJD3WCnbXG5Jjaw9K8UwsGC4imyy8N4dS2oHXWHEM9LaJ5XbC OL2OoHN77GHTrZ7laPNSRyH8EBhdV4rHgZHdbmwsLWe86LN/ZUcZW2grAo5vdSXpc0mv lSCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Pdcq6EHi; 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 ht16-20020a170907609000b0078d805901b1si18798834ejc.489.2022.11.09.09.52.35; Wed, 09 Nov 2022 09:52:58 -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=Pdcq6EHi; 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 S231833AbiKIRrf (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231846AbiKIRrA (ORCPT ); Wed, 9 Nov 2022 12:47:00 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 712367676; Wed, 9 Nov 2022 09:46:52 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id l6so17422611pjj.0; Wed, 09 Nov 2022 09:46:52 -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=qf7pwJ+tSfBXBsT3Fnhwy44UrI7lbOL4kA5MHT45Zio=; b=Pdcq6EHiScmcD4rAn0pVStsuOUCS5frBTuOuSUYbRSYhCbYuA1wwygpj/cyCGCspBC 4pIEJpigZQbZ+dQFaksHOqxhREZ/HUzc+qlvxFL6cyYPre53fk91cTcoDnCy4Uy/uy8e Hib0zvSKRklbBL5wfnHazsaAu/YUeR5vVehk3VvuQa+rcsFrR4lm54fLFi6YtuVcQB5q 9yOVCYHqVaWbYst3NRLNA0D/l1rzQ9K4CiWdRucyGUS9ON0tlTELaSj7s2zJuRutBQfB 7lW0uQLuwJOFH3+yEjRwZ93mvTDtMLLvOokiIm1esD7RwdT/S1AUJq8Ozo62lUoSdHZj Rz3g== 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=qf7pwJ+tSfBXBsT3Fnhwy44UrI7lbOL4kA5MHT45Zio=; b=lq9RpoumCu9IcwMuT6RXy58Q5DF3O9duPG8JCxI60RHmurbi1NwvpZ/PcbERDdzeJ2 /Kokiicb2kky/VkiT19CBvQ3Uoxoohd269Ffuyh4yoDVTT1t8SJCa4ID4uAvOcSPRbGV UgcPEEpyDzInmhwEoGkbtNoiGxGSWvo6qML/tPnsk+M7JQd9lfkJPaU/lybe06qs62o9 KRIPsJDAwTTSrdcANScXGbOV/Brdbu9Mr/5VuqZjLEh/7V1SSZU8N83jYuX/WPTdq3UX WLBvpxAIhxk87Gr8nGZne+3G3Fp7vKBmDBbMmbjw69khnsmxND0wmCEjy7ZPoqt6v4MW 6pFQ== X-Gm-Message-State: ACrzQf3L2QcmATXd/n5Faqa/FCA0XXETz1+iyLeDXTvh9c+oPsicUezO 37IMgUU/Xq+DgkO9o2D/DNo= X-Received: by 2002:a17:902:7894:b0:188:6300:640f with SMTP id q20-20020a170902789400b001886300640fmr1043883pll.124.1668016011817; Wed, 09 Nov 2022 09:46:51 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:51 -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 Subject: [PATCH 11/12] perf test: Add 'datasym' test workload Date: Wed, 9 Nov 2022 09:46:34 -0800 Message-Id: <20221109174635.859406-12-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041941735944361?= X-GMAIL-MSGID: =?utf-8?q?1749041941735944361?= 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 9 17:46:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp475965wru; Wed, 9 Nov 2022 09:52:52 -0800 (PST) X-Google-Smtp-Source: AMsMyM5hEN1UUgY8pUgPVHy+OoHVLM5yP2w1IQDDpAY7o3hHQWSO4++XXop8n9Ufr3gDSKJeLtjT X-Received: by 2002:a17:907:a48:b0:7a7:3714:1629 with SMTP id be8-20020a1709070a4800b007a737141629mr55394753ejc.569.1668016371971; Wed, 09 Nov 2022 09:52:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016371; cv=none; d=google.com; s=arc-20160816; b=agIyF5tcuwrAVWKzHXlafhVUHWD0PG73JWUFuTkugzT94kv221TPc3fmVLt7MlZMe5 WrHpYqmBiTdTt4PayIyQtZn6fuDslTwCpDjWErDHrVV6gEGCqbWohSQ6T2HQ+buMdWHV wSJrlczjSR15MrijYym7QFGsY4V42at+hZYiJfhzib9zYjUbGmn6r0dMiLxnhYTLTACi bMkUV3O5t1T/N0ijzYZ5ZyS+1ONbOQITxk+KQOAZcuHAMackJ5kLEc4nXenCpwBVPI2Y 8C9MJmcmiRalMIWVQ/Udlxw/LULTIIFvXTwZ6m9bYp1RCz/8MHmlHO7bAboLUf4uLYmZ pVnA== 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=W0zLgQdSAIqAU+WOoh8QcTGRCE1+p+yashdyC8yN0/4=; b=D9jbja6RCV84vHogxjJeTaNn0WK3gDfKpTJDOI+JRhUgBprzu12wZjLdw01IyvlnUi EDdVTf/4RCy8FZt3qCBYx/70fyTRnIxEFBU4ohy2B+Z+B+aFAg7inCoI3u2s5jrYr3AL WvmS4nIwvfHHgoAILgO/iFOrW2X5Y0ebJ6RGZLVYIw4hJpdjYAJ1wVaI5OSJaegYBCxx MZdyssZ4Ce7T1/iX6P3AGYh7XJonsuMAbMG4EBjY8LNFImMJfJSsBIcRCkKQI5sHO1mC FKA543AgDotBfHoeZHvEnH3dMmx/0RYvigMhhzcoLl2fx5lReUgZQe6G7pvTiEKtg3Rc lRTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KsEREoge; 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 l15-20020a1709067d4f00b0078dbd939dacsi12195521ejp.545.2022.11.09.09.52.28; Wed, 09 Nov 2022 09:52: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=KsEREoge; 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 S231175AbiKIRrb (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231853AbiKIRrB (ORCPT ); Wed, 9 Nov 2022 12:47:01 -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 D7AD4A189; Wed, 9 Nov 2022 09:46:53 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id d59-20020a17090a6f4100b00213202d77e1so2549441pjk.2; Wed, 09 Nov 2022 09:46:53 -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=W0zLgQdSAIqAU+WOoh8QcTGRCE1+p+yashdyC8yN0/4=; b=KsEREoges0F7NLoKhExkw1DyTx3/yMVl0I967wXWVWd6CkOCd93c6pXeHKi8sPAX7H d3sEFja87m883x4BOw2BPyYmKbZJi9gU2FxzcmSN9AVyTbLNfqR+2l3/AHR2ZHO5k/No ifeTe6Ve4vTbdSJfT5a/Pj/mRcC3GwfUiSKbPoDQ+9y/BBylqJg5xeuq8XDBgyuOqM60 QlycBxlTtLCKtVu9RZ96bwY/4ZTaAuCvc9hLpWE4r4XT8KRspJtxydjxvMqlngIZyz0g C+w0MtUOwR3ewWYJGR/2dd3B9n9X6qmelVMJb8894/BxhogW31k+czZXjvSgqVdb6kF7 cQ3g== 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=W0zLgQdSAIqAU+WOoh8QcTGRCE1+p+yashdyC8yN0/4=; b=HY93gGMMSpqTuzLo7U2NxMngzKtAyJTLsdUkegCIvaAP846x5neypQ1gX4OVSNWPnA JHeMKMLeVzIbphyxS8q8G5OXaXa0BP7QYYBsC4GCJh2e3w7K3oarlrBs04S3bN0mkuMM aW0ElOg/waSVsEps7addmceudKNzo2zNzAjcI/o6EUs0fFmcpRed9cZEF7HVeX+I/Tfu tBfYzT4skjhnEHdS7MyCtjxN5OiXHOjOE/hgK9sEP5+2xh6Rfo2964T7IvgWYcfJsFzM SxMGGLCsT+hhe5Qkia9cFTfeoDwyoBONcZPgTVWoHwl3vFyLPTuft6JG2sHzjIox8Uc3 6TwQ== X-Gm-Message-State: ACrzQf0wP1NHaaItIzwRzaBEWAlwGM9ncGFjFZPDmYindUy+5UIqbJGG imd48g7uAZX+r8M+bGOtOTY= X-Received: by 2002:a17:90a:ba05:b0:213:b1c2:ff88 with SMTP id s5-20020a17090aba0500b00213b1c2ff88mr62367294pjr.240.1668016013193; Wed, 09 Nov 2022 09:46:53 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:52 -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 Subject: [PATCH 12/12] perf test: Replace data symbol test workload with datasym Date: Wed, 9 Nov 2022 09:46:35 -0800 Message-Id: <20221109174635.859406-13-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1749041935505394689?= X-GMAIL-MSGID: =?utf-8?q?1749041935505394689?= 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 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