From patchwork Wed Nov 9 17:46:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp475097wru; Wed, 9 Nov 2022 09:50:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6MEvsJ+El/fwSBiVGcSe8x9AG5T616c2+GLnI8rbvmponC8LM0cJStGuhzg9U6ImBZmnL5 X-Received: by 2002:a05:6402:27d2:b0:462:8e41:569c with SMTP id c18-20020a05640227d200b004628e41569cmr19885335ede.191.1668016256911; Wed, 09 Nov 2022 09:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016256; cv=none; d=google.com; s=arc-20160816; b=TvWcPyxYV/1LYJAulreek8jRIsrXOjFBgS38KFoiJwK0mQe6gsPd4ByUPKUiNehsgx sACX8Wv6WuTM8AMD2XTMvlXVX1MdkKr4tvHiqQKgT8de+9IhKKNw7fnUmCqRh1GICKW7 m0sh2pwGwDm6OBZpJXr3M1/DMkO8CD/7g+a+ddwPivl22t6TO8btEUXnegV4K0HSEHme 8aRZXPJd2neNG+70xsKKft/dRyloAB0lg0t9n/X3Snny9QTg6AEvZy70LgtJJbOCMQuw ZBal1hoANAKv2WQlvp/Gg5ZEDoIeFQe8QAB7btWiCuuN5zVG8P929ky/le96BZV/2LQ6 4liQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=6ybVelHPiskCNH6fllR2RvI9SCAjZ5b8Tt7/oz7w9lQ=; b=du1lxotJXTm9LZUIALaMH0q1R1B2Zf9AKLBm2FpRpCNNTafCu/2sDTU8sIl7j9Bmrt QjGx3JHdgspdax3z1T9icAY5Et5y3ecx2QDgJlmGenX2UqLz6SKWI9pshVNJEawcml2D rxLQqQH0nLw9SZ7dU1LXuPxizL6fuy0HgU7TXgW4PZKZkuUN485RAQqqDxg/JmP622VD AuLXIAHuXnsmB1wxiLY+GdFtf6zD5nEV13RvOJiTsBAsa0q9aZwIMTTEfoLH0E5y+LCp MZQw+kle9Txp6WoUGVPyak2TeZygREDzSCA+0weJEVCqBbKeRUGokW1FRuN8I7Acom0F coFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=geMmBOuP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga12-20020a170906b84c00b0078d9cec6a5asi12243519ejb.191.2022.11.09.09.50.33; Wed, 09 Nov 2022 09:50:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=geMmBOuP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231856AbiKIRrP (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbiKIRqu (ORCPT ); Wed, 9 Nov 2022 12:46:50 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95ADC659C; Wed, 9 Nov 2022 09:46:49 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id b29so17354695pfp.13; Wed, 09 Nov 2022 09:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=6ybVelHPiskCNH6fllR2RvI9SCAjZ5b8Tt7/oz7w9lQ=; b=geMmBOuPjKLU7pZSlNSnodyozLusn2++H+Pw70vxMxbmq15wKDGv6FL5Z/ll7loMfO mykYxcAlwZu+6RuzIUfhDrT4FqpyCcE6ArZQs+zEorfLZKbKzLQxNfzje7SNyx0BiM+k r1s9Jo9YixWegrENQn2JhWwexzwFrbZqqxt7vgD3ciVF775rFb+LZVa0RXSFnDE1ejWR p2LspXjdsXc1Rr1SeQKdKUk19DcSc5gxX0esRx7M4RA5Xb/rRZaokVDKpU2wkNnYR5j6 l0BEFwS64dW3GjiMKfidGR/FsI31Hq3ARg9vRtkKbn/oOefG1QFsoDnU4/zme6KSRCfk kk6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6ybVelHPiskCNH6fllR2RvI9SCAjZ5b8Tt7/oz7w9lQ=; b=uh+eq9DYtTmyBE2o2SoMUGQBj2CIX/fE69/Geul6vfPVJ7/AfW/bqzqjQwDWA4gP9P uEXXGIw4EvS0XwpHIegyK9IsXxH0hWj+p4K0dlJq6pjX5CcVcgSKHRNT9G96bSu1LKZG cMFM8xAtG5L+Mf9sFpKm16FVHRkbU+kbIxr8Zvtdd/Jr4iFzNG6SkdyI0lbpfQS+ZwTz 6GCX8luIkJe9FzcViGXkTvYHs2OHNEGpVrJy31D7siGjC7Y3VhcaqLGiYRxojM/I7/96 A0hjjaH2uSOU71+3l0z5IvhgwImP7/2KlA9e704ORsKbp1UQ02tk7d3ERYuKZSWTYRdo 98Pg== X-Gm-Message-State: ACrzQf2gmbp4xy+5D96KozoCiKx8SKKxvsVzh7LeDleHbt9Qa71d7n0q HzmLqoPAqpHSxQpSmMWH1PDYJICamuk= X-Received: by 2002:a63:1206:0:b0:470:18c:1489 with SMTP id h6-20020a631206000000b00470018c1489mr36187235pgl.357.1668016009081; Wed, 09 Nov 2022 09:46:49 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:48 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark Subject: [PATCH 09/12] perf test: Add 'brstack' test workload Date: Wed, 9 Nov 2022 09:46:32 -0800 Message-Id: <20221109174635.859406-10-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749041814319041151?= X-GMAIL-MSGID: =?utf-8?q?1749041814319041151?= The brstack is to run different kinds of branches repeatedly. This is necessary for brstack test case to verify if it has correct branch info. $ perf test -w brstack I renamed the internal functions to have brstack_ prefix as it's too generic name. Signed-off-by: Namhyung Kim --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 2 ++ tools/perf/tests/workloads/brstack.c | 39 ++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 tools/perf/tests/workloads/brstack.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 9acb7a93eeb9..69fa56939309 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -123,6 +123,7 @@ static struct test_workload *workloads[] = { &workload__thloop, &workload__leafloop, &workload__sqrtloop, + &workload__brstack, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 18c40319e67c..dc96f59cac2e 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -204,5 +204,6 @@ DECLARE_WORKLOAD(noploop); DECLARE_WORKLOAD(thloop); DECLARE_WORKLOAD(leafloop); DECLARE_WORKLOAD(sqrtloop); +DECLARE_WORKLOAD(brstack); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index 1ca95cb0fdb5..c933cdcf91d1 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -4,5 +4,7 @@ perf-y += noploop.o perf-y += thloop.o perf-y += leafloop.o perf-y += sqrtloop.o +perf-y += brstack.o CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer +CFLAGS_brstack.o = -g -O0 -fno-inline diff --git a/tools/perf/tests/workloads/brstack.c b/tools/perf/tests/workloads/brstack.c new file mode 100644 index 000000000000..61c9a9f24b43 --- /dev/null +++ b/tools/perf/tests/workloads/brstack.c @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include "../tests.h" + + +#define BENCH_RUNS 999999 + +static volatile int cnt; + +static void brstack_bar(void) { +} /* return */ + +static void brstack_foo(void) { + brstack_bar(); /* call */ +} /* return */ + +static void brstack_bench(void) { + void (*brstack_foo_ind)(void) = brstack_foo; + + if ((cnt++) % 3) /* branch (cond) */ + brstack_foo(); /* call */ + brstack_bar(); /* call */ + brstack_foo_ind(); /* call (ind) */ +} + +static int brstack(int argc, const char **argv) +{ + if (argc > 0) + cnt = atoi(argv[0]); + + while (1) { + if ((cnt++) > BENCH_RUNS) + break; + brstack_bench();/* call */ + } /* branch (uncond) */ + return 0; +} + +DEFINE_WORKLOAD(brstack);