Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp465244lqp; Wed, 12 Jun 2024 07:04:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXISHWjSjNlvDKPU/eNCfImUKABYZGUU1odhwCe+sylK9rmoj/ByQBmWVSw3ogvPkcVnp19OujFaxJP+e77SP/s+bUIZ57SnFvgMR+gYw== X-Google-Smtp-Source: AGHT+IGrKHylmm/TSc+PaiVYq/v17OwtS+UqE1MiAE/k6nD2fn/DLET2A0/SfXCyZpjt9qUbV4qh X-Received: by 2002:a17:906:dfe6:b0:a6e:f91f:672c with SMTP id a640c23a62f3a-a6f47f8c006mr111650466b.25.1718201050077; Wed, 12 Jun 2024 07:04:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718201050; cv=pass; d=google.com; s=arc-20160816; b=1F4pjzPXCDzD8Xv/SSYeqndpcQeYxcNexd86a8ZLssvByxxnfXlDcayvaVZGjpCwBW IYkhccTLrdt7bLyq8si2Ne+6YO3EFzmbatYIiKtyhUZF9rzcqH6oObwSYF8f2rtzkKmc SsqBJhjxnNCJ8CkF3rAQRDAKdHx8IVeGskJCgC22o8A/Sel5mFA4M8bNGPCkpJUwXwKn YJfomwVnZSjWvGeeugMkdNomXSJhz67s2QW3hXKomNA80TvuRFMyo6kiiz9kNvYd7rR3 BmbRpKcCk7/dihVzSOV6vG+HVcW1Gn1P+GN+DO20YVGq3bmjCP1nSwBucyCEW3ukyDnn RdMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=LMr0SsTXqpJIpFx1vfIOk9kSx/sdyQ/jk2/pF0m17ho=; fh=8ePA+GJZYty/u3W7nlI8QtxXvH5BvW9WlwjxVZcJWGg=; b=N4UH2idgnrqX4gY9bKQOP6WOfcPR3otkAOmk1aglqLx0C3Qj/VJZD+gtOk9zxDXzJ/ P3sMAUfEjAWl16hjgzWMyPOpCztEG8XwMGOta7OeKdTk2RlS592HM2WrShsRkfyP75Ij f7KGGTmSrmQZIMXi/Gi+xjnArHeLNvaf/AYP/5JZfTTA7nymCIeIw8MAgqmAXClFosN1 y4rsOz58jM43fZBPFs6FvKf+ZluPoCc2Dst82/G33mH9fUbbYRQuN3ONggohHUWTidp7 HX39keOOhwRap92vvP8nc1GF2azeJQR25PA2JpPorS7rPt0CvDmZoHVK5IzTXshnEBMB QyxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-211635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c9c558736si1640063a12.542.2024.06.12.07.04.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 07:04:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-211635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A58A51F225B1 for ; Wed, 12 Jun 2024 14:03:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2452D17DE30; Wed, 12 Jun 2024 14:03:36 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D981417D8A3; Wed, 12 Jun 2024 14:03:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718201015; cv=none; b=J6XK26aPExL0dI5icWlFyUiNXuhBdrugMdvi9kgH0bQmlirbrYpEWYjin6LREQ1+RzIafoQPAIC5N2Beu4RUNy5vBinFF4iN3BqDs6H7MGPa9ZyORIjX8eb+vEMKnDhV3+rj7MMr4DOcWpO7yzZB5/O91OMHWQa+3mbG+GERSlc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718201015; c=relaxed/simple; bh=Z8v6VN3VTXwQnLuxWiCD7XiHXxTlypzscfkEhk+/2RU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=GIYHCyDXOEh1PfzzWMPk608LCvyB6Xu7EhD5v4jiCH1KTsO5b8SR7JsXfHlltyGDJG9/qt4Ta2Ap7fvuA+6lxIu9R6iusgz4zAdsVrnxaxqxzezusPrqm5j1UOhRjvsRjeilBAWEuJ1zsL/1AkLlFWGa3fPtDCypcaad4j3GkmA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B448D367; Wed, 12 Jun 2024 07:03:57 -0700 (PDT) Received: from e127643.broadband (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E43413F64C; Wed, 12 Jun 2024 07:03:30 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Kajol Jain , Spoorthy S , German Gomez , linux-kernel@vger.kernel.org Subject: [PATCH] perf test: Make test_arm_callgraph_fp.sh more robust Date: Wed, 12 Jun 2024 15:03:14 +0100 Message-Id: <20240612140316.3006660-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The 2 second sleep can cause the test to fail on very slow network file systems because Perf ends up being killed before it finishes starting up. Fix it by making the leafloop workload end after a fixed time like the other workloads so there is no need to kill it after 2 seconds. Also remove the 1 second start sampling delay because it is similarly fragile. Instead, search through all samples for a matching one, rather than just checking the first sample and hoping it's in the right place. Fixes: cd6382d82752 ("perf test arm64: Test unwinding using fame-pointer (fp) mode") Signed-off-by: James Clark --- .../perf/tests/shell/test_arm_callgraph_fp.sh | 27 +++++++------------ tools/perf/tests/workloads/leafloop.c | 20 +++++++++++--- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/tools/perf/tests/shell/test_arm_callgraph_fp.sh b/tools/perf/tests/shell/test_arm_callgraph_fp.sh index 61898e256616..9caa36130175 100755 --- a/tools/perf/tests/shell/test_arm_callgraph_fp.sh +++ b/tools/perf/tests/shell/test_arm_callgraph_fp.sh @@ -28,28 +28,21 @@ cleanup_files() trap cleanup_files EXIT TERM INT -# Add a 1 second delay to skip samples that are not in the leaf() function # shellcheck disable=SC2086 -perf record -o "$PERF_DATA" --call-graph fp -e cycles//u -D 1000 --user-callchains -- $TEST_PROGRAM 2> /dev/null & -PID=$! +perf record -o "$PERF_DATA" --call-graph fp -e cycles//u --user-callchains -- $TEST_PROGRAM -echo " + Recording (PID=$PID)..." -sleep 2 -echo " + Stopping perf-record..." - -kill $PID -wait $PID +# Try opening the file so any immediate errors are visible in the log +perf script -i "$PERF_DATA" -F comm,ip,sym | head -n4 -# expected perf-script output: +# expected perf-script output if 'leaf' has been inserted correctly: # -# program +# perf # 728 leaf # 753 parent # 76c leafloop -# ... +# ... remaining stack to main() ... -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] != "leafloop") exit 1 }' +# Each frame is separated by a tab, some spaces and an address +SEP="[[:space:]]+ [[:xdigit:]]+" +perf script -i "$PERF_DATA" -F comm,ip,sym | tr '\n' ' ' | \ + grep -E -q "perf $SEP leaf $SEP parent $SEP leafloop" diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c index 1bf5cc97649b..f7561767e32c 100644 --- a/tools/perf/tests/workloads/leafloop.c +++ b/tools/perf/tests/workloads/leafloop.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#include #include #include +#include #include "../tests.h" /* We want to check these symbols in perf script */ @@ -8,10 +10,16 @@ noinline void leaf(volatile int b); noinline void parent(volatile int b); static volatile int a; +static volatile sig_atomic_t done; + +static void sighandler(int sig __maybe_unused) +{ + done = 1; +} noinline void leaf(volatile int b) { - for (;;) + while (!done) a += b; } @@ -22,12 +30,16 @@ noinline void parent(volatile int b) static int leafloop(int argc, const char **argv) { - int c = 1; + int sec = 1; if (argc > 0) - c = atoi(argv[0]); + sec = atoi(argv[0]); + + signal(SIGINT, sighandler); + signal(SIGALRM, sighandler); + alarm(sec); - parent(c); + parent(sec); return 0; } -- 2.34.1