linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Thomas Richter <tmricht@linux.ibm.com>,
	James Clark <james.clark@linaro.org>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] perf check: Add sanitizer feature and use to avoid test failure
Date: Mon, 21 Oct 2024 22:41:18 -0700	[thread overview]
Message-ID: <Zxc6_jZdDcWgtEom@google.com> (raw)
In-Reply-To: <20241018055627.1005723-1-irogers@google.com>

On Thu, Oct 17, 2024 at 10:56:27PM -0700, Ian Rogers wrote:
> Sanitizer builds can break expectations for test disassembly,
> particularly in the annotate test. Add features for the different
> sanitizer options seen in the source tree. Use the added sanitizer
> feature to skip the annotate test when sanitizers are in use.

Can you please split the perf check changes from the test change?
It's good to add an example output (of perf version --build-options)
with new sanitizer features.

Also it might be helpful if you share how the test fails.  I don't
think the disasm format is changed.  Then it probably missed to find
the target symbol in the first 250 lines for some reason.

Thanks,
Namhyung

> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> v2 build fix.
> ---
>  tools/perf/builtin-check.c         | 49 ++++++++++++++++++++++++++++++
>  tools/perf/tests/shell/annotate.sh |  6 ++++
>  2 files changed, 55 insertions(+)
> 
> diff --git a/tools/perf/builtin-check.c b/tools/perf/builtin-check.c
> index 0b76b6e42b78..c44444008d64 100644
> --- a/tools/perf/builtin-check.c
> +++ b/tools/perf/builtin-check.c
> @@ -9,6 +9,49 @@
>  #include <string.h>
>  #include <subcmd/parse-options.h>
>  
> +#if defined(__has_feature)
> +#define HAS_COMPILER_FEATURE(feature) __has_feature(feature)
> +#else
> +#define HAS_COMPILER_FEATURE(feature) 0
> +#endif
> +
> +#if defined(__SANITIZE_ADDRESS__) || defined(ADDRESS_SANITIZER) || \
> +	HAS_COMPILER_FEATURE(address_sanitizer)
> +#define HAVE_SANITIZER_ADDRESS 1
> +#define HAVE_SANITIZER_LEAK 1
> +#elif defined(LEAK_SANITIZER) || HAS_COMPILER_FEATURE(leak_sanitizer)
> +#define HAVE_SANITIZER_ADDRESS 0
> +#define HAVE_SANITIZER_LEAK 1
> +#else
> +#define HAVE_SANITIZER_ADDRESS 0
> +#define HAVE_SANITIZER_LEAK 0
> +#endif
> +
> +#if defined(MEMORY_SANITIZER) || HAS_COMPILER_FEATURE(memory_sanitizer)
> +#define HAVE_SANITIZER_MEMORY 1
> +#else
> +#define HAVE_SANITIZER_MEMORY 0
> +#endif
> +
> +#if defined(THREAD_SANITIZER) || HAS_COMPILER_FEATURE(thread_sanitizer)
> +#define HAVE_SANITIZER_THREAD 1
> +#else
> +#define HAVE_SANITIZER_THREAD 0
> +#endif
> +
> +#if defined(UNDEFINED_SANITIZER) || HAS_COMPILER_FEATURE(undefined_sanitizer)
> +#define HAVE_SANITIZER_UNDEFINED 1
> +#else
> +#define HAVE_SANITIZER_UNDEFINED 0
> +#endif
> +
> +#if HAVE_SANITIZER_ADDRESS || HAVE_SANITIZER_LEAK || HAVE_SANITIZER_MEMORY || \
> +	HAVE_SANITIZER_THREAD || HAVE_SANITIZER_UNDEFINED
> +#define HAVE_SANITIZER 1
> +#else
> +#define HAVE_SANITIZER 0
> +#endif
> +
>  static const char * const check_subcommands[] = { "feature", NULL };
>  static struct option check_options[] = {
>  	OPT_BOOLEAN('q', "quiet", &quiet, "do not show any warnings or messages"),
> @@ -47,6 +90,12 @@ struct feature_status supported_features[] = {
>  	FEATURE_STATUS("libunwind", HAVE_LIBUNWIND_SUPPORT),
>  	FEATURE_STATUS("lzma", HAVE_LZMA_SUPPORT),
>  	FEATURE_STATUS("numa_num_possible_cpus", HAVE_LIBNUMA_SUPPORT),
> +	FEATURE_STATUS("sanitizer", HAVE_SANITIZER),
> +	FEATURE_STATUS("sanitizer_address", HAVE_SANITIZER_ADDRESS),
> +	FEATURE_STATUS("sanitizer_leak", HAVE_SANITIZER_LEAK),
> +	FEATURE_STATUS("sanitizer_memory", HAVE_SANITIZER_MEMORY),
> +	FEATURE_STATUS("sanitizer_thread", HAVE_SANITIZER_THREAD),
> +	FEATURE_STATUS("sanitizer_undefined", HAVE_SANITIZER_UNDEFINED),
>  	FEATURE_STATUS("syscall_table", HAVE_SYSCALL_TABLE_SUPPORT),
>  	FEATURE_STATUS("zlib", HAVE_ZLIB_SUPPORT),
>  	FEATURE_STATUS("zstd", HAVE_ZSTD_SUPPORT),
> diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/annotate.sh
> index 1590a37363de..199f547e656d 100755
> --- a/tools/perf/tests/shell/annotate.sh
> +++ b/tools/perf/tests/shell/annotate.sh
> @@ -4,6 +4,12 @@
>  
>  set -e
>  
> +if perf check feature -q sanitizer
> +then
> +  echo "Skip test with sanitizers due to differing assembly code"
> +  exit 2
> +fi
> +
>  shelldir=$(dirname "$0")
>  
>  # shellcheck source=lib/perf_has_symbol.sh
> -- 
> 2.47.0.105.g07ac214952-goog
> 

  reply	other threads:[~2024-10-22  5:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18  5:56 [PATCH v2] perf check: Add sanitizer feature and use to avoid test failure Ian Rogers
2024-10-22  5:41 ` Namhyung Kim [this message]
2024-10-22 17:39   ` Ian Rogers
2024-10-23  6:18     ` Namhyung Kim
2024-10-23 22:19       ` Namhyung Kim
2024-10-23 23:24         ` Namhyung Kim
2024-10-24  2:42           ` Ian Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zxc6_jZdDcWgtEom@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).