Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1540251 > unrolled thread
| Started by | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| First post | 2016-12-12 11:40 +0100 |
| Last post | 2016-12-20 20:30 +0100 |
| Articles | 11 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH 0/5] perf record: Allow to ignore missing pid Jiri Olsa <jolsa@kernel.org> - 2016-12-12 11:40 +0100
[PATCH 4/5] perf tools: Allow to ignore missing pid Jiri Olsa <jolsa@kernel.org> - 2016-12-12 11:40 +0100
Re: [PATCH 4/5] perf tools: Allow to ignore missing pid Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-12 15:40 +0100
Re: [PATCH 4/5] perf tools: Allow to ignore missing pid Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-12 15:40 +0100
Re: [PATCH 4/5] perf tools: Allow to ignore missing pid Jiri Olsa <jolsa@redhat.com> - 2016-12-12 16:00 +0100
Re: [PATCH 4/5] perf tools: Allow to ignore missing pid Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-12 16:30 +0100
Re: [PATCH 4/5] perf tools: Allow to ignore missing pid Jiri Olsa <jolsa@redhat.com> - 2016-12-12 16:40 +0100
Re: [PATCH 4/5] perf tools: Allow to ignore missing pid Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-12 20:40 +0100
Re: [PATCH 4/5] perf tools: Allow to ignore missing pid Namhyung Kim <namhyung@kernel.org> - 2016-12-12 18:00 +0100
[PATCHv2 4/5] perf tools: Allow to ignore missing pid Jiri Olsa <jolsa@redhat.com> - 2016-12-13 08:50 +0100
[tip:perf/urgent] perf evsel: Allow to ignore missing pid tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-12-20 20:30 +0100
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-12-12 11:40 +0100 |
| Subject | [PATCH 0/5] perf record: Allow to ignore missing pid |
| Message-ID | <sNwbv-3aN-9@gated-at.bofh.it> |
hi,
this patches allows record's -u option to ignore group of
pids, that 'disappear' before perf opens their event.
This currently leads perf to report error and exit.
With this change we will allow this race and ignore such
failure with warning:
$ perf record -u
WARNING: Ignored open failure for pid 8605
...
and continue monitoring whatever portion of processes
we managed to open.
Plus one extra perf mem fix.
Available also here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
---
Jiri Olsa (5):
perf mem: Fix --all-user/--all-kernel options
perf tools: Use variable instead of repeating lengthy FD macro
perf tools: Add thread_map__remove function
perf tools: Allow to ignore missing pid
perf record: Force ignore_missing_thread for uid option
tools/perf/builtin-mem.c | 4 ++--
tools/perf/builtin-record.c | 3 +++
tools/perf/perf.h | 1 +
tools/perf/tests/builtin-test.c | 4 ++++
tools/perf/tests/tests.h | 1 +
tools/perf/tests/thread-map.c | 43 +++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/evsel.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++--------
tools/perf/util/evsel.h | 1 +
tools/perf/util/thread_map.c | 22 ++++++++++++++++++++++
tools/perf/util/thread_map.h | 1 +
10 files changed, 131 insertions(+), 10 deletions(-)
[toc] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-12-12 11:40 +0100 |
| Subject | [PATCH 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNwbw-3aN-23@gated-at.bofh.it> |
| In reply to | #1540251 |
Adding perf_evsel::ignore_missing_cpu_thread bool.
When set true, it allows perf to ignore error of missing
pid of perf event syscall.
We remove missing thread id from the thread_map, so the
rest of the processing like ioctl and mmap won't get
disturbed with -1 fd.
The reason for supporting this is to ease up monitoring
group of pids, that 'disappear' before perf opens their
event. This currently leads perf to report error and exit
and makes perf record's -u option unusable under certain
setup.
With this change we will allow this race and ignore such
failure with following warning:
WARNING: Ignored open failure for pid 8605
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-atmzsjyhrt1j6xjwwmb84upg@git.kernel.org
---
tools/perf/perf.h | 1 +
tools/perf/util/evsel.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/evsel.h | 1 +
3 files changed, 46 insertions(+)
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 9a0236a4cf95..1c27d947c2fe 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -55,6 +55,7 @@ struct record_opts {
bool all_user;
bool tail_synthesize;
bool overwrite;
+ bool ignore_missing_thread;
unsigned int freq;
unsigned int mmap_pages;
unsigned int auxtrace_mmap_pages;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index fd61ebd77c26..ac87f1637ae9 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -990,6 +990,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
* it overloads any global configuration.
*/
apply_config_terms(evsel, opts);
+
+ evsel->ignore_missing_thread = opts->ignore_missing_thread;
}
static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
@@ -1419,6 +1421,33 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val,
return fprintf(fp, " %-32s %s\n", name, val);
}
+static bool ignore_missing_thread(struct perf_evsel *evsel,
+ struct thread_map *threads,
+ int thread, int err)
+{
+ if (!evsel->ignore_missing_thread)
+ return false;
+
+ /* The system wide setup does not work with threads. */
+ if (!evsel->system_wide)
+ return false;
+
+ /* The -ESRCH is perf event syscall errno for pid's not found. */
+ if (err != -ESRCH)
+ return false;
+
+ /* If there's only one thread, let it fail. */
+ if (threads->nr == 1)
+ return false;
+
+ if (thread_map__remove(threads, thread))
+ return false;
+
+ pr_warning("WARNING: Ignored open failure for pid %d\n",
+ thread_map__pid(threads, thread));
+ return true;
+}
+
static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
struct thread_map *threads)
{
@@ -1491,6 +1520,21 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
if (fd < 0) {
err = -errno;
+
+ if (ignore_missing_thread(evsel, threads, thread, err)) {
+ /*
+ * We just removed 1 thread, so take a step
+ * back on thread index and lower the upper
+ * nthreads limit.
+ */
+ nthreads--;
+ thread--;
+
+ /* ... and pretend like nothing have happened. */
+ err = 0;
+ continue;
+ }
+
pr_debug2("\nsys_perf_event_open failed, error %d\n",
err);
goto try_fallback;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 6abb89cd27f9..06ef6f29efa1 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -120,6 +120,7 @@ struct perf_evsel {
bool tracking;
bool per_pkg;
bool precise_max;
+ bool ignore_missing_thread;
/* parse modifier helper */
int exclude_GH;
int nr_members;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-12 15:40 +0100 |
| Subject | Re: [PATCH 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNzVL-5vw-5@gated-at.bofh.it> |
| In reply to | #1540253 |
Em Mon, Dec 12, 2016 at 11:32:09AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Dec 12, 2016 at 11:35:42AM +0100, Jiri Olsa escreveu:
> > Adding perf_evsel::ignore_missing_cpu_thread bool.
> >
> > When set true, it allows perf to ignore error of missing
> > pid of perf event syscall.
> >
> > We remove missing thread id from the thread_map, so the
> > rest of the processing like ioctl and mmap won't get
> > disturbed with -1 fd
>
> What was the test performed? I tried it here the following while doing
> a 'make -j4 allmodconfig' in the background, i.e. tons of threads coming
> and going, and I sometimes get:
>
> [root@jouet ~]# perf record -u acme
> Error:
> The sys_perf_event_open() syscall returned with 3 (No such process) for
> event (cycles:ppp).
> /bin/dmesg may provide additional information.
> No CONFIG_PERF_EVENTS=y kernel support configured?
> [root@jouet ~]#
So I applied the first three patches, will continue after discussing
this.
- Arnaldo
> > The reason for supporting this is to ease up monitoring
> > group of pids, that 'disappear' before perf opens their
> > event. This currently leads perf to report error and exit
> > and makes perf record's -u option unusable under certain
> > setup.
> >
> > With this change we will allow this race and ignore such
> > failure with following warning:
> >
> > WARNING: Ignored open failure for pid 8605
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > Cc: David Ahern <dsahern@gmail.com>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Link: http://lkml.kernel.org/n/tip-atmzsjyhrt1j6xjwwmb84upg@git.kernel.org
> > ---
> > tools/perf/perf.h | 1 +
> > tools/perf/util/evsel.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> > tools/perf/util/evsel.h | 1 +
> > 3 files changed, 46 insertions(+)
> >
> > diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> > index 9a0236a4cf95..1c27d947c2fe 100644
> > --- a/tools/perf/perf.h
> > +++ b/tools/perf/perf.h
> > @@ -55,6 +55,7 @@ struct record_opts {
> > bool all_user;
> > bool tail_synthesize;
> > bool overwrite;
> > + bool ignore_missing_thread;
> > unsigned int freq;
> > unsigned int mmap_pages;
> > unsigned int auxtrace_mmap_pages;
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index fd61ebd77c26..ac87f1637ae9 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -990,6 +990,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
> > * it overloads any global configuration.
> > */
> > apply_config_terms(evsel, opts);
> > +
> > + evsel->ignore_missing_thread = opts->ignore_missing_thread;
> > }
> >
> > static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
> > @@ -1419,6 +1421,33 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val,
> > return fprintf(fp, " %-32s %s\n", name, val);
> > }
> >
> > +static bool ignore_missing_thread(struct perf_evsel *evsel,
> > + struct thread_map *threads,
> > + int thread, int err)
> > +{
> > + if (!evsel->ignore_missing_thread)
> > + return false;
> > +
> > + /* The system wide setup does not work with threads. */
> > + if (!evsel->system_wide)
> > + return false;
> > +
> > + /* The -ESRCH is perf event syscall errno for pid's not found. */
> > + if (err != -ESRCH)
> > + return false;
> > +
> > + /* If there's only one thread, let it fail. */
> > + if (threads->nr == 1)
> > + return false;
> > +
> > + if (thread_map__remove(threads, thread))
> > + return false;
> > +
> > + pr_warning("WARNING: Ignored open failure for pid %d\n",
> > + thread_map__pid(threads, thread));
> > + return true;
> > +}
> > +
> > static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
> > struct thread_map *threads)
> > {
> > @@ -1491,6 +1520,21 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
> >
> > if (fd < 0) {
> > err = -errno;
> > +
> > + if (ignore_missing_thread(evsel, threads, thread, err)) {
> > + /*
> > + * We just removed 1 thread, so take a step
> > + * back on thread index and lower the upper
> > + * nthreads limit.
> > + */
> > + nthreads--;
> > + thread--;
> > +
> > + /* ... and pretend like nothing have happened. */
> > + err = 0;
> > + continue;
> > + }
> > +
> > pr_debug2("\nsys_perf_event_open failed, error %d\n",
> > err);
> > goto try_fallback;
> > diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> > index 6abb89cd27f9..06ef6f29efa1 100644
> > --- a/tools/perf/util/evsel.h
> > +++ b/tools/perf/util/evsel.h
> > @@ -120,6 +120,7 @@ struct perf_evsel {
> > bool tracking;
> > bool per_pkg;
> > bool precise_max;
> > + bool ignore_missing_thread;
> > /* parse modifier helper */
> > int exclude_GH;
> > int nr_members;
> > --
> > 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-12 15:40 +0100 |
| Subject | Re: [PATCH 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNzVL-5vw-7@gated-at.bofh.it> |
| In reply to | #1540253 |
Em Mon, Dec 12, 2016 at 11:35:42AM +0100, Jiri Olsa escreveu:
> Adding perf_evsel::ignore_missing_cpu_thread bool.
>
> When set true, it allows perf to ignore error of missing
> pid of perf event syscall.
>
> We remove missing thread id from the thread_map, so the
> rest of the processing like ioctl and mmap won't get
> disturbed with -1 fd
What was the test performed? I tried it here the following while doing
a 'make -j4 allmodconfig' in the background, i.e. tons of threads coming
and going, and I sometimes get:
[root@jouet ~]# perf record -u acme
Error:
The sys_perf_event_open() syscall returned with 3 (No such process) for
event (cycles:ppp).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?
[root@jouet ~]#
> The reason for supporting this is to ease up monitoring
> group of pids, that 'disappear' before perf opens their
> event. This currently leads perf to report error and exit
> and makes perf record's -u option unusable under certain
> setup.
>
> With this change we will allow this race and ignore such
> failure with following warning:
>
> WARNING: Ignored open failure for pid 8605
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Link: http://lkml.kernel.org/n/tip-atmzsjyhrt1j6xjwwmb84upg@git.kernel.org
> ---
> tools/perf/perf.h | 1 +
> tools/perf/util/evsel.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/evsel.h | 1 +
> 3 files changed, 46 insertions(+)
>
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index 9a0236a4cf95..1c27d947c2fe 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -55,6 +55,7 @@ struct record_opts {
> bool all_user;
> bool tail_synthesize;
> bool overwrite;
> + bool ignore_missing_thread;
> unsigned int freq;
> unsigned int mmap_pages;
> unsigned int auxtrace_mmap_pages;
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index fd61ebd77c26..ac87f1637ae9 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -990,6 +990,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
> * it overloads any global configuration.
> */
> apply_config_terms(evsel, opts);
> +
> + evsel->ignore_missing_thread = opts->ignore_missing_thread;
> }
>
> static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
> @@ -1419,6 +1421,33 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val,
> return fprintf(fp, " %-32s %s\n", name, val);
> }
>
> +static bool ignore_missing_thread(struct perf_evsel *evsel,
> + struct thread_map *threads,
> + int thread, int err)
> +{
> + if (!evsel->ignore_missing_thread)
> + return false;
> +
> + /* The system wide setup does not work with threads. */
> + if (!evsel->system_wide)
> + return false;
> +
> + /* The -ESRCH is perf event syscall errno for pid's not found. */
> + if (err != -ESRCH)
> + return false;
> +
> + /* If there's only one thread, let it fail. */
> + if (threads->nr == 1)
> + return false;
> +
> + if (thread_map__remove(threads, thread))
> + return false;
> +
> + pr_warning("WARNING: Ignored open failure for pid %d\n",
> + thread_map__pid(threads, thread));
> + return true;
> +}
> +
> static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
> struct thread_map *threads)
> {
> @@ -1491,6 +1520,21 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
>
> if (fd < 0) {
> err = -errno;
> +
> + if (ignore_missing_thread(evsel, threads, thread, err)) {
> + /*
> + * We just removed 1 thread, so take a step
> + * back on thread index and lower the upper
> + * nthreads limit.
> + */
> + nthreads--;
> + thread--;
> +
> + /* ... and pretend like nothing have happened. */
> + err = 0;
> + continue;
> + }
> +
> pr_debug2("\nsys_perf_event_open failed, error %d\n",
> err);
> goto try_fallback;
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index 6abb89cd27f9..06ef6f29efa1 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -120,6 +120,7 @@ struct perf_evsel {
> bool tracking;
> bool per_pkg;
> bool precise_max;
> + bool ignore_missing_thread;
> /* parse modifier helper */
> int exclude_GH;
> int nr_members;
> --
> 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-12-12 16:00 +0100 |
| Subject | Re: [PATCH 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNAf8-5C8-23@gated-at.bofh.it> |
| In reply to | #1540354 |
On Mon, Dec 12, 2016 at 11:32:09AM -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Dec 12, 2016 at 11:35:42AM +0100, Jiri Olsa escreveu: > > Adding perf_evsel::ignore_missing_cpu_thread bool. > > > > When set true, it allows perf to ignore error of missing > > pid of perf event syscall. > > > > We remove missing thread id from the thread_map, so the > > rest of the processing like ioctl and mmap won't get > > disturbed with -1 fd > > What was the test performed? I tried it here the following while doing > a 'make -j4 allmodconfig' in the background, i.e. tons of threads coming > and going, and I sometimes get: > > [root@jouet ~]# perf record -u acme > Error: > The sys_perf_event_open() syscall returned with 3 (No such process) for > event (cycles:ppp). > /bin/dmesg may provide additional information. > No CONFIG_PERF_EVENTS=y kernel support configured? I dont think it's fast enough (start/stop) to hit the race, I've got best results with having on background this: while :; do /usr/bin/true; done jirka
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-12 16:30 +0100 |
| Subject | Re: [PATCH 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNAI9-61i-35@gated-at.bofh.it> |
| In reply to | #1540364 |
Em Mon, Dec 12, 2016 at 03:53:12PM +0100, Jiri Olsa escreveu: > On Mon, Dec 12, 2016 at 11:32:09AM -0300, Arnaldo Carvalho de Melo wrote: > > Em Mon, Dec 12, 2016 at 11:35:42AM +0100, Jiri Olsa escreveu: > > > Adding perf_evsel::ignore_missing_cpu_thread bool. > > > > > > When set true, it allows perf to ignore error of missing > > > pid of perf event syscall. > > > > > > We remove missing thread id from the thread_map, so the > > > rest of the processing like ioctl and mmap won't get > > > disturbed with -1 fd > > > > What was the test performed? I tried it here the following while doing > > a 'make -j4 allmodconfig' in the background, i.e. tons of threads coming > > and going, and I sometimes get: > > > > [root@jouet ~]# perf record -u acme > > Error: > > The sys_perf_event_open() syscall returned with 3 (No such process) for > > event (cycles:ppp). > > /bin/dmesg may provide additional information. > > No CONFIG_PERF_EVENTS=y kernel support configured? > > I dont think it's fast enough (start/stop) to hit the race, I've got best > results with having on background this: > > while :; do /usr/bin/true; done Ok, but the focus of my message wasn't on generating threads, was in having the above happen with your patch applied. - Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-12-12 16:40 +0100 |
| Subject | Re: [PATCH 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNARQ-64o-15@gated-at.bofh.it> |
| In reply to | #1540389 |
On Mon, Dec 12, 2016 at 12:21:49PM -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Dec 12, 2016 at 03:53:12PM +0100, Jiri Olsa escreveu: > > On Mon, Dec 12, 2016 at 11:32:09AM -0300, Arnaldo Carvalho de Melo wrote: > > > Em Mon, Dec 12, 2016 at 11:35:42AM +0100, Jiri Olsa escreveu: > > > > Adding perf_evsel::ignore_missing_cpu_thread bool. > > > > > > > > When set true, it allows perf to ignore error of missing > > > > pid of perf event syscall. > > > > > > > > We remove missing thread id from the thread_map, so the > > > > rest of the processing like ioctl and mmap won't get > > > > disturbed with -1 fd > > > > > > What was the test performed? I tried it here the following while doing > > > a 'make -j4 allmodconfig' in the background, i.e. tons of threads coming > > > and going, and I sometimes get: > > > > > > [root@jouet ~]# perf record -u acme > > > Error: > > > The sys_perf_event_open() syscall returned with 3 (No such process) for > > > event (cycles:ppp). > > > /bin/dmesg may provide additional information. > > > No CONFIG_PERF_EVENTS=y kernel support configured? > > > > I dont think it's fast enough (start/stop) to hit the race, I've got best > > results with having on background this: > > > > while :; do /usr/bin/true; done > > Ok, but the focus of my message wasn't on generating threads, was in > having the above happen with your patch applied. hum, actualy the patch 5 enables that for -u option.. this patch just adds the logic jirka
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-12-12 20:40 +0100 |
| Subject | Re: [PATCH 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNEC6-8kr-13@gated-at.bofh.it> |
| In reply to | #1540392 |
Em Mon, Dec 12, 2016 at 04:38:44PM +0100, Jiri Olsa escreveu: > On Mon, Dec 12, 2016 at 12:21:49PM -0300, Arnaldo Carvalho de Melo wrote: > > Em Mon, Dec 12, 2016 at 03:53:12PM +0100, Jiri Olsa escreveu: > > > On Mon, Dec 12, 2016 at 11:32:09AM -0300, Arnaldo Carvalho de Melo wrote: > > > > Em Mon, Dec 12, 2016 at 11:35:42AM +0100, Jiri Olsa escreveu: > > > > > Adding perf_evsel::ignore_missing_cpu_thread bool. > > > > > > > > > > When set true, it allows perf to ignore error of missing > > > > > pid of perf event syscall. > > > > > > > > > > We remove missing thread id from the thread_map, so the > > > > > rest of the processing like ioctl and mmap won't get > > > > > disturbed with -1 fd > > > > > > > > What was the test performed? I tried it here the following while doing > > > > a 'make -j4 allmodconfig' in the background, i.e. tons of threads coming > > > > and going, and I sometimes get: > > > > > > > > [root@jouet ~]# perf record -u acme > > > > Error: > > > > The sys_perf_event_open() syscall returned with 3 (No such process) for > > > > event (cycles:ppp). > > > > /bin/dmesg may provide additional information. > > > > No CONFIG_PERF_EVENTS=y kernel support configured? > > > > > > I dont think it's fast enough (start/stop) to hit the race, I've got best > > > results with having on background this: > > > > > > while :; do /usr/bin/true; done > > > > Ok, but the focus of my message wasn't on generating threads, was in > > having the above happen with your patch applied. > > hum, actualy the patch 5 enables that for -u option.. this patch just adds the logic Sure, I noticed that, and the above is with your patches, all of them, that is why I asked about this behaviour, how you tested it, etc. - Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2016-12-12 18:00 +0100 |
| Subject | Re: [PATCH 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNC7g-6Ka-17@gated-at.bofh.it> |
| In reply to | #1540253 |
Hi Jiri,
On Mon, Dec 12, 2016 at 11:35:42AM +0100, Jiri Olsa wrote:
> Adding perf_evsel::ignore_missing_cpu_thread bool.
>
> When set true, it allows perf to ignore error of missing
> pid of perf event syscall.
>
> We remove missing thread id from the thread_map, so the
> rest of the processing like ioctl and mmap won't get
> disturbed with -1 fd.
>
> The reason for supporting this is to ease up monitoring
> group of pids, that 'disappear' before perf opens their
> event. This currently leads perf to report error and exit
> and makes perf record's -u option unusable under certain
> setup.
>
> With this change we will allow this race and ignore such
> failure with following warning:
>
> WARNING: Ignored open failure for pid 8605
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Link: http://lkml.kernel.org/n/tip-atmzsjyhrt1j6xjwwmb84upg@git.kernel.org
> ---
> tools/perf/perf.h | 1 +
> tools/perf/util/evsel.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/evsel.h | 1 +
> 3 files changed, 46 insertions(+)
>
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index 9a0236a4cf95..1c27d947c2fe 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -55,6 +55,7 @@ struct record_opts {
> bool all_user;
> bool tail_synthesize;
> bool overwrite;
> + bool ignore_missing_thread;
> unsigned int freq;
> unsigned int mmap_pages;
> unsigned int auxtrace_mmap_pages;
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index fd61ebd77c26..ac87f1637ae9 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -990,6 +990,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
> * it overloads any global configuration.
> */
> apply_config_terms(evsel, opts);
> +
> + evsel->ignore_missing_thread = opts->ignore_missing_thread;
> }
>
> static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
> @@ -1419,6 +1421,33 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val,
> return fprintf(fp, " %-32s %s\n", name, val);
> }
>
> +static bool ignore_missing_thread(struct perf_evsel *evsel,
> + struct thread_map *threads,
> + int thread, int err)
> +{
> + if (!evsel->ignore_missing_thread)
> + return false;
> +
> + /* The system wide setup does not work with threads. */
> + if (!evsel->system_wide)
> + return false;
I'm bit confused with this. Shouldn't the condition be positive?
Thanks,
Namhyung
> +
> + /* The -ESRCH is perf event syscall errno for pid's not found. */
> + if (err != -ESRCH)
> + return false;
> +
> + /* If there's only one thread, let it fail. */
> + if (threads->nr == 1)
> + return false;
> +
> + if (thread_map__remove(threads, thread))
> + return false;
> +
> + pr_warning("WARNING: Ignored open failure for pid %d\n",
> + thread_map__pid(threads, thread));
> + return true;
> +}
> +
> static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
> struct thread_map *threads)
> {
> @@ -1491,6 +1520,21 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
>
> if (fd < 0) {
> err = -errno;
> +
> + if (ignore_missing_thread(evsel, threads, thread, err)) {
> + /*
> + * We just removed 1 thread, so take a step
> + * back on thread index and lower the upper
> + * nthreads limit.
> + */
> + nthreads--;
> + thread--;
> +
> + /* ... and pretend like nothing have happened. */
> + err = 0;
> + continue;
> + }
> +
> pr_debug2("\nsys_perf_event_open failed, error %d\n",
> err);
> goto try_fallback;
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index 6abb89cd27f9..06ef6f29efa1 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -120,6 +120,7 @@ struct perf_evsel {
> bool tracking;
> bool per_pkg;
> bool precise_max;
> + bool ignore_missing_thread;
> /* parse modifier helper */
> int exclude_GH;
> int nr_members;
> --
> 2.7.4
>
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-12-13 08:50 +0100 |
| Subject | [PATCHv2 4/5] perf tools: Allow to ignore missing pid |
| Message-ID | <sNQ0x-6QJ-3@gated-at.bofh.it> |
| In reply to | #1540458 |
On Tue, Dec 13, 2016 at 01:58:25AM +0900, Namhyung Kim wrote:
SNIP
> > }
> >
> > +static bool ignore_missing_thread(struct perf_evsel *evsel,
> > + struct thread_map *threads,
> > + int thread, int err)
> > +{
> > + if (!evsel->ignore_missing_thread)
> > + return false;
> > +
> > + /* The system wide setup does not work with threads. */
> > + if (!evsel->system_wide)
> > + return false;
>
> I'm bit confused with this. Shouldn't the condition be positive?
>
ugh, right.. that was last minute change, I had this condition
below together with ignore_missing_thread call and moved it up :-\
thanks for spotting this, attaching v2
jirka
---
Adding perf_evsel::ignore_missing_cpu_thread bool.
When set true, it allows perf to ignore error of missing
pid of perf event syscall.
We remove missing thread id from the thread_map, so the
rest of the processing like ioctl and mmap won't get
disturbed with -1 fd.
The reason for supporting this is to ease up monitoring
group of pids, that 'disappear' before perf opens their
event. This currently leads perf to report error and exit
and makes perf record's -u option unusable under certain
setup.
With this change we will allow this race and ignore such
failure with following warning:
WARNING: Ignored open failure for pid 8605
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-atmzsjyhrt1j6xjwwmb84upg@git.kernel.org
---
tools/perf/perf.h | 1 +
tools/perf/util/evsel.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/evsel.h | 1 +
3 files changed, 46 insertions(+)
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 9a0236a4cf95..1c27d947c2fe 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -55,6 +55,7 @@ struct record_opts {
bool all_user;
bool tail_synthesize;
bool overwrite;
+ bool ignore_missing_thread;
unsigned int freq;
unsigned int mmap_pages;
unsigned int auxtrace_mmap_pages;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index fd61ebd77c26..04e536ae4d88 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -990,6 +990,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
* it overloads any global configuration.
*/
apply_config_terms(evsel, opts);
+
+ evsel->ignore_missing_thread = opts->ignore_missing_thread;
}
static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
@@ -1419,6 +1421,33 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val,
return fprintf(fp, " %-32s %s\n", name, val);
}
+static bool ignore_missing_thread(struct perf_evsel *evsel,
+ struct thread_map *threads,
+ int thread, int err)
+{
+ if (!evsel->ignore_missing_thread)
+ return false;
+
+ /* The system wide setup does not work with threads. */
+ if (evsel->system_wide)
+ return false;
+
+ /* The -ESRCH is perf event syscall errno for pid's not found. */
+ if (err != -ESRCH)
+ return false;
+
+ /* If there's only one thread, let it fail. */
+ if (threads->nr == 1)
+ return false;
+
+ if (thread_map__remove(threads, thread))
+ return false;
+
+ pr_warning("WARNING: Ignored open failure for pid %d\n",
+ thread_map__pid(threads, thread));
+ return true;
+}
+
static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
struct thread_map *threads)
{
@@ -1491,6 +1520,21 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
if (fd < 0) {
err = -errno;
+
+ if (ignore_missing_thread(evsel, threads, thread, err)) {
+ /*
+ * We just removed 1 thread, so take a step
+ * back on thread index and lower the upper
+ * nthreads limit.
+ */
+ nthreads--;
+ thread--;
+
+ /* ... and pretend like nothing have happened. */
+ err = 0;
+ continue;
+ }
+
pr_debug2("\nsys_perf_event_open failed, error %d\n",
err);
goto try_fallback;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 6abb89cd27f9..06ef6f29efa1 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -120,6 +120,7 @@ struct perf_evsel {
bool tracking;
bool per_pkg;
bool precise_max;
+ bool ignore_missing_thread;
/* parse modifier helper */
int exclude_GH;
int nr_members;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Jiri Olsa <tipbot@zytor.com> |
|---|---|
| Date | 2016-12-20 20:30 +0100 |
| Subject | [tip:perf/urgent] perf evsel: Allow to ignore missing pid |
| Message-ID | <sQygT-1i9-63@gated-at.bofh.it> |
| In reply to | #1540873 |
Commit-ID: a359c17a7e1a9c99384499cf7b43d80867080789
Gitweb: http://git.kernel.org/tip/a359c17a7e1a9c99384499cf7b43d80867080789
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Tue, 13 Dec 2016 08:46:22 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 15 Dec 2016 16:25:46 -0300
perf evsel: Allow to ignore missing pid
Adding perf_evsel::ignore_missing_cpu_thread bool.
When set true, it allows perf to ignore error of missing pid of perf
event syscall.
We remove missing thread id from the thread_map, so the rest of the
processing like ioctl and mmap won't get disturbed with -1 fd.
The reason for supporting this is to ease up monitoring group of pids,
that 'disappear' before perf opens their event. This currently leads
perf to report error and exit and makes perf record's -u option unusable
under certain setup.
With this change we will allow this race and ignore such failure with
following warning:
WARNING: Ignored open failure for pid 8605
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20161213074622.GA3084@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/perf.h | 1 +
tools/perf/util/evsel.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/evsel.h | 1 +
3 files changed, 46 insertions(+)
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 9a0236a..1c27d94 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -55,6 +55,7 @@ struct record_opts {
bool all_user;
bool tail_synthesize;
bool overwrite;
+ bool ignore_missing_thread;
unsigned int freq;
unsigned int mmap_pages;
unsigned int auxtrace_mmap_pages;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index fd61ebd..04e536a 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -990,6 +990,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
* it overloads any global configuration.
*/
apply_config_terms(evsel, opts);
+
+ evsel->ignore_missing_thread = opts->ignore_missing_thread;
}
static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
@@ -1419,6 +1421,33 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val,
return fprintf(fp, " %-32s %s\n", name, val);
}
+static bool ignore_missing_thread(struct perf_evsel *evsel,
+ struct thread_map *threads,
+ int thread, int err)
+{
+ if (!evsel->ignore_missing_thread)
+ return false;
+
+ /* The system wide setup does not work with threads. */
+ if (evsel->system_wide)
+ return false;
+
+ /* The -ESRCH is perf event syscall errno for pid's not found. */
+ if (err != -ESRCH)
+ return false;
+
+ /* If there's only one thread, let it fail. */
+ if (threads->nr == 1)
+ return false;
+
+ if (thread_map__remove(threads, thread))
+ return false;
+
+ pr_warning("WARNING: Ignored open failure for pid %d\n",
+ thread_map__pid(threads, thread));
+ return true;
+}
+
static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
struct thread_map *threads)
{
@@ -1491,6 +1520,21 @@ retry_open:
if (fd < 0) {
err = -errno;
+
+ if (ignore_missing_thread(evsel, threads, thread, err)) {
+ /*
+ * We just removed 1 thread, so take a step
+ * back on thread index and lower the upper
+ * nthreads limit.
+ */
+ nthreads--;
+ thread--;
+
+ /* ... and pretend like nothing have happened. */
+ err = 0;
+ continue;
+ }
+
pr_debug2("\nsys_perf_event_open failed, error %d\n",
err);
goto try_fallback;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 6abb89c..06ef6f2 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -120,6 +120,7 @@ struct perf_evsel {
bool tracking;
bool per_pkg;
bool precise_max;
+ bool ignore_missing_thread;
/* parse modifier helper */
int exclude_GH;
int nr_members;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web