linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jiri Olsa <jolsa@redhat.com>, Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf tools: Add file-handle feature test
Date: Thu, 2 Apr 2020 12:37:48 -0300	[thread overview]
Message-ID: <20200402153748.GC8736@kernel.org> (raw)
In-Reply-To: <20200402015249.3800462-1-namhyung@kernel.org>

Em Thu, Apr 02, 2020 at 10:52:49AM +0900, Namhyung Kim escreveu:
> The file handle (FHANDLE) support is configurable so some systems might
> not have it.  So add a config feature item to check it on build time
> and reject cgroup tracking based on that.

Ok, I'll break this patch in two, add the feature test first, then fold
the usage of HAVE_FILE_HANDLE with the patch that uses it, so that we
keep the codebase bisectable,

Thanks!

- Arnaldo
 
> Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/build/Makefile.feature           |  3 ++-
>  tools/build/feature/Makefile           |  6 +++++-
>  tools/build/feature/test-file-handle.c | 14 ++++++++++++++
>  tools/perf/Makefile.config             |  4 ++++
>  tools/perf/builtin-record.c            |  8 +++++++-
>  tools/perf/builtin-top.c               |  8 +++++++-
>  tools/perf/util/synthetic-events.c     |  9 +++++++++
>  7 files changed, 48 insertions(+), 4 deletions(-)
>  create mode 100644 tools/build/feature/test-file-handle.c
> 
> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index 574c2e0b9d20..3e0c019ef297 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -72,7 +72,8 @@ FEATURE_TESTS_BASIC :=                  \
>          setns				\
>          libaio				\
>          libzstd				\
> -        disassembler-four-args
> +        disassembler-four-args		\
> +        file-handle
>  
>  # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
>  # of all feature tests
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index 7ac0d8088565..621f528f7822 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -67,7 +67,8 @@ FILES=                                          \
>           test-llvm.bin				\
>           test-llvm-version.bin			\
>           test-libaio.bin			\
> -         test-libzstd.bin
> +         test-libzstd.bin			\
> +         test-file-handle.bin
>  
>  FILES := $(addprefix $(OUTPUT),$(FILES))
>  
> @@ -321,6 +322,9 @@ FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
>  $(OUTPUT)test-libzstd.bin:
>  	$(BUILD) -lzstd
>  
> +$(OUTPUT)test-file-handle.bin:
> +	$(BUILD)
> +
>  ###############################
>  
>  clean:
> diff --git a/tools/build/feature/test-file-handle.c b/tools/build/feature/test-file-handle.c
> new file mode 100644
> index 000000000000..5f8c16f8784f
> --- /dev/null
> +++ b/tools/build/feature/test-file-handle.c
> @@ -0,0 +1,14 @@
> +#define _GNU_SOURCE
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +
> +int main(void)
> +{
> +	struct file_handle fh;
> +	int mount_id;
> +
> +	name_to_handle_at(AT_FDCWD, "/", &fh, &mount_id, 0);
> +	return 0;
> +}
> +
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 80e55e796be9..eb95c0c0a169 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -348,6 +348,10 @@ ifeq ($(feature-gettid), 1)
>    CFLAGS += -DHAVE_GETTID
>  endif
>  
> +ifeq ($(feature-file-handle), 1)
> +  CFLAGS += -DHAVE_FILE_HANDLE
> +endif
> +
>  ifdef NO_LIBELF
>    NO_DWARF := 1
>    NO_DEMANGLE := 1
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 7d7912e121d6..1ab349abe904 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1433,8 +1433,14 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
>  	if (rec->opts.record_namespaces)
>  		tool->namespace_events = true;
>  
> -	if (rec->opts.record_cgroup)
> +	if (rec->opts.record_cgroup) {
> +#ifdef HAVE_FILE_HANDLE
>  		tool->cgroup_events = true;
> +#else
> +		pr_err("cgroup tracking is not supported\n");
> +		return -1;
> +#endif
> +	}
>  
>  	if (rec->opts.auxtrace_snapshot_mode || rec->switch_output.enabled) {
>  		signal(SIGUSR2, snapshot_sig_handler);
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 56b2dd0db88e..02ea2cf2a3d9 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -1246,8 +1246,14 @@ static int __cmd_top(struct perf_top *top)
>  
>  	if (opts->record_namespaces)
>  		top->tool.namespace_events = true;
> -	if (opts->record_cgroup)
> +	if (opts->record_cgroup) {
> +#ifdef HAVE_FILE_HANDLE
>  		top->tool.cgroup_events = true;
> +#else
> +		pr_err("cgroup tracking is not supported.\n");
> +		return -1;
> +#endif
> +	}
>  
>  	ret = perf_event__synthesize_bpf_events(top->session, perf_event__process,
>  						&top->session->machines.host,
> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> index 24975470ed5c..f96e84956d84 100644
> --- a/tools/perf/util/synthetic-events.c
> +++ b/tools/perf/util/synthetic-events.c
> @@ -415,6 +415,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
>  	return rc;
>  }
>  
> +#ifdef HAVE_FILE_HANDLE
>  static int perf_event__synthesize_cgroup(struct perf_tool *tool,
>  					 union perf_event *event,
>  					 char *path, size_t mount_len,
> @@ -526,6 +527,14 @@ int perf_event__synthesize_cgroups(struct perf_tool *tool,
>  
>  	return 0;
>  }
> +#else
> +int perf_event__synthesize_cgroups(struct perf_tool *tool,
> +				   perf_event__handler_t process,
> +				   struct machine *machine)
> +{
> +	return -1;
> +}
> +#endif
>  
>  int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t process,
>  				   struct machine *machine)
> -- 
> 2.26.0.rc2.310.g2932bb562d-goog
> 

-- 

- Arnaldo

  reply	other threads:[~2020-04-02 15:37 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 12:45 [PATCHSET 0/9] perf: Improve cgroup profiling (v6) Namhyung Kim
2020-03-25 12:45 ` [PATCH 1/9] perf/core: Add PERF_RECORD_CGROUP event Namhyung Kim
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for Namhyung Kim
2020-03-25 12:45 ` [PATCH 2/9] perf/core: Add PERF_SAMPLE_CGROUP feature Namhyung Kim
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for Namhyung Kim
2020-03-25 12:45 ` [PATCH 3/9] perf tools: Basic support for CGROUP event Namhyung Kim
2020-03-27 14:06   ` Arnaldo Carvalho de Melo
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for Namhyung Kim
2020-03-25 12:45 ` [PATCH 4/9] perf tools: Maintain cgroup hierarchy Namhyung Kim
2020-04-03 12:36   ` Arnaldo Carvalho de Melo
2020-04-04  1:29     ` Namhyung Kim
2020-04-04  8:41     ` [tip: perf/urgent] perf python: Include rwsem.c in the pythong biding tip-bot2 for Arnaldo Carvalho de Melo
2020-04-04  8:41   ` [tip: perf/urgent] perf cgroup: Maintain cgroup hierarchy tip-bot2 for Namhyung Kim
2020-03-25 12:45 ` [PATCH 5/9] perf report: Add 'cgroup' sort key Namhyung Kim
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for Namhyung Kim
2020-03-25 12:45 ` [PATCH 6/9] perf record: Support synthesizing cgroup events Namhyung Kim
2020-03-30 16:30   ` Arnaldo Carvalho de Melo
2020-03-30 16:43     ` Arnaldo Carvalho de Melo
2020-03-31 16:04       ` Arnaldo Carvalho de Melo
2020-04-01 23:22       ` Namhyung Kim
2020-04-02  1:52         ` [PATCH] perf tools: Add file-handle feature test Namhyung Kim
2020-04-02 15:37           ` Arnaldo Carvalho de Melo [this message]
2020-04-02 15:46             ` Arnaldo Carvalho de Melo
2020-04-02 18:37             ` Arnaldo Carvalho de Melo
2020-04-04  8:41           ` [tip: perf/urgent] " tip-bot2 for Namhyung Kim
2020-04-04  8:41   ` [tip: perf/urgent] perf record: Support synthesizing cgroup events tip-bot2 for Namhyung Kim
2020-03-25 12:45 ` [PATCH 7/9] perf record: Add --all-cgroups option Namhyung Kim
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for Namhyung Kim
2020-03-25 12:45 ` [PATCH 8/9] perf top: " Namhyung Kim
2020-03-27 16:35   ` Arnaldo Carvalho de Melo
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for Namhyung Kim
2020-03-25 12:45 ` [PATCH 9/9] perf script: Add --show-cgroup-events option Namhyung Kim
2020-03-27 16:39   ` Arnaldo Carvalho de Melo
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for Namhyung Kim
2020-03-25 13:05 ` [PATCHSET 0/9] perf: Improve cgroup profiling (v6) Arnaldo Carvalho de Melo
2020-03-25 13:19   ` Namhyung Kim

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=20200402153748.GC8736@kernel.org \
    --to=arnaldo.melo@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /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).