From patchwork Thu Nov 10 18:19:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp301471wru; Thu, 10 Nov 2022 10:20:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM5WDEAv8ejSBiQl8qY49wJ+Fg6bO5Y8huQvJB/zmSKWO9cd8D5OATJ8/fXxeN39zVgSfm1J X-Received: by 2002:a17:907:2beb:b0:7a3:28c7:5835 with SMTP id gv43-20020a1709072beb00b007a328c75835mr3495924ejc.32.1668104440355; Thu, 10 Nov 2022 10:20:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104440; cv=none; d=google.com; s=arc-20160816; b=kOqxEeO86u3TYvRXxFjdND25a/U2OTTJUIGBkwbMSu0FZBb9lx51lphqn8zXgBU9jE CKzzJOR3gfvByZrg7M9SezQ5AsjwRJSPl9DQJp3EoYSGxI1RoJ3CbcVaWTcE0fZIoiRr /DHZLON/u1crAqm8fKXhqlXGIRAIujD37t1spIhPIbdN0X3XtbytdLkMFdX+9yWksbjv +AMN/E+71WdW7nTadHXR4uSduuKE5ICF8Nn0cp8CVQIAtkqe6JbBrraHym8uRlN01HVL 0hwZA0gUgpI2SO8YNt2/nywZjOrvHEFUMSDRMIa6/Kp4woY8EKnIoFfA0srKdLDtEgNr CtGQ== 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=TLcUTxbLtqLuMUkFI/k4r25Yr8S67Z4Vfuw/WeAxT6Y=; b=eTPCpeFblVGBg/gLY+mHupthtbrw65GiERTdL99cQsM4qBh6JGJdfvbRQt6bIzvL+3 IZHsYN9EXBPrvJfqlohMvWGexjRXaRpPz7f65eQqbjSSaeXWnX0VVNrVzLewoE/Ioq4E NcnRn6Y179M2m0ERFZ+C/WswBEUA22xLsfqyuAmrRQkdcJ458EekrV5F5a19IB4bOc3p EcAJD3L1dBDPar1YRBBihQHMowhslT2jSDjN13apHRlMvVXhgS94mW2Pq3/P8T/1B4G+ XUWyMG4RkwpYuYR5RFL2aUXAQYRNcqeus2vSE+vPzgNYUQkWsS3jkDEBgt5DvABiTimI 0hfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bJjHtuxz; 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 hb31-20020a170907161f00b007ae72fcabb3si12248923ejc.838.2022.11.10.10.20.14; Thu, 10 Nov 2022 10:20:40 -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=bJjHtuxz; 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 S231791AbiKJST3 (ORCPT + 99 others); Thu, 10 Nov 2022 13:19:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbiKJST0 (ORCPT ); Thu, 10 Nov 2022 13:19:26 -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 2C68E2DA98; Thu, 10 Nov 2022 10:19:25 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id j12so2137420plj.5; Thu, 10 Nov 2022 10:19:25 -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=TLcUTxbLtqLuMUkFI/k4r25Yr8S67Z4Vfuw/WeAxT6Y=; b=bJjHtuxzKMmrpA6C4f74Xj45etv76YATl7sotLoqR+RIWOmDkl5S67hur0dTpBHA96 05B+BjwCOgN9OnP3snuwa0rpmlY+0dJzWqnJpqOISDK2mhq+Ii5brX3JMQ6mCgFm0hmB yaYqesgOxrDLOuVSr6R2ZCusZU+N/iIJ17nXP55nL6GpXHYsl9z2kvYtL26hbsQ0/SaZ 48a9GUVBgV9ryjY04kdBgMU9rC45KoQ4vVivWtMGoVczl6UuzstkQPSI6NNdEShIZ4Gl qPzYQdrcphbGA9C3Dh/LLE75LS47OYCoc6nSkURhJBfryXdZjbpNiorcoPCEEoYtQYhP XDRg== 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=TLcUTxbLtqLuMUkFI/k4r25Yr8S67Z4Vfuw/WeAxT6Y=; b=muN1uRgaD4y9GqRtp7JURk9YxxkZr5IWd3wkcrvu5r9LVx721M0HlxP7gre2XA3Sdq tDqNiCKGI0ZkmCw90EqENRwDOBZE1sERlKliZy1HTrGg4zROFmSIhQrFqQxEL9dKptN8 ZtaIoevBgZ4ANHNrjTFHcYHuZS5J5eJvP7ij/lOUj28VDkv06M2+H+qKGLD3sJdlfNER y3q/bZ31oWY44DYtHQTXQ6YN+alAzT5udis0xW786DOJns+Y5epvGeDxzJSt4NGV6IJT 3/080Ai8HbH029tYUX9/LeDZ6iHG4pHfa8E7eAOVROikyfea0WhFomc3nRqr4Vz9fJT1 0YIw== X-Gm-Message-State: ACrzQf1sneOZzJW64B7+mHFS1yKA/gdoJ4pvbXSPoFvqfuheM1PHr7Yp QwjMjcaikzG3dwmEcSimOd4= X-Received: by 2002:a17:902:c946:b0:186:9890:97cd with SMTP id i6-20020a170902c94600b00186989097cdmr1702287pla.104.1668104364596; Thu, 10 Nov 2022 10:19:24 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:24 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 01/12] perf test: Add -w/--workload option Date: Thu, 10 Nov 2022 10:19:09 -0800 Message-Id: <20221110181920.84900-2-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134281747771070?= X-GMAIL-MSGID: =?utf-8?q?1749134281747771070?= The -w/--workload option is to run a simple workload used by testing. This adds a basic framework to run the workloads and 'noploop' workload as an example. $ perf test -w noploop The noploop does a loop doing nothing (NOP) for a second by default. It can have an optional argument to specify the time in seconds. Signed-off-by: Namhyung Kim --- tools/perf/tests/Build | 2 ++ tools/perf/tests/builtin-test.c | 24 +++++++++++++++++++++ tools/perf/tests/tests.h | 22 +++++++++++++++++++ tools/perf/tests/workloads/Build | 3 +++ tools/perf/tests/workloads/noploop.c | 32 ++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 tools/perf/tests/workloads/Build create mode 100644 tools/perf/tests/workloads/noploop.c diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index 2064a640facb..11b69023011b 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build @@ -103,3 +103,5 @@ endif CFLAGS_attr.o += -DBINDIR="BUILD_STR($(bindir_SQ))" -DPYTHON="BUILD_STR($(PYTHON_WORD))" CFLAGS_python-use.o += -DPYTHONPATH="BUILD_STR($(OUTPUT)python)" -DPYTHON="BUILD_STR($(PYTHON_WORD))" CFLAGS_dwarf-unwind.o += -fno-optimize-sibling-calls + +perf-y += workloads/ diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 7122eae1d98d..ce641ccfcf81 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -118,6 +118,10 @@ static struct test_suite **tests[] = { arch_tests, }; +static struct test_workload *workloads[] = { + &workload__noploop, +}; + static int num_subtests(const struct test_suite *t) { int num; @@ -475,6 +479,21 @@ static int perf_test__list(int argc, const char **argv) return 0; } +static int run_workload(const char *work, int argc, const char **argv) +{ + unsigned int i = 0; + struct test_workload *twl; + + for (i = 0; i < ARRAY_SIZE(workloads); i++) { + twl = workloads[i]; + if (!strcmp(twl->name, work)) + return twl->func(argc, argv); + } + + pr_info("No workload found: %s\n", work); + return -1; +} + int cmd_test(int argc, const char **argv) { const char *test_usage[] = { @@ -482,12 +501,14 @@ int cmd_test(int argc, const char **argv) NULL, }; const char *skip = NULL; + const char *workload = NULL; const struct option test_options[] = { OPT_STRING('s', "skip", &skip, "tests", "tests to skip"), OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('F', "dont-fork", &dont_fork, "Do not fork for testcase"), + OPT_STRING('w', "workload", &workload, "work", "workload to run for testing"), OPT_END() }; const char * const test_subcommands[] = { "list", NULL }; @@ -504,6 +525,9 @@ int cmd_test(int argc, const char **argv) if (argc >= 1 && !strcmp(argv[0], "list")) return perf_test__list(argc - 1, argv + 1); + if (workload) + return run_workload(workload, argc, argv); + symbol_conf.priv_size = sizeof(int); symbol_conf.sort_by_name = true; symbol_conf.try_vmlinux_path = true; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 5bbb8f6a48fc..d315d0d6fc97 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -180,4 +180,26 @@ int test__arch_unwind_sample(struct perf_sample *sample, DECLARE_SUITE(vectors_page); #endif +/* + * Define test workloads to be used in test suites. + */ +typedef int (*workload_fnptr)(int argc, const char **argv); + +struct test_workload { + const char *name; + workload_fnptr func; +}; + +#define DECLARE_WORKLOAD(work) \ + extern struct test_workload workload__##work + +#define DEFINE_WORKLOAD(work) \ +struct test_workload workload__##work = { \ + .name = #work, \ + .func = work, \ +} + +/* The list of test workloads */ +DECLARE_WORKLOAD(noploop); + #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build new file mode 100644 index 000000000000..f98e968d4633 --- /dev/null +++ b/tools/perf/tests/workloads/Build @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +perf-y += noploop.o diff --git a/tools/perf/tests/workloads/noploop.c b/tools/perf/tests/workloads/noploop.c new file mode 100644 index 000000000000..940ea5910a84 --- /dev/null +++ b/tools/perf/tests/workloads/noploop.c @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include +#include +#include "../tests.h" + +static volatile sig_atomic_t done; + +static void sighandler(int sig __maybe_unused) +{ + done = 1; +} + +static int noploop(int argc, const char **argv) +{ + int sec = 1; + + if (argc > 0) + sec = atoi(argv[0]); + + signal(SIGINT, sighandler); + signal(SIGALRM, sighandler); + alarm(sec); + + while (!done) + continue; + + return 0; +} + +DEFINE_WORKLOAD(noploop); From patchwork Thu Nov 10 18:19:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp302221wru; Thu, 10 Nov 2022 10:22:19 -0800 (PST) X-Google-Smtp-Source: AMsMyM5w+49w+beS98Fnwi/o7fLKzXBK3nkdxbBp0SOoeLm/9C96JxqRFNPg4DYfi/Nso9OUpncW X-Received: by 2002:a17:902:cccd:b0:187:733:35d1 with SMTP id z13-20020a170902cccd00b00187073335d1mr64206551ple.26.1668104538762; Thu, 10 Nov 2022 10:22:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104538; cv=none; d=google.com; s=arc-20160816; b=nzQcQL6LlGPtFND6fjUjZUftHFSWdt4ki2JHFXykttSzwgiB2Sj+6+Ec0znxj1Ulg6 GD0WdCdntqXw1idMXxa71lTMigGF0UWnheLqow+M9ogYYx73QM7cKsradNMZTfzjI5G2 HpvQQzuPHEyT/E5AKO9tYEFiPPDZ+4oBuw7HzCb6HMVGfWDJEcb0fe7d9Yay6NSsivxX 9bh5mZx8+J4hGUdPnPneLVBQeSplwje+ZrP3MBAqnJF4zP73ZgH/NyZWYfgiOYD9KdK0 13bBJXisxFQ5FvI0Bg6ZYUH7Q9nA4obaQqRZm0/bKf8qPxkZ4953VeBX4/rq40hIaBc4 YM0Q== 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=xN13JFxKxPVkjxGylWKLVZxnCq3MwU+nxhwlTyhC5nY=; b=EDrPZJ7CEnuIDy09ygSHv2NzMIs6SCSMMF3InJvZxqocczA5n/gR1ncO5INCmaGlHH A1ZB+Xoa8cw0UiFMOENJFx/Id+c7LnMkob3I/Y4jI4Z2USAue73W8N02XksZKD0FttVf 5tLl7wC3TyvGhsD/cPeELUgdD4QxzGsUT7EQk8EDbhSf57xLZBPIQeNxusVrFFKcd6/x 9wM2jQ5rVc+P+DAZ/TGw1zWxnbJTgvSdnjCui0s4KGYdL/V5mEqe1wI9n1E9i3E3uwgF og1xVXvTeKC9fiXmZLNLrtIbiinDg9sVvqHneLZ/z2OdPglghl+7GJGWePLiOawAji0c ykzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=khCPq+Mv; 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 q15-20020a63d60f000000b0046ee9f16e3dsi20959822pgg.671.2022.11.10.10.22.05; Thu, 10 Nov 2022 10:22:18 -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=khCPq+Mv; 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 S231819AbiKJSTc (ORCPT + 99 others); Thu, 10 Nov 2022 13:19:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbiKJST1 (ORCPT ); Thu, 10 Nov 2022 13:19:27 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F4682CC95; Thu, 10 Nov 2022 10:19:26 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id h193so2473618pgc.10; Thu, 10 Nov 2022 10:19:26 -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=xN13JFxKxPVkjxGylWKLVZxnCq3MwU+nxhwlTyhC5nY=; b=khCPq+Mv+AjXuYqj91VjQny7Dq5csxPkl99CArR98EpyWD7RvrWQkXyf0s3HDQCKUX JoBj4+KS1nTUfTvbvX4M7Ng4EGp15tQyixks6HVn+oX0ErleSgQ/7NLBZwggy1R0LtuS ZlbpYYH6oHHhP9horJO71o4RZYyWVJ7PbSh6E/b3ggoDmIDA2RPtx3jTs4lzKB9tEoYV RUsOCOXuuBfF7eOzcHU0Gt0CJfuH+SRd1elD1HrbWkcog5ZvFc8iFsUaW0JxamLwFA+Z dejxZEVVcQM5j/LONREilfMWxgsCudqmC7CtcuBSh2Q0bzv4ReYbRyMSM/AKYCvZVzny V3Ow== 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=xN13JFxKxPVkjxGylWKLVZxnCq3MwU+nxhwlTyhC5nY=; b=1Ekbto5Llx5fOVZWrIld/LgyXVe6zICXDs96GQ0q2OFtIqhG/1W8+P2svtA9YjiAEQ hSN/yMNVVNdtg9ptbm2hf4hzEKy1xPeTt8eiqB2aZj3ikswamr9tCm7DaOE3kc/y40f5 C1qQqKno+IPeokbVcwMlrOyh2ctOGdpT1IlCqgRhBX1LWtk16Z32RnTg4SpK6K/j4LM3 uQcwIetV1pAZr94bCkuU/hXI91CuClSGdGgKpnlIETeGrxuRo4nMkCqSGmgwuzpo+omX eD2tqT45yeL5RQkHYsBfaRskCGhTlX4HzYluEWQBphS8C+0FACJppl3zper4BnENNgyT KTHg== X-Gm-Message-State: ACrzQf3ySnt81aX/Cv6tR63Th4rJ+nz5n7Bma6/QuwGCO+mQbJp2vnV3 aWO2q/ve0R7pmlQOaT38Jh3brBCsIF0= X-Received: by 2002:a63:174b:0:b0:46f:b6df:3107 with SMTP id 11-20020a63174b000000b0046fb6df3107mr3030917pgx.454.1668104365859; Thu, 10 Nov 2022 10:19:25 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:25 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 02/12] perf test: Replace pipe test workload with noploop Date: Thu, 10 Nov 2022 10:19:10 -0800 Message-Id: <20221110181920.84900-3-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134385105506003?= X-GMAIL-MSGID: =?utf-8?q?1749134385105506003?= 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 Tested-by: James Clark --- 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 Thu Nov 10 18:19:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp301581wru; Thu, 10 Nov 2022 10:20:54 -0800 (PST) X-Google-Smtp-Source: AMsMyM5OM1sHfLQK9l39x66lt69u3LXZHPgBQapbREUsM54FYQe432U7PJZ+5hdmj2scbJTXhOfC X-Received: by 2002:a17:907:989b:b0:7ad:8bc6:48e4 with SMTP id ja27-20020a170907989b00b007ad8bc648e4mr3381347ejc.514.1668104454703; Thu, 10 Nov 2022 10:20:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104454; cv=none; d=google.com; s=arc-20160816; b=OH+oSG1QSql6KdJ7SoyFBjTCk/bCPgKRY5Wo/HuUJap2+IgxnZhWDWkqWGHRBoShHw Kb+tR5rAneisytLJ8D55npOWz+oeEyb3hX7Hvu7H0gUdzH67g4xzaK/3Qm1/oo6JIjAN IhxL5h8IHABQM15jgtaUxUaCMpiiwg9Sep065n7ke6Pzz50S548oDLXZGrLSAV3A7P4X n4PsnnTVxKAKqYT+I5ecMpgDrqs8P6UcUxwvjW260GzwaYxO2rYCvyp4kZNOEHZ9jVqo 9iOSIdvm4ABwZin+rqfroufjmsdCHB3zDq1wLePu6rTKJRcleQgGhtJKgwPy/G/fbQWL p2XA== 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=3eCEQ/gN18j+U28atVDeus3N47A3I4Dq4PXONaj/eF0=; b=r8BzNwy2nqCSHzdZ5tNm1WqTtNuYBbP9lWBKXryloMP6h4j6QteBXQJrH9fF58O8Pp PFb3j/hAjnMcrwUE026DGk8yYDDMkfi8iejbQ8uza0rCsQRvaKdDMbWXAkT+CwHn1y82 1STKyhA9DPoNevcGRrSyB3JYLN+m2UYgDANKhXK6iSKrV/pEZ2Kpv5px6ki5L6Slqem+ yaMNuxAdGqSEa7FLxXczTOpKQGbzMYnklKEc0nr7Eg0EvtjYiU/UsNUGj63bD5ltPHtn tzru8rTdEJxqz+b4HWv4CG+HauyCQypap/5UoqYZlbqqmHtrrf0P/0Tr5skWGQ0KL3a/ wRQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=U+bveVg5; 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 h22-20020a056402281600b00463c29b5443si387874ede.27.2022.11.10.10.20.29; Thu, 10 Nov 2022 10:20:54 -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=U+bveVg5; 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 S231840AbiKJSTf (ORCPT + 99 others); Thu, 10 Nov 2022 13:19:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231753AbiKJST2 (ORCPT ); Thu, 10 Nov 2022 13:19:28 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B99F22CC95; Thu, 10 Nov 2022 10:19:27 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id u6so2113123plq.12; Thu, 10 Nov 2022 10:19:27 -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=3eCEQ/gN18j+U28atVDeus3N47A3I4Dq4PXONaj/eF0=; b=U+bveVg5rcJYPgdAm17Yn6Ci8pYhuEmQnL1xPLDEDJYg5zmqo1CyCEyNJrXpWhPri1 3q7PbUlPu4EreGCjYehZOplu2kEN+TMalV3/GLYAwLtRqqYbt9wMsrH2genVGzkcqVpm KlogBGdFVs/WsW2pS+cMyL8EHktL0/LAyxJ66uKaObT9mfXERRyi0wBVXkg8dp/NdS/3 1LV934RmAnuzclQaA+V7mC5aWp+9uRhtQVHX3CU6sHlcUsefHQWy7ZyC6WIt/rleL8f1 sF5V/p4mq9GxC1e/3hAe7uZ5cZrFc+4Al5tacCTv5TcAcYVIcuym60jW4tCruvXdmq6B hQ7w== 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=3eCEQ/gN18j+U28atVDeus3N47A3I4Dq4PXONaj/eF0=; b=ivL041gnqNZE2M1++jX+MQ54umg/WllHwhvoNHFEF6UiLRdthYQHWU05VXSRBVS/me JHG2RFsfH5EsYWhrM1UDvruKD9esA3py8sUn5YMEknEKCe9odTXjuSNR/yU/06ci/P4C tIjFA8Er2nwwmWJMpe6htNRkIkJ74t1TQf2hRMsX6bdJ+2n3SZFKOIP2e9sQ9cFoQRTr xGn60MyTasIDb6KZeorFiKpk7MG+hSdu73y245iVWAb7Mr/hYmB0LqYyc2bjNXgXkpq/ To+QIyOTcH/biacL7QEmkE95kuFQQbpJtjqD7ZUaCul0G0fWKDhlZZEj7Z00Rvg4iokD jyKA== X-Gm-Message-State: ACrzQf32vlbI4ZbGT7d/F4BwDufSXIr52tjLmacZatJ7rKV0TIBR+ppz dOcaz3HTpY0I+5Bk2YNUvek= X-Received: by 2002:a17:902:e8d3:b0:187:3c31:fb3a with SMTP id v19-20020a170902e8d300b001873c31fb3amr1578266plg.38.1668104367126; Thu, 10 Nov 2022 10:19:27 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:26 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 03/12] perf test: Add 'thloop' test workload Date: Thu, 10 Nov 2022 10:19:11 -0800 Message-Id: <20221110181920.84900-4-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134297010523083?= X-GMAIL-MSGID: =?utf-8?q?1749134297010523083?= The thloop is similar to noploop but runs in two threads. This is needed to verify perf record --per-thread to handle multi-threaded programs properly. $ perf test -w thloop It also takes an optional argument to specify runtime in seconds (default: 1). Signed-off-by: Namhyung Kim --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 1 + tools/perf/tests/workloads/thloop.c | 53 +++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 tools/perf/tests/workloads/thloop.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index ce641ccfcf81..161f38476e77 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -120,6 +120,7 @@ static struct test_suite **tests[] = { static struct test_workload *workloads[] = { &workload__noploop, + &workload__thloop, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index d315d0d6fc97..e6edfeeadaeb 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -201,5 +201,6 @@ struct test_workload workload__##work = { \ /* The list of test workloads */ DECLARE_WORKLOAD(noploop); +DECLARE_WORKLOAD(thloop); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index f98e968d4633..b8964b1099c0 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 perf-y += noploop.o +perf-y += thloop.o diff --git a/tools/perf/tests/workloads/thloop.c b/tools/perf/tests/workloads/thloop.c new file mode 100644 index 000000000000..29193b75717e --- /dev/null +++ b/tools/perf/tests/workloads/thloop.c @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include +#include +#include +#include "../tests.h" + +static volatile sig_atomic_t done; +static volatile unsigned count; + +/* We want to check this symbol in perf report */ +noinline void test_loop(void); + +static void sighandler(int sig __maybe_unused) +{ + done = 1; +} + +noinline void test_loop(void) +{ + while (!done) + count++; +} + +static void *thfunc(void *arg) +{ + void (*loop_fn)(void) = arg; + + loop_fn(); + return NULL; +} + +static int thloop(int argc, const char **argv) +{ + int sec = 1; + pthread_t th; + + if (argc > 0) + sec = atoi(argv[0]); + + signal(SIGINT, sighandler); + signal(SIGALRM, sighandler); + alarm(sec); + + pthread_create(&th, NULL, thfunc, test_loop); + test_loop(); + pthread_join(th, NULL); + + return 0; +} + +DEFINE_WORKLOAD(thloop); From patchwork Thu Nov 10 18:19:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp301741wru; Thu, 10 Nov 2022 10:21:17 -0800 (PST) X-Google-Smtp-Source: AMsMyM5eZTWz99WlJGfJvyqHVmLBBIS31j3mYWOQhqgCPfpBkZPNTXtVICvIYMP8HQaS6JOguYOI X-Received: by 2002:a05:6a00:35c9:b0:54c:9e75:ab7 with SMTP id dc9-20020a056a0035c900b0054c9e750ab7mr3126820pfb.82.1668104477063; Thu, 10 Nov 2022 10:21:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104477; cv=none; d=google.com; s=arc-20160816; b=p+ukbCaLpinMAR4bi41nKRfQ3giBlab1qJlVauGqmmiN30j4grPEKwy3iSFteiFy69 E1nwabbVYPNjU0YOdE7XxN423c/dC9RCag+sdNrKdJXhP9KebiOxR44FYYTKTZxJlG5T z5/FqH3ro4UdGZEf8qFZ7AqvpaZWsk76rmpsOlokxyejx+fozS9YqsbceEfpVuHhzrkw Ime14NTCTwCITUrFKE1Ay9JIbESkcxJxGzCZAdZLCdek5PxzTcdzjlak1EtWiESGmQKj pgxCChk8BzxoBLSYJmKPnY31EApRPJN2uITC1+7b8seufUHcea4bQsiFgvcg7fqag55T 6Z1g== 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=tOrM7DG6LUDq+Ll5YPubMT6jgUHifwK6RUyTLKQOndA=; b=qmPEVwIAymidpjOu/YWp2I6LWPj9IM91fzExO2TY657H/tmOOIwwsCrLccxehnmcvc jgWRTYtGUbgOZT1qCA6M53psQ1FtmlEQEABuBJ7UsezW19PYlB5YojkGHJ/osDjDT0pg Tay/CbU7P7jh/aeb+crTcZ8VwCpcN95VzwFim0CEVlVwi3GXlb/f0hSVtW4jz1QRgkV3 VaaQzqkJ10Js3v/sVkn9hdvvR8i2oFjtniee6FezdujG0xzaw4WTqj4HuPHDWKU17sO8 p8Y1S9/i0ctWQgjInj0B4WzXu3ZYGwXNI27B6EVMe46c7Ecrj67gJC56ozz7pOpXi44w BJYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qcbkzL4D; 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 205-20020a6302d6000000b0047009247403si18927464pgc.409.2022.11.10.10.21.02; Thu, 10 Nov 2022 10:21:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qcbkzL4D; 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 S231852AbiKJSTi (ORCPT + 99 others); Thu, 10 Nov 2022 13:19:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbiKJST3 (ORCPT ); Thu, 10 Nov 2022 13:19:29 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFBAD2CC95; Thu, 10 Nov 2022 10:19:28 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id b11so2313350pjp.2; Thu, 10 Nov 2022 10:19:28 -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=tOrM7DG6LUDq+Ll5YPubMT6jgUHifwK6RUyTLKQOndA=; b=qcbkzL4De+QgKx+eLLv3VThu1rH8Us/PnxRz4kLRjFpAfO/AVtWKxZ4sH44j4MnT3M wbee2GMxkCV+mC4gXNDPibYtXxB0Fis/q4jg82ERC67k2nZwnntJZEYRvuYnjWgh+Gul TLz0j87cg7xD2LrXo2EAF95ahmrfGQBYPJMKOV4P7tnVTh7dwGwo3ZOsOip/35yqV+bc kHnFvayI3pTrIEu68xCr+oYEsin8+7E/BZ7Byr70w4WOpao3/WmhZrn5IQm3dN3qCslg HoL1qWN1+XDQN3XugIKo8HFolRqsQzZIui+F+SdBSZNr0AdPb+ppl3KY799W5TehZdUw gwKg== 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=tOrM7DG6LUDq+Ll5YPubMT6jgUHifwK6RUyTLKQOndA=; b=NW0VFMpQwGYfdRCJ1EJkytodXHOEChZg/VADDYnI8Od2WsthbYpe+9kmDm8wZZg+du dSQoSeWDms9utqHXZjtGqT7MIxt6r5sD7c2DhS9olqAkmG5tjsO4EpB00L5VdXQrEiTy VcopQb8U+d306ymqjVZafxUxEjqnZ3NtHC37VpfKxXwF6MyI30kO1mMQbThibDyHq6sX jW9WNt7rWazhSK4+yUWgl8fnOV8fWxXcyzypuZ2ACOtfWtyxmznbnOysk0gFbSchnPqp 3XzoXROh0BJIYxzBJBodRxyz8Z7r1D/dZeKVyMwI9kte2K1IxFzuUDWfKy/6k72RJ5i9 8mEw== X-Gm-Message-State: ACrzQf0IOI/QGy8azuXYJl0Vc5n869IfIo22yjrw/8LTzLWXj5EZXBZA zo0jVs7Fo643kE/GCIVbsE0= X-Received: by 2002:a17:902:f394:b0:186:ff42:704d with SMTP id f20-20020a170902f39400b00186ff42704dmr1690417ple.153.1668104368402; Thu, 10 Nov 2022 10:19:28 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:28 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 04/12] perf test: Replace record test workload with thloop Date: Thu, 10 Nov 2022 10:19:12 -0800 Message-Id: <20221110181920.84900-5-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134320147061235?= X-GMAIL-MSGID: =?utf-8?q?1749134320147061235?= 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 Tested-by: James Clark --- 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 Thu Nov 10 18:19:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp302736wru; Thu, 10 Nov 2022 10:23:19 -0800 (PST) X-Google-Smtp-Source: AMsMyM6HlHMIOTjZHRBq+7imsvQXZxBVt/DElg82J3Et4MGCjsTRv5ixs+de6iy7oTdpohzYAzWN X-Received: by 2002:a17:90b:4c87:b0:213:5fe0:6700 with SMTP id my7-20020a17090b4c8700b002135fe06700mr81563654pjb.128.1668104599136; Thu, 10 Nov 2022 10:23:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104599; cv=none; d=google.com; s=arc-20160816; b=Nk5wTw2nXdkox06yTA8YeSTn4psnI8zIVC4CdSudXuA41XIsUYovw66pXU/BERyg4U kdQFQPTiLLt77SlsQbFOR7QdT9M353siX5KPKDJtsYzY4FlVtdjr9WNCAj1c3tXcyWiq LbIFW6FI4dOSXFjAMiMC5zqxIL3L/fPe51vjeRrueJPw9MTlyg36TBDFeXg4T7H6JNNC M3SHlZvFJnUlRYUoeFU9wHY1poMS0cmDlAle1TcSBUTLLm5bVjf+CmlI+5LsiZPknYrv //Dt20X7mlQ1KUKCPCOA1dGsB5FOH0KAro3Cky843QUrO/bM/yeey2P4CWTp1dmSP7x8 GYFg== 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=kHtWNAtYktOIgs6nS4lgKw2kHSGAY/bbpUgRU4xzJN4=; b=0P1VFRJBZqAg20gDWcqOrCBqvJGiGEO3WjlKY0zEKzhudGCYHjhKERu4V75kb1ANHX gAfRyvSS4HoY86dpkzt2UeADPfxXG+RaajNiD9uil7LuVEe0bpRnF67GUBPk+jat6oSV q7TeaCXyMTaJsfz/TeRn6MaZFRz2rlZcsTB/B9z0xnPYA8dBRNgijskrCG63vpvfoabm cn/8LaiVO4+PXytosWKyfkoNyB3stqRWu4bE+CzyrIRCl9iLuKq3MVAlB7Ks1E8nhvfB tYy9TNL2WacAxGtxSDOitNu3l1z0MnAS63qTFgPMx/2IiaoIBDx9Pvr99M0XH+TZEhOI QJmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Gevv+KwM; 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 q2-20020a170902dac200b0017145b821d2si23940434plx.477.2022.11.10.10.23.05; Thu, 10 Nov 2022 10:23:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Gevv+KwM; 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 S230296AbiKJSTo (ORCPT + 99 others); Thu, 10 Nov 2022 13:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbiKJSTa (ORCPT ); Thu, 10 Nov 2022 13:19:30 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DFD03FB9E; Thu, 10 Nov 2022 10:19:30 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id k7so2134173pll.6; Thu, 10 Nov 2022 10:19:30 -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=kHtWNAtYktOIgs6nS4lgKw2kHSGAY/bbpUgRU4xzJN4=; b=Gevv+KwMkjgHS2suEvRfwl6RP6NVEJKhevUXMwlZFMjF36LmwEb9/uz/XbrZgFTnEF Tz66g6Hk499lJj5AnGz7kf+ThUsM/vJuF8K6Vt7d5dWKlVb+dRs+dxlpgqyVciJFoEsY XHOonL/LjQOJDxQP4TikKootOuwsLnkWQUMvbfdnsUSCn+vuOdXt8P0He7QzqsMpWqAx UV8kpmMVgXtBe1VRjkuxW7CUDWk6BM+RhrOkOvVmKA6Kmz+04zZsPkePUr/xJqf/yRwO UEiVBp51lN+8BIHTknuiiB+rqfaO9UaF9qc8Ah7QMpf139uAKZ8fOL7OfPnZi0OJTIAZ +jXg== 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=kHtWNAtYktOIgs6nS4lgKw2kHSGAY/bbpUgRU4xzJN4=; b=4iECDwwJjWXoDNudzRwjl6OMBkuNeww4TC9tofHmJDmvlvi7h6NVt2AJGFq8AmozHx /9sT48pnOkWwxUq9oQL4XomFlg56uYaB3vd2Arc8FO2aXrQvkUl/2MP3BDoagJoaZC4S uZIUJPKsBuZJzUODU7WRniHdcjgXjFH2/DHZEi8t0uNpdt0EqRlceUk6GlBDZJMQ61zs gDdTBr2uW8ihIpbXps4BWlU/3Rx/WYCegmZHFUmASCTjOF/CAQTjMkPkuSBxSDYDol8G cOrnw+3Rjs9azoHVX3RlJR8b8q+sBibZ4XxFYFAR5mEHbo/N015l3c9tuxDdohnaTLXX kcPw== X-Gm-Message-State: ACrzQf0TCZ1zWgTWXg7Biyk0gd88mG1+1wUrFRUisy1+VTAutFt48Z+5 GmlfRxhWw2Wyl9gxzQNlZvo= X-Received: by 2002:a17:90b:1095:b0:213:ee6a:f268 with SMTP id gj21-20020a17090b109500b00213ee6af268mr54565898pjb.213.1668104369654; Thu, 10 Nov 2022 10:19:29 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:29 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 05/12] perf test: Add 'leafloop' test workload Date: Thu, 10 Nov 2022 10:19:13 -0800 Message-Id: <20221110181920.84900-6-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134448261666535?= X-GMAIL-MSGID: =?utf-8?q?1749134448261666535?= 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 Thu Nov 10 18:19:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp302222wru; Thu, 10 Nov 2022 10:22:19 -0800 (PST) X-Google-Smtp-Source: AMsMyM4X4XHCatVBNfm2qtXUEGkWAIkLlTfD1kKDmFa65+71eUTc5ysXmOgOrYflrRRM95TaXRma X-Received: by 2002:a63:e94d:0:b0:45f:a78b:f910 with SMTP id q13-20020a63e94d000000b0045fa78bf910mr2942158pgj.67.1668104538684; Thu, 10 Nov 2022 10:22:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104538; cv=none; d=google.com; s=arc-20160816; b=MEQ9gmr/Wgs2Vopaz9VEQZ5UkDRaz4cCCIYKfCxZ0dZwIt4NkShjeXJeZbqofj//b9 4obKunw4+xMcbiD4xZkCLhiAMwDSJbi7RYnCd9W29jFx4J4eFKpdxQWZsLT6YeS5ZjHW nM1hf3928OshBRpLqKXVqYR5OdKMydl+5WEm4oKJOSrAGbIEJ2EOhgQE0nUXVpTU67DS LJNiJAR9VctEDKOccIzmhg0+neefxXFqaoFFeB0zAQV7oHRsTJ7VXcpDpmEMi/kGscCo zR/WNYPy7QNn9wrxyBq9y6p0Iczyz1HY8n2u6hWj3Osyy+JPjd42RE6Wg8TcTB6j2lWE H1+A== 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=8W1IE2xF3dtxcNrj5t79DBInf6fMe+hYp9ym1CIb+t0=; b=ynOTALRzNi/WAlwqfZYS4nHGfEzDcPrU5aWxsEUy60xfgWlJCPyw8cuHZMuz7PkPnm 7l2hJePNz/teDjCYAZoA4o69xHZZvgSR/AFlKLi49DYVo5lWZvvG+2GyX6OWC8/ws03o 0wLgYBrtDX0lZ/XKtI411fzNCB9qyZintw9tBsIkfevyyE0AcDLacbJ2t6M3YItRpBZA HGSX1IX4+04F5HV0OWCwfTI27oj4BPlple7NKDPVQlHBwxqXjYSpnzVbWKst2b7CewlS thZYM1Z6tpgfgj2jB7IXs1GVBP/OzsmJbj84ZdGFarrqC9GrAI4FIBF0H8Ohw1Poc4YF qfkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YhqlzF1L; 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 h3-20020a056a00230300b0056e48944843si23587602pfh.355.2022.11.10.10.22.03; Thu, 10 Nov 2022 10:22:18 -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=YhqlzF1L; 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 S231912AbiKJSTu (ORCPT + 99 others); Thu, 10 Nov 2022 13:19:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbiKJSTl (ORCPT ); Thu, 10 Nov 2022 13:19:41 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 933F14C25F; Thu, 10 Nov 2022 10:19:31 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id 4so2180477pli.0; Thu, 10 Nov 2022 10:19:31 -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=8W1IE2xF3dtxcNrj5t79DBInf6fMe+hYp9ym1CIb+t0=; b=YhqlzF1L0IAbbvz6hY9m89EYo+kFy9yEK0/JcmBQzgk1D3UCS7dwZom64Ufaikv4MZ 0ZZ361jjEKVhtwdtTrTQWQ8KTc6UWGJrfoJ4aZnt0SxD5yHPondQPsfd2y5XLW9jvXW1 v2RRg3YAkEIOHks4wLk8rqJjFfwoZWYXHxiYf5J5DaHpoI7f/PkfcpoL8sAkbg1jhIPI wihJMKrx2ZLsy9fqqfclcsPVU9fEeQAUK5rIbCvYM4isymCMkgwOgJyuMhIyDH7xCJ1j 7kHUxFRIiEXCRQJWHWrJDuBbzlP+xp3XJYDfCyvE9N6CNegEaYOtZLrfpOum252nv8Od N8zw== 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=8W1IE2xF3dtxcNrj5t79DBInf6fMe+hYp9ym1CIb+t0=; b=eqF6FaaLrM6VaRHawIFcZyJ320cFdNuQQ1Q268K/XcIvi4gsYLMKW3CTheSV6coN1p OmiYOv27BNHMzEa5czNIZuzwtMsf+dFaq8L90cHtsz3OUxFX0oeGOS2rbpU/7icW1MqF C7Sm+mLZSlgUCrVpaS9JotFUCXO1v4IPTWxCEYZfJLDkBfVKaLrKyllvPbayI56XiKnM seApYCm2IfWlaBLZ1oPmOrVKb1Dmx4y45kZA3jXvpzwX+m23C+2473IRkvwj2BwFqt0b +exPyFPJ9OhSqYcZvDaY70ez0LAGVjj5UkGBUlvo2fAOTT/WIH+ytEQtFu8OyKrztO34 UIgw== X-Gm-Message-State: ACrzQf0mi3qPRu4EMz+KO2eaJwOpQhH/NJQxVE4ZR8JOoNzgifWHfME8 Rg51fFyQjkC6rWPr3gyH6Ok= X-Received: by 2002:a17:902:744b:b0:187:12cc:d6f1 with SMTP id e11-20020a170902744b00b0018712ccd6f1mr1630691plt.63.1668104370928; Thu, 10 Nov 2022 10:19:30 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:30 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 06/12] perf test: Replace arm callgraph fp test workload with leafloop Date: Thu, 10 Nov 2022 10:19:14 -0800 Message-Id: <20221110181920.84900-7-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134385055301388?= X-GMAIL-MSGID: =?utf-8?q?1749134385055301388?= So that it can get rid of requirement of a compiler. Reviewed-by: Leo Yan Signed-off-by: Namhyung Kim Tested-by: James Clark --- .../perf/tests/shell/test_arm_callgraph_fp.sh | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_callgraph_fp.sh b/tools/perf/tests/shell/test_arm_callgraph_fp.sh index ec108d45d3c6..e61d8deaa0c4 100755 --- a/tools/perf/tests/shell/test_arm_callgraph_fp.sh +++ b/tools/perf/tests/shell/test_arm_callgraph_fp.sh @@ -4,44 +4,16 @@ lscpu | grep -q "aarch64" || exit 2 -if ! [ -x "$(command -v cc)" ]; then - echo "failed: no compiler, install gcc" - exit 2 -fi - PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX) -TEST_PROGRAM_SOURCE=$(mktemp /tmp/test_program.XXXXX.c) -TEST_PROGRAM=$(mktemp /tmp/test_program.XXXXX) +TEST_PROGRAM="perf test -w leafloop" cleanup_files() { rm -f $PERF_DATA - rm -f $TEST_PROGRAM_SOURCE - rm -f $TEST_PROGRAM } trap cleanup_files exit term int -cat << EOF > $TEST_PROGRAM_SOURCE -int a = 0; -void leaf(void) { - for (;;) - a += a; -} -void parent(void) { - leaf(); -} -int main(void) { - parent(); - return 0; -} -EOF - -echo " + Compiling test program ($TEST_PROGRAM)..." - -CFLAGS="-g -O0 -fno-inline -fno-omit-frame-pointer" -cc $CFLAGS $TEST_PROGRAM_SOURCE -o $TEST_PROGRAM || exit 1 - # Add a 1 second delay to skip samples that are not in the leaf() function perf record -o $PERF_DATA --call-graph fp -e cycles//u -D 1000 --user-callchains -- $TEST_PROGRAM 2> /dev/null & PID=$! @@ -58,11 +30,11 @@ wait $PID # program # 728 leaf # 753 parent -# 76c main +# 76c leafloop # ... perf script -i $PERF_DATA -F comm,ip,sym | head -n4 perf script -i $PERF_DATA -F comm,ip,sym | head -n4 | \ awk '{ if ($2 != "") sym[i++] = $2 } END { if (sym[0] != "leaf" || sym[1] != "parent" || - sym[2] != "main") exit 1 }' + sym[2] != "leafloop") exit 1 }' From patchwork Thu Nov 10 18:19:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp302318wru; Thu, 10 Nov 2022 10:22:28 -0800 (PST) X-Google-Smtp-Source: AMsMyM7AboZNJATBXR6k5OijsJassJL0QM5e9xKmwp0oO5JERvg9FejBWTX9VA1dpLACcFVF8CqG X-Received: by 2002:a17:902:b210:b0:17d:c3ca:4a4f with SMTP id t16-20020a170902b21000b0017dc3ca4a4fmr63534400plr.33.1668104548334; Thu, 10 Nov 2022 10:22:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104548; cv=none; d=google.com; s=arc-20160816; b=bw0lezSr785XSjtlu8sc+BpcsBbRC77OeOx48u7DKEiCWSCQGPXco19E2K1Bobo4tK 517FaXbnAZPozvSlij1ooFKIo1xWyVJ43qv6h6UQlZmJV6Rx1Hd7FkU2R+xmL/NxouLl +nX419U26yEThsmeJrd3H90brtmnSh4/JwBtSEk3s+A12XGybEhaVluODDfdH/pZbTEt 7TnnaKkHm7vRNrBqxf2/wlAMrOPfG6k51Rnddizgd8D4x7hyZPq043rKNw830a8gQh+a OIvK9eQO7pbkc2fKz4oE0MpORqFy1xPgAyt2S0PWEHxKwi/CXCaKrLHHdc4Gk5xfiTCl VDLA== 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=X+pmvI1xzgAYs9HEK5XMlqqAdnFzxXTz0mFIAnH5WiA=; b=gV5zKsDt6/ioL5cLqZkjYytJ32xGuSX0s7Nao42qFFbAEYoINRz66+cuyNuwOaRtI3 V3dRRqQwCtmvH/qGWbPV3NZPB4WipBikVPiUkw4Jgj03oCtMAUtxeeG5BvV3y72LvBuI TG1LKyRabpF7zK64pbe/IKOyUCreQQl/gXvu/5j9bTx17JVho3qYfiNDFP2NEojxF5oR BQJ2CtVMtCnkViVclOTgLKsUbLlp7ASY8eLGQTP1WCz/6Fhr2tpXDvBPiSPQ6lagUnwi bw51pdXw++cvSesndOV+h+zhD/Qwnc789EdYnbNx+bXs+sU/2w/IKKnm5Go4eI53t8Vi X0NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SXm8mv6N; 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 h1-20020a170902748100b0018128753b2bsi19883366pll.437.2022.11.10.10.22.14; Thu, 10 Nov 2022 10:22:28 -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=SXm8mv6N; 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 S231586AbiKJSTx (ORCPT + 99 others); Thu, 10 Nov 2022 13:19:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbiKJSTm (ORCPT ); Thu, 10 Nov 2022 13:19:42 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D26394D5D7; Thu, 10 Nov 2022 10:19:32 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id v4-20020a17090a088400b00212cb0ed97eso2356494pjc.5; Thu, 10 Nov 2022 10:19:32 -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=X+pmvI1xzgAYs9HEK5XMlqqAdnFzxXTz0mFIAnH5WiA=; b=SXm8mv6NhXkEOya2FyhrKvEY7h4ot/P2kILLaBZ0B0zd2kgRzil3ENBZ3nxemj+gd2 3+7DG8IkQC8GdijkxvT9uJ9AnAFBGY003LnJSSY/RZ9qih0QPESFalwtrwyct5Z2kOZP oeOCk2vKNcAv3mAU0wjlCtOfh90nsxfHKcvyrb1jYR0yFMBfvNrXUzvdmunO/pN4PS9q PfFD9S0RDoH3PCtU7RoJuNeJpw6hboE2MuwDTyaYD8CN+hPTRloqjHKTHAnaxqx6/LWZ USa+SwanrSyOlpOdSuxyHJ/9e7NXrYUSIVVmFqxqLHG7C2davi6R595U39abpjp9x6p6 N10g== 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=X+pmvI1xzgAYs9HEK5XMlqqAdnFzxXTz0mFIAnH5WiA=; b=o0IwPXBxK/prIErlHR58LsnDq9xxAQtydgmjnF0fMJ24b/o03FtYnzjHOGfhQU6gES wj56GYZTVRwA5fUylj0Pg12U6sSmIRsPDBsoIpeRt1HMg5LNuQxwjMwBln1kXdf5mhHl rVQ5WkezY3YSWy8R7GaKg6ePmn7p586xScbSV974sGeNq6JAp6JChyt/ZXxNe5fC/8/u Qldj/+PTDaDPjkX730qS1TGhLM7/clVpydERtxIrYDfmO3yNeoHRTh1XxezJR1bf4mrl kIrkYb8sTzunRkH5cCGZn4bSeIETtvt7+IKaS7OXW18lhhu8DxZyQhqTw5NqTUD+ZxCq Vleg== X-Gm-Message-State: ACrzQf0d+kChtwru2oQSRRUR+x4SERw22HEGxXOE3lJdcQ0dRo9VqP6z jZv+qi63a6nXFzPTL9TWUd0= X-Received: by 2002:a17:903:3293:b0:186:867b:e24 with SMTP id jh19-20020a170903329300b00186867b0e24mr64818447plb.127.1668104372255; Thu, 10 Nov 2022 10:19:32 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:31 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 07/12] perf test: Add 'sqrtloop' test workload Date: Thu, 10 Nov 2022 10:19:15 -0800 Message-Id: <20221110181920.84900-8-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134394440944224?= X-GMAIL-MSGID: =?utf-8?q?1749134394440944224?= The sqrtloop creates a child process to run an infinite loop calling sqrt() with rand(). This is needed for ARM SPE fork test. $ perf test -w sqrtloop It can take an optional argument to specify how long it will run in seconds (default: 1). Signed-off-by: Namhyung Kim --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 1 + tools/perf/tests/workloads/sqrtloop.c | 45 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 tools/perf/tests/workloads/sqrtloop.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 0ed5ac452f6e..9acb7a93eeb9 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -122,6 +122,7 @@ static struct test_workload *workloads[] = { &workload__noploop, &workload__thloop, &workload__leafloop, + &workload__sqrtloop, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 86804dd6452b..18c40319e67c 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -203,5 +203,6 @@ struct test_workload workload__##work = { \ DECLARE_WORKLOAD(noploop); DECLARE_WORKLOAD(thloop); DECLARE_WORKLOAD(leafloop); +DECLARE_WORKLOAD(sqrtloop); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index 631596bdb2b3..1ca95cb0fdb5 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -3,5 +3,6 @@ perf-y += noploop.o perf-y += thloop.o perf-y += leafloop.o +perf-y += sqrtloop.o CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer diff --git a/tools/perf/tests/workloads/sqrtloop.c b/tools/perf/tests/workloads/sqrtloop.c new file mode 100644 index 000000000000..1e44d541d737 --- /dev/null +++ b/tools/perf/tests/workloads/sqrtloop.c @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include +#include +#include +#include +#include "../tests.h" + +static volatile sig_atomic_t done; + +static void sighandler(int sig __maybe_unused) +{ + done = 1; +} + +static int __sqrtloop(int sec) +{ + signal(SIGALRM, sighandler); + alarm(sec); + + while (!done) + sqrt(rand()); + return 0; +} + +static int sqrtloop(int argc, const char **argv) +{ + int sec = 1; + + if (argc > 0) + sec = atoi(argv[0]); + + switch (fork()) { + case 0: + return __sqrtloop(sec); + case -1: + return -1; + default: + wait(NULL); + } + return 0; +} + +DEFINE_WORKLOAD(sqrtloop); From patchwork Thu Nov 10 18:19:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp303650wru; Thu, 10 Nov 2022 10:25:12 -0800 (PST) X-Google-Smtp-Source: AMsMyM5s3sIzucJnPToKLbB3irOo8KdKNT/zjdSTvLIdyD5tmf6+nqn40zrl5DBv37ECfROjkm7I X-Received: by 2002:a17:902:c612:b0:186:8376:208d with SMTP id r18-20020a170902c61200b001868376208dmr64812626plr.89.1668104711617; Thu, 10 Nov 2022 10:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104711; cv=none; d=google.com; s=arc-20160816; b=AP8skLQi8mvzvAC/qkaIF7SX3sSK/JjAxlGB0mH8Q9veM7P8RbYrk77HwCTsoW0WZi bNySP/Gns1J9W5mvvJyZsr1C6M5ap5ltaxSNrzZ0oB0zg+zN57NqC6sxeYXx+s7Q3Gfp INmns4gleOP5WiuE8LPfsWvBLNlI/XtF8xqrbkUaMUvczv2WFDwgfUdMBqquEx+XoLhf /0dZ1DSYD1S80tKCVF41FaDcbfSFUsn4wgo90Tm1z/pCIlG9CWhIwRUNtSzfmTX40kHk eKwFeOsS8SAP62kkk13lV7SBJzfOWPDs6R4idIMyKoAkRw4h+wWKcq/YdExbljordLuv S/vg== 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=FODnLSuSnJC8nWqwuvg7shPnq+VjgBsbYk20eZkpuhA=; b=dG2JK5hDY4y0+j7HhMY8Hc4L5Kffvl12Nx0837xs4oPDy78LjCUFKo3CIEqKKjtiQZ fwIcV4KORDefj+wxyV3Ucpte/debzWfWp2VVov2ELhGCE1xyL0bBy1lKp9GZBT9zdh1T mjHoKilvxkgwJb/vxgefdzHrdXwvFSmXsjJcqjsEuwGeJQT1B+ZM/YO/NsHtlqnkd8RP FSV1iexcpVpWx9lDzX0pcbiDattC5T/Y4dnLSKA4tqX85qBn9e7IHm8N1eN/wpk3dtU9 EnvYXW2UNoNWBHlhUafNP5WaQJwhoXoBMODHW9FJTHemBjrcBsemFXOKxXPkDLqZ6xkJ bZeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jT8M1/wh"; 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 t14-20020a170902e84e00b0018685257c0csi23588plg.121.2022.11.10.10.24.57; Thu, 10 Nov 2022 10:25:11 -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="jT8M1/wh"; 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 S231975AbiKJST4 (ORCPT + 99 others); Thu, 10 Nov 2022 13:19:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231886AbiKJSTs (ORCPT ); Thu, 10 Nov 2022 13:19:48 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D1894E40D; Thu, 10 Nov 2022 10:19:34 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id y203so2858406pfb.4; Thu, 10 Nov 2022 10:19:34 -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=FODnLSuSnJC8nWqwuvg7shPnq+VjgBsbYk20eZkpuhA=; b=jT8M1/whbkeXDZtiqh3HyRJML6ytB5gkJNQTgcFjlwAqfQqa+qLL+b42Tl8u9Aevt6 WbH0MQCRL1vDsFcxwh3g/UIAXK1Tk2f9x+9mvvqGQJy0CLdOIF6gFTVRWtRcWN5ip5Md e/LF13TYoq/D1nWImPpNTuHUrj9+Rzsbr5uRk+nNjLsUdK2FWspWLdinwCf2IYZP98CV ENRfZdX4ZfgGznrv/Vx/uQD552heVX2JaFKcCULUmP7JtfjYs+/Wo53aT9hhTrDVhQJe 3V2+tmECwiClHpZulzRuw3LG1w4r/d6enqsyDcPr1fWLl5VyhF3IwZUQzxSxMGZJjkmT XTSA== 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=FODnLSuSnJC8nWqwuvg7shPnq+VjgBsbYk20eZkpuhA=; b=DYG3uHmuxXG7EuWg0vWdcXr4bk/BsDG6UKZJWqzyu0uz6p4C5PmDcZoI2ZRVlQRTur Uq0wFl8v0xFNfHF71z9DWWQhAg5OoKtKDo6YW7A3AH+N8Tsz/6ynFBZXLA3Ae+vmeiyi FZxTr3YFIbqBaaOQ4hc4J/2HgerEgwl+1z4amWJnL7/+nTz+0m24HdmHzzmOFJV9DyBW IylwsHTVQdXqvJqXFw4WhFpHYJL8dfDX9qEtpAD1Td5BYVOfnfB9AycxsgK0LajJnLy0 aOKsYL/oQtTCvmovrs1mL9Wzj8TbePobA0vj4Jq3vYVyOZvxz0tL8u/p2FZMK3pNLuOh 8mvw== X-Gm-Message-State: ACrzQf2uDJmThqwaz1YRpRiPkN8VjKHGotihkFQFu0ZdTU/xqaT0Efv8 mnlEBLRXilH70jcFwqdO6eY= X-Received: by 2002:a63:ec42:0:b0:46b:27b0:c245 with SMTP id r2-20020a63ec42000000b0046b27b0c245mr2996232pgj.611.1668104373617; Thu, 10 Nov 2022 10:19:33 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:33 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 08/12] perf test: Replace arm spe fork test workload with sqrtloop Date: Thu, 10 Nov 2022 10:19:16 -0800 Message-Id: <20221110181920.84900-9-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134565687345368?= X-GMAIL-MSGID: =?utf-8?q?1749134565687345368?= So that it can get rid of requirement of a compiler. I've also removed killall as it'll kill perf process now and run the test workload for 10 sec instead. Tested-by: Leo Yan Signed-off-by: Namhyung Kim Tested-by: James Clark --- 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 Thu Nov 10 18:19:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp303950wru; Thu, 10 Nov 2022 10:25:49 -0800 (PST) X-Google-Smtp-Source: AMsMyM4YbsYxWq0C+v8vwv7GWMUMxWqrdZw47oA1g7ZizduTCnNCFlLJ9OPjn7dtXdo0Ybau0Jh+ X-Received: by 2002:a63:ec02:0:b0:46f:a989:ad72 with SMTP id j2-20020a63ec02000000b0046fa989ad72mr2956569pgh.430.1668104748844; Thu, 10 Nov 2022 10:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104748; cv=none; d=google.com; s=arc-20160816; b=DwNnzyHDCaQn0DodviIpi1ZetuwIRm4gC26OLZjD8OLcwggZjU4szkVHrJVPO0EGqQ uKMJu4M3LDV+uEDnpvfQCfa6bUS+OzrnxhMgc87JKBXQRKMPGxAB6+yRSnPpYOl7RkTc pYsUao5NpH++N522BRTrXS24qck/ajuLvW0nTmk3i+7cyp4BwZlRw7rW9fwRUuOYQlcG sn6Z0iIOkB6+hlVo/ua/n4cBDUQ2aK+0u8kyvHKH13x7Henozr+CRnp/P3fnpOlCw94l +1270uHwBmTC4dX3R5HzfnalPf0ALjHKOkWtokqiZQFdw7WmtOc38/MsjemQM21vILRR wm6A== 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=Ad6CYrOOdzs5XimR11K4fWv4D01X6+lyVjHOyaLup4A=; b=xTSx4zI/Hs5fbcF3doRiQ7fYELWCIMVNs6SLhohhCmZMnOzP8Y21TZdHwXGWZTl849 yoSDJ0Y8TBP3TzLo1bubz9A8RbjBh75AJRElt2MoH0HwmT8Fo/Ps1ZHEWkcTNmv4d1c8 78DYcJeHpc33yFuVFEs3aubBQXpUOAkLNcFf6AecmaL6ZRiOfPCbKT770E6SD0p5UiKI y5Dls1rblt4ePfWr5S7recqSOeYMMUar/k4aKvgEOVwDKl4B1Aw0M0awmjZ0s1Th15uT nN3HcY1ZH6alpKnFdbwKekNmJhAIW5IK2M5YMRq5fDFWIXfCvKTBxj41hV1FwcN20Bdt rxnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AZHPUnF1; 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 z14-20020a630a4e000000b0045650af278bsi21225669pgk.817.2022.11.10.10.25.35; Thu, 10 Nov 2022 10:25:48 -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=AZHPUnF1; 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 S232019AbiKJSUG (ORCPT + 99 others); Thu, 10 Nov 2022 13:20:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbiKJSTs (ORCPT ); Thu, 10 Nov 2022 13:19:48 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACC684E41D; Thu, 10 Nov 2022 10:19:35 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id e129so2478809pgc.9; Thu, 10 Nov 2022 10:19:35 -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=Ad6CYrOOdzs5XimR11K4fWv4D01X6+lyVjHOyaLup4A=; b=AZHPUnF1x4GURYsUY6xefpVfUR7702OIutkbc4opdUOJCqeqTkFO99CQu417+Gcp/m +Ius47BJMJxks6g4UyQaX2+H0Lc3bEVFhK4xv5h+9pqlVi/5n9JgA1rlANhg+rx7r7oh yJW9yjVg4ZeTSRA1OCMry1ihGhzAtGhgPHJaHzyAftBBHeNDlN5Tsw9fzDkInWVoe8h8 +041TWlJWDneqzBwWZzRQfVBueNXRJOPLqUlPsKYSRtEZztwHS3xSUxuPKPS4Epw3hKY a32V5c2C3HXm3+STKIYPplKJSBrx31MhrGTLH3x/VzNV9dNqqDxq/0AqRdaV66hBqBlP xGwg== 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=Ad6CYrOOdzs5XimR11K4fWv4D01X6+lyVjHOyaLup4A=; b=JuAe4rgkurvbF7s44OtRcF/dyJN+QDwYjssnBEKSIbfRyi1Fa0A3Ru5GeWlfb3lAxo BlWKyvqcSAq5HGs6bV+wH6KLk3gsHcYC69SCXBjceORjn5hbTOAlUJN4bN7Ci2zzS+Z3 BzeCS2SuiVpTR4DpRwf3F8pF6/xgf4sj9268gUn3GyXz48bOAYv9pLfJ7i0P8bowVJ5R 1Mn1o+PiiCUp9sFjKrV7bMl2VDlDsv5Px0AuYzeGWp8WNaRmqHxPwoVcOMC3ses7qZ89 P0dJ+mxPTx+Q5Eso6aG4ht1mDIS9R3Mec0e48hQD0CNvMpSbV+PmYlh6jwpUDIZnFWYV SIaQ== X-Gm-Message-State: ACrzQf3xluZ7tqJ7/nlLUeumNZfVMZH/7dajCsnfgoOqY4pH4AgRRtdf 5r63NBUOm4Fo3j1IbLo+p7o= X-Received: by 2002:a63:3d4:0:b0:464:527a:5796 with SMTP id 203-20020a6303d4000000b00464527a5796mr3019420pgd.38.1668104374830; Thu, 10 Nov 2022 10:19:34 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:34 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 09/12] perf test: Add 'brstack' test workload Date: Thu, 10 Nov 2022 10:19:17 -0800 Message-Id: <20221110181920.84900-10-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134604925140954?= X-GMAIL-MSGID: =?utf-8?q?1749134604925140954?= 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 Thu Nov 10 18:19:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp304771wru; Thu, 10 Nov 2022 10:27:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM7DHZR6lAeZy6pajbbmb/EJnQolTmJ5qOnRbUVEA4VZUamfo5VOSSShrfxFv9uNYjplR8u1 X-Received: by 2002:a50:d6d8:0:b0:461:7b63:b378 with SMTP id l24-20020a50d6d8000000b004617b63b378mr3062946edj.63.1668104852056; Thu, 10 Nov 2022 10:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104852; cv=none; d=google.com; s=arc-20160816; b=BD6tmk2utkA/NPck0AFayW96onCbu3Y6TUFjWGWqBMWJCZitPLFCwjePWm7BVHRVk7 3jvZrfl/yA97Jum3JvQ96279f0bdvlBdWLv1t05nvHb6o7V0+n6c9EVUy2NTJkEx3tTl D7mzlK+vz/G9x/VtNgniFLDHsCxW/MtHz7tXxMUiitjbmZVf7lbJtvzd3ZOtDmycQZr8 PDD3ehlVKJforf026R/eggents86GxlsqK9uaSLhg3LfcrQlGDm49/dxmq7GGfhGUDds 9ZbHeVr5AcZ/PrqZaJeUlpTpCdHZrxLQY6DLsnfULXyZWwuBLn874oaqIOowgB9IVqWe xSSQ== 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=sVha7Zh/4iO9cmJI/CriQtLmB6U5f2y65t9ftbB7Kko=; b=Gy7WmCHNgErarxC4TxDFNm/BOgNK2Lv1WQtZltCjDzvaiBH2a6ijW3gv1SMnWB2CRX 00206O8CSrYMvkrkVP3kAVD3NPcEAUaBzPVpa8bRZK/4dX63dkHoj1jOXhIKse6Z4ESM DA13oQSw5lS1yMZlpimeS5YS/3l0TgC8qZRpGcprV0+tccBN6b+zslicKduGROR1PTkJ cs5r3Aqrcx2RYPnWBaonHHuBEU8l89Tshv1xhi6r0UcK7Bw7NbehQeotIY4iG7KsWMm9 sm70AE1eI/gULs0aq/YMmVLtsg2/GoeYG/RUj6SjQeT1+JM07iiMGEvN2hD+uZi3GyWM x7xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EfVnLhpi; 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 d14-20020a50fb0e000000b00461d2ed78afsi202924edq.563.2022.11.10.10.27.08; Thu, 10 Nov 2022 10:27:32 -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=EfVnLhpi; 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 S232067AbiKJSUK (ORCPT + 99 others); Thu, 10 Nov 2022 13:20:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231946AbiKJSTy (ORCPT ); Thu, 10 Nov 2022 13:19:54 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C584E43F; Thu, 10 Nov 2022 10:19:36 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id m14-20020a17090a3f8e00b00212dab39bcdso5547321pjc.0; Thu, 10 Nov 2022 10:19:36 -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=sVha7Zh/4iO9cmJI/CriQtLmB6U5f2y65t9ftbB7Kko=; b=EfVnLhpi1R0E5sZeqyMN/uIQBCDSKLb686lT6TJ59s1kq5px6aCEgCVQ0xW2ocZ4Kj VC1j6FcgDtfqt9vhOCE0vrb1hc7bmRKdnhtO6EI5RhoJkTZ48pcfoPMVunw7WNfO4J5F EQypLnoXvySntJhRylbos43z2yFB0bFt/NoIujtgAbx9+s6dEkMQ40E9hAYtoC9rQatl NLkzpQECtWStnluM8RQkmJtfVELo7ngFHYQi4BFrbUuVrMEzYO/nE0Yq2RY1qAnfy3rP 4FGAiz5Zd+wmjJQvBG4WTogY/m5s7h9youdKHl8RGYoNUh/TjGJW5eOVbdxytmi6uh/B 7VNQ== 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=sVha7Zh/4iO9cmJI/CriQtLmB6U5f2y65t9ftbB7Kko=; b=YwJ/md0yfIVcuahyDRZyXWDGfOTanANkKepL7q9UmptcgOB+4WGm0CdJ7a+0DUscor 8u7Wme8pKce/Y1wcmPw1ss+MHctmB+SaqgRAsQwWZXPULU1mZJmIQ1czf2eIC4Wei5/9 9v3WXniFRBUXsFNaKEz1CMDTZ7Q4ki6+vzQkif/nQYjVvQM5djDKbNVcRWoC1IbbeDiz VlLcu8yz1VmZI31kLixZdwhjzna4UDywe6Pc07MpyKDDUwRy4VpzMQppbrEODvOTWGeL AUFB5dzf043EiqRmKN9ingmWqC44Fh9wpq1m28XpNvgH8l+eUDXITvRe0QU/abYXqQxJ LGDw== X-Gm-Message-State: ACrzQf2JDjwU1nYDjPOkhiW0tY3cNoUTQTS3f4Ef+5cB2Vyr2xQKuFyP HzwDmreAoP0YQDuPohiEz6U= X-Received: by 2002:a17:902:e5d1:b0:187:3593:a86f with SMTP id u17-20020a170902e5d100b001873593a86fmr49893281plf.15.1668104376051; Thu, 10 Nov 2022 10:19:36 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:35 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 10/12] perf test: Replace brstack test workload Date: Thu, 10 Nov 2022 10:19:18 -0800 Message-Id: <20221110181920.84900-11-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134713765896972?= X-GMAIL-MSGID: =?utf-8?q?1749134713765896972?= 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 Acked-by: German Gomez Tested-by: James Clark --- 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 Thu Nov 10 18:19:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp305077wru; Thu, 10 Nov 2022 10:28:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf6aCE+FYiDs4UwPt2uFUjR8cb4pMclH1uU6i5iwzw0fontQ2HiQH3GcfBBHCvZPYXFw6c9J X-Received: by 2002:a05:6402:170c:b0:467:3ea1:acdd with SMTP id y12-20020a056402170c00b004673ea1acddmr92612edu.96.1668104888720; Thu, 10 Nov 2022 10:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104888; cv=none; d=google.com; s=arc-20160816; b=WbNHUP08KUxceo7eZRyHq8Lz6dl7/jb2yfBlxgKHX4KeJ0hAqoEv4AiR2DntC7oCkZ afw9HdtNuPCwo/zBqNy9hslhJOpPQ6/BeIoW6zK40VqDiY+cCVW4AMWdDTGwDdETx2g7 URIyvIKm+qEdBBsKM1RJIz621uu8riJ8FtIumZrCElX4J/OfrEpHqR4I6F/Yxoil3zXX GrfOQZL9L64SOSSn18Vc+5zM73X6ROpwfp4iiJ+8pI0t6XR2jOq2PGE4qqnev3A33ZLa lGks33W+oQZw11ZnDoXwoo3AI3C/TCVWNEzcCCC7vBovKejoR5vwPGyWneovH9v9Rm3P owuQ== 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=4HtB7zBK4yjfHRJqPzKBOzWxy2usXPdRZk3LDGweMME=; b=PCWZCJmPwURITzWVZ9QH4UbdrTsg/FaHEXurpvR8KEHDWo/1BpI5MhHdLEXgIMbHQ+ S+JykwJyEevJnK2Nu9YuvN0OJ2Vmj78V6FIW0cRYARAjVj5330rIrYTmwTOs/20TPYcu HgFAi4yD1X5cxV3PsqaI8PPhGWa4t+qFeAYxtvE+Mbpl7KzQ5g8sICicIqSfTeXggEuH Zjrcf7gK4oSkJm4U7zJhFNC7AZ5vzXgT7JunArQJ/4qCGEUmWCk+MsrR05NfT1c85USX bjjnSwoPjZNAGdE/TxG24erWd0qlWa6iTPTilUSz+vnjp6eqLVl6tcXEsuywwukpv/vE Ulhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YvN+8vlK; 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 sb3-20020a170906edc300b007aa5e6c4b5bsi18884ejb.164.2022.11.10.10.27.45; Thu, 10 Nov 2022 10:28:08 -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=YvN+8vlK; 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 S232094AbiKJSUS (ORCPT + 99 others); Thu, 10 Nov 2022 13:20:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231890AbiKJST5 (ORCPT ); Thu, 10 Nov 2022 13:19:57 -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 1366150F23; Thu, 10 Nov 2022 10:19:38 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id b21so2123030plc.9; Thu, 10 Nov 2022 10:19:38 -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=4HtB7zBK4yjfHRJqPzKBOzWxy2usXPdRZk3LDGweMME=; b=YvN+8vlKYLlTN09A35Q9vSR20tjer/GsyGD+A/sxIO3o3J7xtlR9usgukuAb/oh7gU ROvtX4OSh2AhmONRGDjFo8Z3/IHSUHRSaYSwsc9XjQobbWROTDTF9xJvCSK02gn6rBnM 6BcYwSzQoyFAEWlqWlxCIeq9H+nkzC7YhRvqIKn6JGC4zOEfLPkRyMufb5R5tTdDT/a/ +wCiyhqsaFiHBgfREkzHpFZNNeqDMIsXGxoWU6mQu8vy+IKk1wBZku9DBjdG5zs0IS8Y 3c22cwyiFEbYxV5B0rpAQyM2Y6KHapUvKd3jGMU1ItnO1bGbU0ewEVHZ3H8SJirlekGk CrPg== 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=4HtB7zBK4yjfHRJqPzKBOzWxy2usXPdRZk3LDGweMME=; b=XsOivvjWciKJxBcClo7SQEA3r/4KlZ/rEGfFqjSo8Xxc4KcJW8DguGCHWlZgkGNtuP FT57X5iwH6WfcImXoeQoJGhLeHhslukIMLybqgE2tR1KoJIg6ZgLoiD1bfjLC4L4bXtd rmGiWGqEs+9SNFta1/qns6S/akkwQNm/C4KdVHI9o4BZj2EhtLAeAeNA9u31xwcd0CRp W9eJr0/IlMbaOf+48sAuRzO+e85fXxd977O8AzJfyWKblAJNTprSqmr3VzjeSduvfvK3 YzGl03IIRyaketfc7FjzD4KaAA//vvGwOZCBp6nQh+CyoV6bgXCnMwHtB57jKSLdC8GB rnFQ== X-Gm-Message-State: ANoB5plPImx2HfWNMMVvUpYVxZtUPvS3KxVmVBpyoXeZ2FySeXGKvMbg n4fZOBRmwaJDO4nz74cnuQ8= X-Received: by 2002:a17:902:f804:b0:188:a1f4:a18a with SMTP id ix4-20020a170902f80400b00188a1f4a18amr1335025plb.128.1668104377358; Thu, 10 Nov 2022 10:19:37 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19:37 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 11/12] perf test: Add 'datasym' test workload Date: Thu, 10 Nov 2022 10:19:19 -0800 Message-Id: <20221110181920.84900-12-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134751856454386?= X-GMAIL-MSGID: =?utf-8?q?1749134751856454386?= 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 Thu Nov 10 18:19:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 18280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp305399wru; Thu, 10 Nov 2022 10:28:54 -0800 (PST) X-Google-Smtp-Source: AMsMyM7SwKJnw8NIJiuegiV1fvjl7cgJqDRu28k5zy2mNbVrsGGKPknNsLKWFEh0E6OSNINZlDbH X-Received: by 2002:a17:906:3054:b0:78d:585e:d183 with SMTP id d20-20020a170906305400b0078d585ed183mr3394251ejd.768.1668104934239; Thu, 10 Nov 2022 10:28:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104934; cv=none; d=google.com; s=arc-20160816; b=YLJKkfHPxHER7aif4bgVR30D39WBiuNFbO3/f5yE+t2K21NI5p9vo5ckyV+pmMgapl wxx0kT8s18zYL+E5gcsebM5JrG/ZrkmoALruesHIv7t7lDkuU7ZoAcG1a6awHPDkpmYl qtDGkMlAWS0W8SsKfZ83VgOo2k6TMoQoZG4OxL5qme0XBPSN5ACRHouvqQzuNL0JmkZl hKOmH2/NcdUw4U+DxQ3gJc1bKOqWYyy8OMU4mQhc24CeNl4abXVTQag22CVcganHjOkh YwSHcenlLK6SWkZeqYqrFnKSNnhamMtURODB5tyLY2kXUcGeFDE2qrK4xLM/eVTzhkr+ /6MQ== 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=Ktjc694U1hBp6r3wDR+QD4vHKh9CxqERsaJjaU1PQNI=; b=mejaSXR/uH3j0hlxzWxY+HHbO96q955q/wB/2Zw7P7X73fSKphPQE+nvRHnnvQ6+ks QdPhciYdrpiS4x1g/WhZobHzRRJT9aofIqhE++7Xf/7hHzUs2McBSTCddXE0FffESlpe d3gcZ6TllnyTl16fvDug3wrv2zwNRR+PW/l+zNMRCY4Htkj9Buunyl6SdFQXmkgqkD7K O3gJzo0hiTS7vZ3Vp5SXwzPALsszOy9EoYVK0vsW/obWsidGJ0gvwCENEYJHWV8PoFwf k+Aw7NeJjUxUmBwY1z6Vs+g5H7HmZQOgwGqgBkvVefFu4aMzlzn8FaopCpZEQl5TrZvh 6E9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YmcdUFeU; 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 wy8-20020a170906fe0800b00791a7e441a3si18612132ejb.459.2022.11.10.10.28.29; Thu, 10 Nov 2022 10:28:54 -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=YmcdUFeU; 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 S232126AbiKJSU3 (ORCPT + 99 others); Thu, 10 Nov 2022 13:20:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbiKJSUF (ORCPT ); Thu, 10 Nov 2022 13:20:05 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B5D051C0D; Thu, 10 Nov 2022 10:19:39 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id l2so2108942pld.13; Thu, 10 Nov 2022 10:19: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=Ktjc694U1hBp6r3wDR+QD4vHKh9CxqERsaJjaU1PQNI=; b=YmcdUFeUMM8Ol0c17/XE4ouho/c+5RomMI22FzqXEkqEaWfryDP69ZpQMJ9Vmcwm8m fIQAAXoGRIYJmustO9mq1ls2lqESUdYeWXeS8aHA22WHzyeT14cjAJlKeMPVV2pCGiAf cMLPUh7CbNy0q38zpcdkQcj5sFl4KkmptSVWWRvT3jv5l9HaXfs0fHFtYKAqCtE3G8JN VPbs9ACAqQZd7AtBTAdZj8jiAsTrKVwlfpqmmspYDoObmQUmejHK6mAxzxuJzT2IzkE5 WuahiX7p7NIbVx+auIcpqbx+ErxKjxmssN4GdlUnymd1ZHxQ8u8a9DxXCS1IzbX2T91d Vp9A== 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=Ktjc694U1hBp6r3wDR+QD4vHKh9CxqERsaJjaU1PQNI=; b=xaL3xcJedUK4dwvn9P1p83Xq80vaBH/O+ljpAOtfy1egJtEVWtdSN91OUU4Y8rcYc4 sDtbWR2laLouheBQQCuOh2LGACHiqSb2TnSneJWknYaocXqStOfJ4IzbgV0M67pLZkl0 qVGC6V2xAMe7XzTixgfw1WOpVMt3HyhugjaZuONMD/CcKJGpruIw81hktlXVeC4Iygzl DRgs2Mu0iSb0oB7veucFHYRs2FL2oGAUroyqf6bvZxWpD2DBit8k1/Ltk73+++j0mFVP QxY15dvvyQm7QzFDYUalLHd6vpq7f1UfGbYjsB5NKbVkRCWNYIWIrn6m+ktz1jg07opS DBJg== X-Gm-Message-State: ACrzQf2uDQzL24thq5/ruXQv6EQy08/Ct2M1Vi3mYBINspTxV5aM59oO TR9YKSEV3ztJkCA25vyyGGs= X-Received: by 2002:a17:902:be03:b0:178:6f5d:e979 with SMTP id r3-20020a170902be0300b001786f5de979mr64611722pls.163.1668104378705; Thu, 10 Nov 2022 10:19:38 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:12cb:b694:b3d8:467c]) by smtp.gmail.com with ESMTPSA id e9-20020a170902784900b00183e2a96414sm11518744pln.121.2022.11.10.10.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:19: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 , Athira Jajeev Subject: [PATCH 12/12] perf test: Replace data symbol test workload with datasym Date: Thu, 10 Nov 2022 10:19:20 -0800 Message-Id: <20221110181920.84900-13-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221110181920.84900-1-namhyung@kernel.org> References: <20221110181920.84900-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?1749134799616143635?= X-GMAIL-MSGID: =?utf-8?q?1749134799616143635?= 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 Tested-by: James Clark --- 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