Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp1443922rdb; Sat, 26 Aug 2023 02:50:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfu133xDxusxeTpr7YvV0wzHTvzUSJSPDMtPOmsrwSugOgvA/hqjqgop48LTPoVraqpoB2 X-Received: by 2002:aa7:d3d2:0:b0:522:3849:48db with SMTP id o18-20020aa7d3d2000000b00522384948dbmr15974314edr.3.1693043419014; Sat, 26 Aug 2023 02:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693043418; cv=none; d=google.com; s=arc-20160816; b=sEH/I06y+ied32I6ZeDQ7hDrZagEg/lf7lT0ZX58EiRJbYnn/7c4HgUMzqx9ce9lLR +oHY9xb17eEOghjcNGWfChxj2eayZ9INDv8S0cY0k6/B7LZRdHgSXUFwxRPqmrZve4+T DIXCfTFGjsHwhIwO689p64ZrKcR9bnZbEWkBs+WZ6pcVLJx32GXlZ0cOmm7vYGeJfGJ1 FFRF1lKEJA5GLn4e7SrIbQSxx4OqHy8I/sBWLg/SSw4+IMI2mkGyhT1RpMF+AVZKT+JL fYIyHZ8zcaoVy8CIyucx+O8hZmY6ygT1sGRxg9ndhcQkq2bBOW9NlhGm7YobmUNdOG9A ZYew== 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=PE8aFNxe6GGcFupcPtnr5v1uBa6UWOeWT0Vs7xd6hC9VyGCaJ+Dj9PgMg1sqff1yXc EOIDhrXCNCtnvqFexPPPFrNYSxc7qWV9RPro2WbvoPrUZHgIO0RJlPmWUjzE1ynHXXfh y+Wz4NTu3dHiadlcxrDcqYGYCgM46omZ88JaE24jxYdGJka2DgvkWVBq/hMZnbTV6waZ AuadsKY5X+zSYQEDRxC10HqOOUf6j4DLpC0jNsh4AF9SrXb21llt/+O7039IAXee6rbk sp3Q9TaQ2m3XSXSeRIYGcYGdBI5Zs55TeH1UBwWjLoreBAZT8fXSXIUmMxj02ZGs7ryl LL9g== 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 d10-20020a056402516a00b0052a3cc19f64si2206386ede.390.2023.08.26.02.49.36; Sat, 26 Aug 2023 02:50:18 -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 S231724AbjHZD3q (ORCPT + 99 others); Fri, 25 Aug 2023 23:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231574AbjHZD3N (ORCPT ); Fri, 25 Aug 2023 23:29:13 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0440D213C; Fri, 25 Aug 2023 20:29:11 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RXhzK2QsVzNmtS; Sat, 26 Aug 2023 11:25:33 +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; Sat, 26 Aug 2023 11:29:08 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v7 5/6] perf test: Add test case for record sideband events Date: Sat, 26 Aug 2023 03:26:07 +0000 Message-ID: <20230826032608.107261-6-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230826032608.107261-1-yangjihong1@huawei.com> References: <20230826032608.107261-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: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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