Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp603684lqd; Wed, 24 Apr 2024 11:10:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU1QW1vV77puOmaReuI9OKQRDWRuoze6BqAeLyQhpmIPYWtKGuFfmK2zyXI2Qc23MwDl366J8naD+OWj9UycUfrYLd99V7zWjCFYQBb/g== X-Google-Smtp-Source: AGHT+IFDLhzDCYI7i4Lt+lWjshLMxd1jQlUtbwAHBtJvbJik6hIfrkienZDFYEZm2F1sn8TKSUMx X-Received: by 2002:a05:6a20:7351:b0:1aa:48d1:2144 with SMTP id v17-20020a056a20735100b001aa48d12144mr3712923pzc.52.1713982229914; Wed, 24 Apr 2024 11:10:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713982229; cv=pass; d=google.com; s=arc-20160816; b=uzzRRei+jjhNMi6KA1JlqxgpVrWYKryA8r1Fje1XXX0ceJ0c3o3a/vbtMyq8BWt7/5 H7f4bWWDsAOrP9lNAYKG120Efl+C7+siiace6yMkSdZGmXDI51vefEYdnZcOhCbZZ6Sk Ki5EDEZej+z5sQHW7TNXqjLhFg1TmcanMBGwB0qudnnL0LN3DvIba/r8ZtniKpXnYebm 9DGuCdtUBbYFf3rQ16ljaXGa4P+RlYQx72RuYM5DlT9mKXUav7vSAyrMHorycS7K6kyD NEjI1fsZ1bLcXwI/qQQD+oD266ANoT4yX2EEjZLNYZbsdPOvPfInhmCthcZd+5sX6LgV ds+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=L0p7tew2agWpR4bqy2GNP4coWXMPXtcWBzHy2OtkeHU=; fh=KSfArD4/mnJNFe02suOgN8//PmWk5zUSLiUY+3s5poM=; b=YN7E5S++mMLGmufYxiBK5+iKsbfG+FIHvd1kbCYIR1ALs1SegDo1zhePH5wR6BmGxp vpvUPHTAig8xTd/Q9XrvDqmVm27tbVcp4zBFGwk3btZAD8QaODtTTgA5jH9kXl+iMFkg 6Vnvl/tL6A674YS0cjR3bQ9HhldhO0IIP4oFpkPL2CRiUAXydTzX1gcP5SJN64JHn4fD cnKdrnhxsPODi+6Vv+QBeHJSvPuEgD29iiuPm1JOUzhj1LoQmC3oCrdnFv3xdX7+Tcjt a+TvbojYjG4s7OAdAxx8JN0Smgar4AjeIkS6yZhR+acIyERzMzTvj2RrWCJybQlJiuIs iw+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QW+Bi4CO; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-157442-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157442-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j18-20020a62e912000000b006ed53b26535si11456250pfh.115.2024.04.24.11.10.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 11:10:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157442-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QW+Bi4CO; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-157442-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157442-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CA60B282B7B for ; Wed, 24 Apr 2024 18:10:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17D3A16D9BC; Wed, 24 Apr 2024 18:10:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QW+Bi4CO" Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F9F216D4E5 for ; Wed, 24 Apr 2024 18:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713982206; cv=none; b=n2yH6FMtsdP2wrVqsO54v6Zv7f0FS/ggTW71reJbzC3J9qIDGJLxJNq4606bVO/DaTuFiw1BJRzh0Cgw81tge23nAFhLaUAuDpNkoOAeF6O1bG2MQWnc0d3cYMCTnA1MBNnJdjyBFvfgZZoxVLqRKj0C5BQQ9rNTEdLJtKWyYWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713982206; c=relaxed/simple; bh=jW/Q55tFYbDjApVjeRiSYiCAMWJJXza1aMX93bHT510=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=mlAg2Clw+dnrpNxjIWCQZSy3cbCf+A7aCYFY0vhDtAM/Nae3mugdDvHDwQVsASzJeF0rXUkGah07e1K5TrOH6/AzK6W2Uht4fYQYVqg8Z2X23wTEH/GkclSCJChJxVBUOj6ZAEocQYw60oiq7Ubvo3AIy7Fv+7tOFe0cbLXQ5XI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QW+Bi4CO; arc=none smtp.client-ip=209.85.160.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-439b1c72676so51061cf.1 for ; Wed, 24 Apr 2024 11:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713982203; x=1714587003; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=L0p7tew2agWpR4bqy2GNP4coWXMPXtcWBzHy2OtkeHU=; b=QW+Bi4COtIuCXgUr7kZfIbEl0vXLBMhdIEEAmPplYqi0qOwCPfGKmDbOaag2M0YYEH 9TF/RpYP4mdani2KGWMD0LUuHwTEfoxQRSneoXgIwnE9e7LfTvxeSMutEEAzdw2g5nGC Xv26mMqd5TtkyRGnJ/Q3cr0vuEQ/zVJEeV/TasgrOV193xIJ66aiGehjf4uOUy/uMuL/ uLKCKUqkdR0CibqQKXJ1LvWzz7sF3yLRf+e6JRlKHsCDp8cteW+0Hs6+8vXDvT5AwkDV rrk77kL9LNj4Uf76SbGKUmRDHN9yL+0mvlsKWuf6PsDxA0Ysb29MOaDDYPqBfyPFYDQT gK2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713982203; x=1714587003; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L0p7tew2agWpR4bqy2GNP4coWXMPXtcWBzHy2OtkeHU=; b=JVX2jzx5ErccQg7hMz8V6TAJkRswsC8vt6POeHkjkXoVbbjFGNWLdmGir8Pm13InSL QGYQsfiY8QRg+LkJwPPjd83oPrsSmYjg06d5n42xgh6ES6gRP2iI+t/tD5E/Mr/g2VbI OZm3B333roHFlYBNPrTRH2ybi0VxwCd6B5rzo9JzPhPfABJL/5PZ0LUa6N+ten8oqJPA aWAO7aeuGG60x6C5aOVoz1cTk7DJF2YwR8gz+FkHJa/pj33INjLE3TXhET7A53amiimW TfJjjSSlKkKCxFHCD+SEYCxp1TfIm2y31G9GOdp+F+y6Heh3DV2WuyQUedVJXaaAc308 dgJQ== X-Forwarded-Encrypted: i=1; AJvYcCUZbLMoMVrYDhUXzyX2JMWgYqq5aOph4IZgrC0vRp4vzU0N7nBRtNSoshEUeET6aNnRc6cL6Me86wXGpxgWcL+K/jmw7GVPLa4Ho3BX X-Gm-Message-State: AOJu0YyKbE1s+zenj6HWcPcf8dcyYOhOKvtcHoUOlRzmHGZa2fHCUysJ OFCdTnyw6UYjs5w73/uk4SeBJv9JFMLck8RadfjVNyk6KtgHvEme+AMVXSkKEHaXWGntsYg9456 TpzD95AR6AGJ9+IIsd9QdadS5oqZfLq0eJbfW X-Received: by 2002:ac8:134a:0:b0:437:8ba1:ee1 with SMTP id f10-20020ac8134a000000b004378ba10ee1mr9969qtj.5.1713982203329; Wed, 24 Apr 2024 11:10:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240424001231.849972-1-namhyung@kernel.org> In-Reply-To: <20240424001231.849972-1-namhyung@kernel.org> From: Ian Rogers Date: Wed, 24 Apr 2024 11:09:48 -0700 Message-ID: Subject: Re: [PATCH] perf test: Add a new test for perf annotate To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Kan Liang , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 23, 2024 at 5:12=E2=80=AFPM Namhyung Kim = wrote: > > Add a basic perf annotate test > > $ ./perf test annotate -vv > 76: perf annotate basic tests: > --- start --- > test child forked, pid 846989 > fbcd0-fbd55 l noploop > perf does have symbol 'noploop' > Basic perf annotate test > : 0 0xfbcd0 : > 0.00 : fbcd0: pushq %rbp > 0.00 : fbcd1: movq %rsp, %rbp > 0.00 : fbcd4: pushq %r12 > 0.00 : fbcd6: pushq %rbx > 0.00 : fbcd7: movl $1, %ebx > 0.00 : fbcdc: subq $0x10, %rsp > 0.00 : fbce0: movq %fs:0x28, %rax > 0.00 : fbce9: movq %rax, -0x18(%rbp) > 0.00 : fbced: xorl %eax, %eax > 0.00 : fbcef: testl %edi, %edi > 0.00 : fbcf1: jle 0xfbd04 > 0.00 : fbcf3: movq (%rsi), %rdi > 0.00 : fbcf6: movl $0xa, %edx > 0.00 : fbcfb: xorl %esi, %esi > 0.00 : fbcfd: callq 0x41920 > 0.00 : fbd02: movl %eax, %ebx > 0.00 : fbd04: leaq -0x7b(%rip), %r12 # fbc90 > 0.00 : fbd0b: movl $2, %edi > 0.00 : fbd10: movq %r12, %rsi > 0.00 : fbd13: callq 0x40a00 > 0.00 : fbd18: movl $0xe, %edi > 0.00 : fbd1d: movq %r12, %rsi > 0.00 : fbd20: callq 0x40a00 > 0.00 : fbd25: movl %ebx, %edi > 0.00 : fbd27: callq 0x407c0 > 0.10 : fbd2c: movl 0x89785e(%rip), %eax # 993590 = > 0.00 : fbd32: testl %eax, %eax > 99.90 : fbd34: je 0xfbd2c > 0.00 : fbd36: movq -0x18(%rbp), %rax > 0.00 : fbd3a: subq %fs:0x28, %rax > 0.00 : fbd43: jne 0xfbd50 > 0.00 : fbd45: addq $0x10, %rsp > 0.00 : fbd49: xorl %eax, %eax > 0.00 : fbd4b: popq %rbx > 0.00 : fbd4c: popq %r12 > 0.00 : fbd4e: popq %rbp > 0.00 : fbd4f: retq > 0.00 : fbd50: callq 0x407e0 > 0.00 : fbcd0: pushq %rbp > 0.00 : fbcd1: movq %rsp, %rbp > 0.00 : fbcd4: pushq %r12 > 0.00 : fbcd0: push %rbp > 0.00 : fbcd1: mov %rsp,%rbp > 0.00 : fbcd4: push %r12 > Basic annotate test [Success] > ---- end(0) ---- > 76: perf annotate basic tests : = Ok > > Signed-off-by: Namhyung Kim Looks good, thanks for this! Reviewed-by: Ian Rogers Thanks, Ian > --- > tools/perf/tests/shell/annotate.sh | 83 ++++++++++++++++++++++++++++++ > 1 file changed, 83 insertions(+) > create mode 100755 tools/perf/tests/shell/annotate.sh > > diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/= annotate.sh > new file mode 100755 > index 000000000000..7820d13eebae > --- /dev/null > +++ b/tools/perf/tests/shell/annotate.sh > @@ -0,0 +1,83 @@ > +#!/bin/sh > +# perf annotate basic tests > +# SPDX-License-Identifier: GPL-2.0 > + > +set -e > + > +shelldir=3D$(dirname "$0") > + > +# shellcheck source=3Dlib/perf_has_symbol.sh > +. "${shelldir}"/lib/perf_has_symbol.sh > + > +testsym=3D"noploop" > + > +skip_test_missing_symbol ${testsym} > + > +err=3D0 > +perfdata=3D$(mktemp /tmp/__perf_test.perf.data.XXXXX) > +testprog=3D"perf test -w noploop" > +# disassembly format: "percent : offset: instruction (operands ...)" > +disasm_regex=3D"[0-9]*\.[0-9]* *: *\w*: *\w*" > + > +cleanup() { > + rm -rf "${perfdata}" > + rm -rf "${perfdata}".old > + > + trap - EXIT TERM INT > +} > + > +trap_cleanup() { > + cleanup > + exit 1 > +} > +trap trap_cleanup EXIT TERM INT > + > +test_basic() { > + echo "Basic perf annotate test" > + if ! perf record -o "${perfdata}" ${testprog} 2> /dev/null > + then > + echo "Basic annotate [Failed record]" > + err=3D1 > + return > + fi > + > + # check if it has the target symbol > + if ! perf annotate -i "${perfdata}" 2> /dev/null | grep "${testsym}" > + then > + echo "Basic annotate [Failed missing symbol]" > + err=3D1 > + return > + fi > + > + # check if it has the disassembly lines > + if ! perf annotate -i "${perfdata}" 2> /dev/null | grep "${disasm_rege= x}" > + then > + echo "Basic annotate [Failed missing disasm output]" > + err=3D1 > + return > + fi > + > + # check again with a target symbol name > + if ! perf annotate -i "${perfdata}" "${testsym}" 2> /dev/null | \ > + grep -m 3 "${disasm_regex}" > + then > + echo "Basic annotate [Failed missing disasm output]" > + err=3D1 > + return > + fi > + > + # check one more with external objdump tool (forced by --objdump optio= n) > + if ! perf annotate -i "${perfdata}" --objdump=3Dobjdump 2> /dev/null |= \ > + grep -m 3 "${disasm_regex}" > + then > + echo "Basic annotate [Failed missing disasm output from objdump]" > + err=3D1 > + return > + fi > + echo "Basic annotate test [Success]" > +} > + > +test_basic > + > +cleanup > +exit $err > -- > 2.44.0.769.g3c40516874-goog >