From patchwork Wed Nov 9 17:46:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 17725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp475181wru; Wed, 9 Nov 2022 09:51:07 -0800 (PST) X-Google-Smtp-Source: AMsMyM6gUOElCKO/h/Gtu+Zy91pKW47WlnEam26F/Zrkt8bI5ynr/mHSp4gzOmmXSHo4lQMNrygB X-Received: by 2002:a17:906:bceb:b0:7ae:75e:3929 with SMTP id op11-20020a170906bceb00b007ae075e3929mr36325510ejb.400.1668016267660; Wed, 09 Nov 2022 09:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668016267; cv=none; d=google.com; s=arc-20160816; b=qh87JsYo41oUs6BiS/JEzkIprpDEJ9UF96fyOy3jzlpIrfslLBEnGkjjPpCTBnvuSk WA2iQaIAjqpvf9SV5TRQcpJ9GJ6aLeEG3a4sydn3ReEU02REi9SkuWb5oA3G0wj244eW 1NV3xOJJiDSHzDnt8Xo9D/4GXVSn2HXwTptwb42/diABBtWxUiAqFseIxwq3lNMXtm1f RwvGxeQHXH6g/fiiopB73w8lPJM4De6/5DLT88xjp6ETGyfJetcHBwSOWdjiijdU546a ESSE3Y6F+qDjIZcAVA3G7J1ShVjq9YVo3CjPQallPAm7soxFvBETS1XjhrWexCQV1B4I NSQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=CiF3YnCQsrF/gvWg4IJtalMbBErjLNwZf+63Zgv2mbg=; b=X51QgSR6eyxAGcNz5c3uYwX+4e4MYtt+egIDTcpvcAAcNNc9neAAUD/2hi6nM/Fs9T kKFCim/e/racTZLp8qMxSEld87l/KVVuRAKLlkMAZSqwWrJiiIPF6JFJAXXQJDFrWtb7 3C6Sla9lG108Vo07QYTzc4/Q02dsqvfiVplMOGEUC1n4PWfbfoTm8eyjagHUNwI+SsvB HixFDnWsk3MTD0wXCxpMl9GSdz4NuVw/BYAze7Mgo5FbP2mOh3IzM/Wu3OQDiBA5+okq CgX2npgHpIRCfoXidlBflGVBG16H9avK97pnwH2hdDBzMGVp+CvaqR6FVwgpu6SbGJJ1 IUXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hatPA4Xt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ek16-20020a056402371000b0046453c385e4si13829157edb.365.2022.11.09.09.50.44; Wed, 09 Nov 2022 09:51:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hatPA4Xt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231886AbiKIRrY (ORCPT + 99 others); Wed, 9 Nov 2022 12:47:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231836AbiKIRrA (ORCPT ); Wed, 9 Nov 2022 12:47:00 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B4726562; Wed, 9 Nov 2022 09:46:51 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so2532197pjs.4; Wed, 09 Nov 2022 09:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=CiF3YnCQsrF/gvWg4IJtalMbBErjLNwZf+63Zgv2mbg=; b=hatPA4XtREHlwkvzVLI1nc18tp1XpKw8QO75TiIhdxakEb7zyL+K9819A20gtZd9Iz iDOEzWXNwExj2Ok1R2tYpZCP516eHXzdIRpBJeIyao/q5PvPFA24rT0CXywDscN5zReG bBFkRKyERzXOQ8AOnSIRkESnQjD1iHvV7zsvbW6Fr32vjxVta/8r//p8O5rq3tJ/wrwK y0k4M/Zq6a+fBTysACsAAhiYerzTF7hMvbn3uzeFx3XODCf6UPnt8TV/PflZouKJT6oN FdythhovjLJe836zD7bgZNpY+kbUnSQFK+9RfZ1PE8Ky70T+UadFOrw8e0QZkOgJUfI3 BtIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CiF3YnCQsrF/gvWg4IJtalMbBErjLNwZf+63Zgv2mbg=; b=YJjNtRM18DeJS0XMU9CSn1NkzKCEn8PL2zUASK75fLUj/kbjglo5BP+Srz2UdaLGO1 wMbWzGbARPn5n//2z2yr4U4OcRaPF1/gI7gAVKKUJpW5jPNzTk5g7yAa8tKTDyY39HfF N6YdoQepP2yBFG1bHzTKUwxV4+7yyxx0BrmRU+o1KH51kGnu36fLSSbErNJi/bSUkIf/ 019lW837OIcXb8QMOStZQP3Xcd9hw4mHhZ5VFnoeZxLl4eBqk7/CHuJ60uhEmqgjATpI 8vvPNzSBGMk5QV6XPJI+SPI0R1563zEpm46UP6+2q3iyUD/ZvZGxRHgxqWkioIjAmT8J iaHw== X-Gm-Message-State: ACrzQf3ff/NfI/wojz4TflpJQa7ZLs/uepISN+7flZBWbuge1GnJK/de g9a5bP6Ey51LBgauELl7DWQ= X-Received: by 2002:a17:90a:df91:b0:213:8a69:c504 with SMTP id p17-20020a17090adf9100b002138a69c504mr69026009pjv.82.1668016010394; Wed, 09 Nov 2022 09:46:50 -0800 (PST) Received: from balhae.corp.google.com ([2620:15c:2c1:200:fa05:f3cd:da75:3103]) by smtp.gmail.com with ESMTPSA id a10-20020a63cd4a000000b0043941566481sm7877909pgj.39.2022.11.09.09.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:46:50 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Leo Yan , German Gomez , Zhengjun Xing , James Clark Subject: [PATCH 10/12] perf test: Replace brstack test workload Date: Wed, 9 Nov 2022 09:46:33 -0800 Message-Id: <20221109174635.859406-11-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109174635.859406-1-namhyung@kernel.org> References: <20221109174635.859406-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749041825952842442?= X-GMAIL-MSGID: =?utf-8?q?1749041825952842442?= So that it can get rid of requirement of a compiler. Also rename the symbols to match with the perf test workload. Cc: German Gomez Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/test_brstack.sh | 66 +++++--------------------- 1 file changed, 12 insertions(+), 54 deletions(-) diff --git a/tools/perf/tests/shell/test_brstack.sh b/tools/perf/tests/shell/test_brstack.sh index ec801cffae6b..a8a182dea25f 100755 --- a/tools/perf/tests/shell/test_brstack.sh +++ b/tools/perf/tests/shell/test_brstack.sh @@ -4,18 +4,12 @@ # SPDX-License-Identifier: GPL-2.0 # German Gomez , 2022 -# we need a C compiler to build the test programs -# so bail if none is found -if ! [ -x "$(command -v cc)" ]; then - echo "failed: no compiler, install gcc" - exit 2 -fi - # skip the test if the hardware doesn't support branch stack sampling # and if the architecture doesn't support filter types: any,save_type,u perf record -b -o- -B --branch-filter any,save_type,u true > /dev/null 2>&1 || exit 2 TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX) +TESTPROG="perf test -w brstack" cleanup() { rm -rf $TMPDIR @@ -23,57 +17,24 @@ cleanup() { trap cleanup exit term int -gen_test_program() { - # generate test program - cat << EOF > $1 -#define BENCH_RUNS 999999 -int cnt; -void bar(void) { -} /* return */ -void foo(void) { - bar(); /* call */ -} /* return */ -void bench(void) { - void (*foo_ind)(void) = foo; - if ((cnt++) % 3) /* branch (cond) */ - foo(); /* call */ - bar(); /* call */ - foo_ind(); /* call (ind) */ -} -int main(void) -{ - int cnt = 0; - while (1) { - if ((cnt++) > BENCH_RUNS) - break; - bench(); /* call */ - } /* branch (uncond) */ - return 0; -} -EOF -} - test_user_branches() { echo "Testing user branch stack sampling" - gen_test_program "$TEMPDIR/program.c" - cc -fno-inline -g "$TEMPDIR/program.c" -o $TMPDIR/a.out - - perf record -o $TMPDIR/perf.data --branch-filter any,save_type,u -- $TMPDIR/a.out > /dev/null 2>&1 + perf record -o $TMPDIR/perf.data --branch-filter any,save_type,u -- ${TESTPROG} > /dev/null 2>&1 perf script -i $TMPDIR/perf.data --fields brstacksym | xargs -n1 > $TMPDIR/perf.script # example of branch entries: - # foo+0x14/bar+0x40/P/-/-/0/CALL + # brstack_foo+0x14/brstack_bar+0x40/P/-/-/0/CALL set -x - egrep -m1 "^bench\+[^ ]*/foo\+[^ ]*/IND_CALL$" $TMPDIR/perf.script - egrep -m1 "^foo\+[^ ]*/bar\+[^ ]*/CALL$" $TMPDIR/perf.script - egrep -m1 "^bench\+[^ ]*/foo\+[^ ]*/CALL$" $TMPDIR/perf.script - egrep -m1 "^bench\+[^ ]*/bar\+[^ ]*/CALL$" $TMPDIR/perf.script - egrep -m1 "^bar\+[^ ]*/foo\+[^ ]*/RET$" $TMPDIR/perf.script - egrep -m1 "^foo\+[^ ]*/bench\+[^ ]*/RET$" $TMPDIR/perf.script - egrep -m1 "^bench\+[^ ]*/bench\+[^ ]*/COND$" $TMPDIR/perf.script - egrep -m1 "^main\+[^ ]*/main\+[^ ]*/UNCOND$" $TMPDIR/perf.script + egrep -m1 "^brstack_bench\+[^ ]*/brstack_foo\+[^ ]*/IND_CALL$" $TMPDIR/perf.script + egrep -m1 "^brstack_foo\+[^ ]*/brstack_bar\+[^ ]*/CALL$" $TMPDIR/perf.script + egrep -m1 "^brstack_bench\+[^ ]*/brstack_foo\+[^ ]*/CALL$" $TMPDIR/perf.script + egrep -m1 "^brstack_bench\+[^ ]*/brstack_bar\+[^ ]*/CALL$" $TMPDIR/perf.script + egrep -m1 "^brstack_bar\+[^ ]*/brstack_foo\+[^ ]*/RET$" $TMPDIR/perf.script + egrep -m1 "^brstack_foo\+[^ ]*/brstsack_bench\+[^ ]*/RET$" $TMPDIR/perf.script + egrep -m1 "^brstack_bench\+[^ ]*/brstack_bench\+[^ ]*/COND$" $TMPDIR/perf.script + egrep -m1 "^brstack\+[^ ]*/brstack\+[^ ]*/UNCOND$" $TMPDIR/perf.script set +x # some branch types are still not being tested: @@ -88,10 +49,7 @@ test_filter() { echo "Testing branch stack filtering permutation ($filter,$expect)" - gen_test_program "$TEMPDIR/program.c" - cc -fno-inline -g "$TEMPDIR/program.c" -o $TMPDIR/a.out - - perf record -o $TMPDIR/perf.data --branch-filter $filter,save_type,u -- $TMPDIR/a.out > /dev/null 2>&1 + perf record -o $TMPDIR/perf.data --branch-filter $filter,save_type,u -- ${TESTPROG} > /dev/null 2>&1 perf script -i $TMPDIR/perf.data --fields brstack | xargs -n1 > $TMPDIR/perf.script # fail if we find any branch type that doesn't match any of the expected ones