Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1302129rdb; Mon, 4 Sep 2023 09:06:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9/WhIcTwRiJUKKpOUCh1XY3geBi1z58geL4zIm+hqSN41Uqt7+1n/DyfmXvsy4SJzk/bR X-Received: by 2002:a17:90a:66c7:b0:26d:4ab3:fe11 with SMTP id z7-20020a17090a66c700b0026d4ab3fe11mr7291028pjl.24.1693843597392; Mon, 04 Sep 2023 09:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693843597; cv=none; d=google.com; s=arc-20160816; b=uy/kenIfdJ5aOJCGJOJrbTlIV+JLV3ybNJKTj106jt2K9zCzIieK/siSB9NcNA4uo8 Nw9JEbX9FDOk1HjGzrUfLDUSvn5jhYyAMXDcfXPF/CazM+3JKE1gkczeez9c5Q2XhCOg 5LFjJWWX6DZeiT2Y4Pab9D3QYY265950gI12kSXcsqdwXIPvlhUpolo5VJYxTm0Fpq3z kcTDuBxvjROHQFxTXhvSYXqxfJeL5Q/u5uOX9iXlGW84u/QmnzxVZY9gWl3V4DJS5HHG qG0N33eYU+sH9TCKVcgs1DS8/UHFKhcExQkfdH7rg3knHShq+Qgf76jlscXQfN0nCanu 1oCg== 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; bh=pjmtHcb46OU5cqfXCszKLO3VuEiEWJcYUfTqZaEXVKU=; fh=+V2NJRwYYldEteK9NYuSkp4iZMVHSlTgEsLCPEY32o0=; b=RIIOQvZVbZwSbKwOoIGThXqopKcKsZylmnx4lrrSPfWCWPKrKIBexPCJdIaTay2cOf c3Lu7LhgC8MP+zYgyiQcGArQrdEOhh4SJ1PEkRRI5nlmnZp6iyYFUpZwtxZy+3eg/yop FVBlPi+Fqghipxv02+Oxqh8DZmYrJE27oi7KybpH3ryg+8g3GciQYD0ppJx8Y/fZKNj9 5mm1kwlss3ZAAUpPsj/wRtLa85sLNybrmOnnVb1SVq4xxJQjJAeeimzOB4Zz2uQAbJRx RB7kw7lV+JRzK58/3iWjR1roi+IALpOEKfFgPVIl0Mk/ilqapa5Fy/wcXdK3FPb2uXCM FvUA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a17090a9d8500b00263deaac48esi7938594pjp.8.2023.09.04.09.06.14; Mon, 04 Sep 2023 09:06:37 -0700 (PDT) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351018AbjIDCg7 (ORCPT + 99 others); Sun, 3 Sep 2023 22:36:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241802AbjIDCg4 (ORCPT ); Sun, 3 Sep 2023 22:36:56 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B05F3FC; Sun, 3 Sep 2023 19:36:52 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RfCQx4STWzrRvr; Mon, 4 Sep 2023 10:35:05 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 4 Sep 2023 10:36:50 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v8 5/6] perf test: Add test case for record sideband events Date: Mon, 4 Sep 2023 02:33:39 +0000 Message-ID: <20230904023340.12707-6-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230904023340.12707-1-yangjihong1@huawei.com> References: <20230904023340.12707-1-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Add a new test case to record sideband events for all CPUs when tracing selected CPUs Test result: # ./perf test list 2>&1 | grep 'perf record sideband tests' 95: perf record sideband tests # ./perf test 95 95: perf record sideband tests : Ok Signed-off-by: Yang Jihong --- tools/perf/tests/shell/record_sideband.sh | 58 +++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 tools/perf/tests/shell/record_sideband.sh diff --git a/tools/perf/tests/shell/record_sideband.sh b/tools/perf/tests/shell/record_sideband.sh new file mode 100755 index 000000000000..5024a7ce0c51 --- /dev/null +++ b/tools/perf/tests/shell/record_sideband.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# perf record sideband tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +err=0 +perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) + +cleanup() +{ + rm -rf ${perfdata} + trap - EXIT TERM INT +} + +trap_cleanup() +{ + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +can_cpu_wide() +{ + if ! perf record -o ${perfdata} -BN --no-bpf-event -C $1 true 2>&1 >/dev/null + then + echo "record sideband test [Skipped cannot record cpu$1]" + err=2 + fi + + rm -f ${perfdata} + return $err +} + +test_system_wide_tracking() +{ + # Need CPU 0 and CPU 1 + can_cpu_wide 0 || return 0 + can_cpu_wide 1 || return 0 + + # Record on CPU 0 a task running on CPU 1 + perf record -BN --no-bpf-event -o ${perfdata} -C 0 -- taskset --cpu-list 1 true + + # Should get MMAP events from CPU 1 + mmap_cnt=`perf script -i ${perfdata} --show-mmap-events -C 1 2>/dev/null | grep MMAP | wc -l` + + if [ ${mmap_cnt} -gt 0 ] ; then + return 0 + fi + + echo "Failed to record MMAP events on CPU 1 when tracing CPU 0" + return 1 +} + +test_system_wide_tracking + +cleanup +exit $err -- 2.30.GIT