perf record: Fix continue profiling after draining the buffer
PATCH 1/1 perf record: Fix continue profiling after draining the buffer
commit da231338ec9c098707c8a1e4d8a50e2400e2fe17 uses eventfd to solve rare race where the setting and checking of 'done' which add done_fd to pollfd. When draining buffer, revents of done_fd is 0 and evlist__filter_pollfd function returns a non-zero value.
As a result, perf record does not stop profiling.
The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!
After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Use fdarray_flag__nonfilterable to set done eventfd to nonfilterable objects, so that evlist__filter_pollfd does not filter and check done eventfd.
--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)
tools/perf/builtin-record.c +1 -1
@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;
tools/perf/util/evlist.c +8 -0
@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); } +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif +int evlist__poll (struct evlist *evlist,int timeout) {return perf_evlist__poll (&evlist->core, timeout);
tools/perf/util/evlist.h +4 -0
@@ -142,6 +142,10 @@ struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const charint evlist__add_pollfd (struct evlist *evlist,int fd);int evlist__filter_pollfd (struct evlist *evlist,short revents_and_mask); +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd); +#endif +int evlist__poll (struct evlist *evlist,int timeout);struct evsel *evlist__id2evsel (struct evlist *evlist,u64 id);
Signature · 1 line
2.17.1
Namhyung Kim
maintainerHello,
Quoted 46 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;tools/perf/util/evlist.c +0
-0
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) · line 581
Quoted 10 lines
tools/perf/util/evlist.c +7
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); } +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif
Does it build when HAVE_EVENTFD_SUPPORT is not defined?
Thanks,
Namhyung
Quoted 22 lines
tools/perf/util/evlist.c +1
-0+int evlist__poll (struct evlist *evlist,int timeout) {return perf_evlist__poll (&evlist->core, timeout);tools/perf/util/evlist.h +4
-1@@ -142,6 +142,10 @@ struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const charint evlist__add_pollfd (struct evlist *evlist,int fd);int evlist__filter_pollfd (struct evlist *evlist,short revents_and_mask); +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd); +#endif +int evlist__poll (struct evlist *evlist,int timeout);struct evsel *evlist__id2evsel (struct evlist *evlist,u64 id); --2.17.1
Quoted 52 lines · Namhyung Kim
Hello,
Quoted 49 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;tools/perf/util/evlist.c +0
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); }
Quoted 9 lines
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) · line 581
Quoted 7 lines
tools/perf/util/evlist.c +7
-0+#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif Does it build when
HAVE_EVENTFD_SUPPORTis not defined?
yea, I was wondering the same.. but it's called only from code within HAVE_EVENTFD_SUPPORT ifdef
jirka
Quoted 28 lines
Thanks,
NamhyungQuoted 22 lines
tools/perf/util/evlist.c +1
-0+int evlist__poll (struct evlist *evlist,int timeout) {return perf_evlist__poll (&evlist->core, timeout);tools/perf/util/evlist.h +4
-1@@ -142,6 +142,10 @@ struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const charint evlist__add_pollfd (struct evlist *evlist,int fd);int evlist__filter_pollfd (struct evlist *evlist,short revents_and_mask); +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd); +#endif +int evlist__poll (struct evlist *evlist,int timeout);struct evsel *evlist__id2evsel (struct evlist *evlist,u64 id); --2.17.1
Hello,
Quoted 63 lines · Jiri Olsa
Quoted 52 lines · Namhyung Kim
Hello,
Quoted 49 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;tools/perf/util/evlist.c +0
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); }Quoted 9 lines
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) · line 581
Quoted 7 lines
tools/perf/util/evlist.c +7
-0+#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif Does it build when
HAVE_EVENTFD_SUPPORTis not defined?
Quoted 10 lines
yea, I was wondering the same.. but it's called only from code within
HAVE_EVENTFD_SUPPORTifdefjirka
Quoted 5 lines
Thanks,
Namhyung
I have tested that if "eventfd" feature is removed from the FEATURE_TESTS_BASIC list in Makefile.feature, evlist__add_wakeup_eventfd will not be build.
Modify as follows:
tools/build/Makefile.feature +0 -1
@@ -32,7 +32,6 @@ FEATURE_TESTS_BASIC := \ backtrace \ dwarf \ dwarf_getlocations \ - eventfd \ fortify-source \ sync-compare-and-swap \ get_current_dir_name \
Thanks,
Yang
Quoted 26 lines
Quoted 18 lines
Quoted 18 lines
tools/perf/util/evlist.c +1
-0+int evlist__poll (struct evlist *evlist,int timeout) {return perf_evlist__poll (&evlist->core, timeout);tools/perf/util/evlist.h +4
-0@@ -142,6 +142,10 @@ struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const charint evlist__add_pollfd (struct evlist *evlist,int fd);int evlist__filter_pollfd (struct evlist *evlist,short revents_and_mask); +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd); +#endif +int evlist__poll (struct evlist *evlist,int timeout);Quoted 5 lines
Quoted 4 lines
tools/perf/util/evlist.h +0
-1struct evsel *evlist__id2evsel (struct evlist *evlist,u64 id); --2.17.1
.
Hello,
Quoted 96 lines · Yang Jihong
Hello,
Quoted 65 lines · Jiri Olsa
Quoted 54 lines · Namhyung Kim
Hello,
Quoted 51 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>---
tools/perf/builtin-record.c| 2 +-
tools/perf/util/evlist.c | 8 ++++++++
tools/perf/util/evlist.h | 4 ++++3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status = -1; goto out_delete_session; } - err = evlist__add_pollfd(rec->evlist, done_fd); + err = evlist__add_wakeup_eventfd(rec->evlist, done_fd); if (err < 0) { pr_err("Failed to add wakeup eventfd to poll list\n");status = err;
tools/perf/util/evlist.c +0
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) return perf_evlist__filter_pollfd(&evlist->core, revents_and_mask); }Quoted 9 lines
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist · line 582
Quoted 7 lines
tools/perf/util/evlist.c +7
-0+#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ + return perf_evlist__add_pollfd(&evlist->core, fd, NULL, POLLIN, + fdarray_flag__nonfilterable); +} +#endif Does it build when
HAVE_EVENTFD_SUPPORTis not defined?Quoted 10 lines
yea, I was wondering the same.. but it's called only from code within
HAVE_EVENTFD_SUPPORTifdefjirka
Quoted 5 lines
Thanks,
NamhyungI have tested that if "eventfd" feature is removed from the
FEATURE_TESTS_BASIClist in Makefile.feature,evlist__add_wakeup_eventfdwill not be build.Modify as follows:
tools/build/Makefile.feature +0
-1@@ -32,7 +32,6 @@ FEATURE_TESTS_BASIC := \ backtrace \ dwarf \ dwarf_getlocations \ - eventfd \ fortify-source \ sync-compare-and-swap \ get_current_dir_name \
Quoted 30 lines
Thanks,
YangQuoted 27 lines
Quoted 19 lines
Quoted 19 lines
tools/perf/util/evlist.c +1
-0+ int evlist__poll(struct evlist *evlist, int timeout) {return
perf_evlist__poll(&evlist->core, timeout);tools/perf/util/evlist.h +4
-0@@ -142,6 +142,10 @@ struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const char int evlist__add_pollfd(struct evlist *evlist, int fd); int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask); +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd); +#endif + int evlist__poll(struct evlist *evlist, int timeout);Quoted 5 lines
Quoted 4 lines
struct evsel *evlist__id2evsel(struct evlist *evlist, u64 id);
Signature · 1 line
2.17.1.
Do have any other questions about this patch?
Look forward to your review.
Thanks,
Yang
Arnaldo Carvalho de Melo
maintainerEm Fri, Feb 05, 2021 at 11:46:12AM +0100, Jiri Olsa escreveu:
Quoted 63 lines · Namhyung Kim
Quoted 52 lines
Hello,
Quoted 49 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;tools/perf/util/evlist.c +0
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); }Quoted 9 lines
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) · line 581
Quoted 7 lines
tools/perf/util/evlist.c +7
-0+#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif Does it build when
HAVE_EVENTFD_SUPPORTis not defined?
Quoted 2 lines
yea, I was wondering the same.. but it's called only from code within
HAVE_EVENTFD_SUPPORTifdef
Yes, this can't work on systems without eventfd, it will simply not build, and why do we have to make the definition of this function conditional on HAVE_EVENTFD_SUPPORT?
I'm missing something :-\
Yeah, this whole call to evlist__add_pollfd is already surrounded by #ifdef HAVE_EVENTFD_SUPPORT:
1656 if (zstd_init(&session->zstd_data, rec->opts.comp_level) < 0) {
1657 pr_err("Compression initialization failed.\n");
1658 return -1;
1659 }
1660 #ifdef HAVE_EVENTFD_SUPPORT
1661 done_fd = eventfd(0, EFD_NONBLOCK);
1662 if (done_fd < 0) {
1663 pr_err("Failed to create wakeup eventfd, error: %m\n");
1664 status = -1;
1665 goto out_delete_session;
1666 }
1667 err = evlist__add_pollfd(rec->evlist, done_fd);
1668 if (err < 0) {
1669 pr_err("Failed to add wakeup eventfd to poll list\n");
1670 status = err;
1671 goto out_delete_session;1672 }
1673 #endif // HAVE_EVENTFD_SUPPORT
1674
1675 session->header.env.comp_type = PERF_COMP_ZSTD;
1676 session->header.env.comp_level = rec->opts.comp_level;
Jiri, does your Acked-by stands? Namhyung?
- Arnaldo
Quoted 31 lines
jirka
Quoted 28 lines
Thanks,
NamhyungQuoted 22 lines
tools/perf/util/evlist.c +1
-0+int evlist__poll (struct evlist *evlist,int timeout) {return perf_evlist__poll (&evlist->core, timeout);tools/perf/util/evlist.h +4
-1@@ -142,6 +142,10 @@ struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const charint evlist__add_pollfd (struct evlist *evlist,int fd);int evlist__filter_pollfd (struct evlist *evlist,short revents_and_mask); +#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd); +#endif +int evlist__poll (struct evlist *evlist,int timeout);struct evsel *evlist__id2evsel (struct evlist *evlist,u64 id); --2.17.1
Signature · 1 line
- Arnaldo
Arnaldo Carvalho de Melo
maintainerEm Thu, Feb 18, 2021 at 10:20:53AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 92 lines
Em Fri, Feb 05, 2021 at 11:46:12AM +0100, Jiri Olsa escreveu:
Quoted 63 lines · Namhyung Kim
Quoted 52 lines
Hello,
Quoted 49 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;tools/perf/util/evlist.c +0
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); }Quoted 9 lines
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) · line 581
Quoted 7 lines
tools/perf/util/evlist.c +7
-0+#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif Does it build when
HAVE_EVENTFD_SUPPORTis not defined?Quoted 2 lines
yea, I was wondering the same.. but it's called only from code within
HAVE_EVENTFD_SUPPORTifdefYes, this can't work on systems without eventfd, it will simply not build, and why do we have to make the definition of this function conditional on
HAVE_EVENTFD_SUPPORT?I'm missing something :-\
Yeah, this whole call to
evlist__add_pollfdis already surrounded by #ifdefHAVE_EVENTFD_SUPPORT:1656 if (
zstd_init(&session->zstd_data, rec->opts.comp_level)< 0) {
1657pr_err("Compression initialization failed.\n");
1658 return -1;
1659 }
1660 #ifdefHAVE_EVENTFD_SUPPORT
1661done_fd=eventfd(0, EFD_NONBLOCK);
1662 if (done_fd< 0) {1663 pr_err("Failed to create wakeup eventfd, error: %m\n"); 1664 status = -1; 1665 goto out_delete_session; 1666 } 1667 err = evlist__add_pollfd(rec->evlist, done_fd); 1668 if (err < 0) { 1669 pr_err("Failed to add wakeup eventfd to poll list\n"); 1670 status = err; 1671 goto out_delete_session;
Quoted 7 lines
1672 }
1673 #endif //HAVE_EVENTFD_SUPPORT
1674
1675session->header.env.comp_type=PERF_COMP_ZSTD;
1676session->header.env.comp_level=rec->opts.comp_level;Jiri, does your Acked-by stands? Namhyung?
Thanks tested and applied, together with Jiri's Tested-by,
- Arnaldo
Hello,
Quoted 99 lines · Arnaldo Carvalho de Melo
Em Thu, Feb 18, 2021 at 10:20:53AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 98 lines
Em Fri, Feb 05, 2021 at 11:46:12AM +0100, Jiri Olsa escreveu:
Quoted 63 lines · Namhyung Kim
Quoted 52 lines
Hello,
Quoted 49 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;tools/perf/util/evlist.c +0
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); }Quoted 9 lines
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) · line 581
Quoted 7 lines
tools/perf/util/evlist.c +7
-0+#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif Does it build when
HAVE_EVENTFD_SUPPORTis not defined?Quoted 2 lines
yea, I was wondering the same.. but it's called only from code within
HAVE_EVENTFD_SUPPORTifdefYes, this can't work on systems without eventfd, it will simply not build, and why do we have to make the definition of this function conditional on
HAVE_EVENTFD_SUPPORT?I'm missing something :-\
Yeah, this whole call to
evlist__add_pollfdis already surrounded by #ifdefHAVE_EVENTFD_SUPPORT:1656 if (
zstd_init(&session->zstd_data, rec->opts.comp_level)< 0) {
1657pr_err("Compression initialization failed.\n");
1658 return -1;
1659 }
1660 #ifdefHAVE_EVENTFD_SUPPORT
1661done_fd=eventfd(0, EFD_NONBLOCK);
1662 if (done_fd< 0) {1663 pr_err("Failed to create wakeup eventfd, error: %m\n"); 1664 status = -1; 1665 goto out_delete_session; 1666 } 1667 err = evlist__add_pollfd(rec->evlist, done_fd); 1668 if (err < 0) { 1669 pr_err("Failed to add wakeup eventfd to poll list\n"); 1670 status = err; 1671 goto out_delete_session;1672 }
1673 #endif //HAVE_EVENTFD_SUPPORT
1674
1675session->header.env.comp_type=PERF_COMP_ZSTD;
1676session->header.env.comp_level=rec->opts.comp_level;
Quoted 7 lines
Quoted 1 line
Jiri, does your Acked-by stands? Namhyung?
Thanks tested and applied, together with Jiri's Tested-by,
- Arnaldo
.
Is this patch okay? Is there anything that needs to be modified?
Thanks,
Yang
Arnaldo Carvalho de Melo
maintainerEm Mon, Feb 22, 2021 at 09:31:51AM +0800, Yang Jihong escreveu:
Quoted 102 lines
Hello,
Quoted 99 lines · Arnaldo Carvalho de Melo
Em Thu, Feb 18, 2021 at 10:20:53AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 98 lines
Em Fri, Feb 05, 2021 at 11:46:12AM +0100, Jiri Olsa escreveu:
Quoted 63 lines · Namhyung Kim
Quoted 52 lines
Hello,
Quoted 49 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;tools/perf/util/evlist.c +0
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); }Quoted 9 lines
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) · line 581
Quoted 7 lines
tools/perf/util/evlist.c +7
-0+#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif Does it build when
HAVE_EVENTFD_SUPPORTis not defined?Quoted 2 lines
yea, I was wondering the same.. but it's called only from code within
HAVE_EVENTFD_SUPPORTifdefYes, this can't work on systems without eventfd, it will simply not build, and why do we have to make the definition of this function conditional on
HAVE_EVENTFD_SUPPORT?I'm missing something :-\
Yeah, this whole call to
evlist__add_pollfdis already surrounded by #ifdefHAVE_EVENTFD_SUPPORT:1656 if (
zstd_init(&session->zstd_data, rec->opts.comp_level)< 0) {
1657pr_err("Compression initialization failed.\n");
1658 return -1;
1659 }
1660 #ifdefHAVE_EVENTFD_SUPPORT
1661done_fd=eventfd(0, EFD_NONBLOCK);
1662 if (done_fd< 0) {1663 pr_err("Failed to create wakeup eventfd, error: %m\n"); 1664 status = -1; 1665 goto out_delete_session; 1666 } 1667 err = evlist__add_pollfd(rec->evlist, done_fd); 1668 if (err < 0) { 1669 pr_err("Failed to add wakeup eventfd to poll list\n"); 1670 status = err; 1671 goto out_delete_session;1672 }
1673 #endif //HAVE_EVENTFD_SUPPORT
1674
1675session->header.env.comp_type=PERF_COMP_ZSTD;
1676session->header.env.comp_level=rec->opts.comp_level;
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Jiri, does your Acked-by stands? Namhyung?
Thanks tested and applied, together with Jiri's Tested-by,
- Arnaldo
.Is this patch okay? Is there anything that needs to be modified?
It was merged:
- Arnaldo
Quoted 112 lines · Arnaldo Carvalho de Melo
Em Mon, Feb 22, 2021 at 09:31:51AM +0800, Yang Jihong escreveu:
Quoted 102 lines
Hello,
Quoted 99 lines · Arnaldo Carvalho de Melo
Em Thu, Feb 18, 2021 at 10:20:53AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 98 lines
Em Fri, Feb 05, 2021 at 11:46:12AM +0100, Jiri Olsa escreveu:
Quoted 63 lines · Namhyung Kim
Quoted 52 lines
Hello,
Quoted 49 lines · Yang Jihong
commit
da231338ec9c098707c8a1e4d8a50e2400e2fe17uses eventfd to solve rare race where the setting and checking of 'done' which adddone_fdto pollfd. When draining buffer, revents ofdone_fdis 0 andevlist__filter_pollfdfunction returns a non-zero value.
As a result, perf record does not stop profiling.The following simple scenarios can trigger this condition:
sleep 10 &
perf record -p $!After the sleep process exits, perf record should stop profiling and exit. However, perf record keeps running.
If pollfd revents contains only POLLERR or POLLHUP,
perf record indicates that buffer is draining and need to stop profiling. Usefdarray_flag__nonfilterableto set done eventfd to nonfilterable objects, so thatevlist__filter_pollfddoes not filter and check done eventfd.Fixes da231338ec9c (perf record: Use an eventfd to wakeup when done)Signed-off-by Yang Jihong <[email protected]>--- tools/perf/builtin-record.c | 2 +- tools/perf/util/evlist.c | 8 ++++++++ tools/perf/util/evlist.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-)tools/perf/builtin-record.c +1
-1@@ -1663,7 +1663,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) status =-1 ; goto out_delete_session; } - err =evlist__add_pollfd (rec->evlist, done_fd); + err =evlist__add_wakeup_eventfd (rec->evlist, done_fd);if (err <0 ) {pr_err ("Failed to add wakeup eventfd to poll list\n" ); status = err;tools/perf/util/evlist.c +0
-0@@ -572,6 +572,14 @@ int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask)return perf_evlist__filter_pollfd (&evlist->core, revents_and_mask); }Quoted 9 lines
tools/perf/util/evlist.c int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) · line 581
Quoted 7 lines
tools/perf/util/evlist.c +7
-0+#ifdef HAVE_EVENTFD_SUPPORT +int evlist__add_wakeup_eventfd (struct evlist *evlist,int fd) +{ +return perf_evlist__add_pollfd (&evlist->core, fd,NULL ,POLLIN , + fdarray_flag__nonfilterable); +} +#endif Does it build when
HAVE_EVENTFD_SUPPORTis not defined?Quoted 2 lines
yea, I was wondering the same.. but it's called only from code within
HAVE_EVENTFD_SUPPORTifdefYes, this can't work on systems without eventfd, it will simply not build, and why do we have to make the definition of this function conditional on
HAVE_EVENTFD_SUPPORT?I'm missing something :-\
Yeah, this whole call to
evlist__add_pollfdis already surrounded by #ifdefHAVE_EVENTFD_SUPPORT:1656 if (
zstd_init(&session->zstd_data, rec->opts.comp_level)< 0) {
1657pr_err("Compression initialization failed.\n");
1658 return -1;
1659 }
1660 #ifdefHAVE_EVENTFD_SUPPORT
1661done_fd=eventfd(0, EFD_NONBLOCK);
1662 if (done_fd< 0) {1663 pr_err("Failed to create wakeup eventfd, error: %m\n"); 1664 status = -1; 1665 goto out_delete_session; 1666 } 1667 err = evlist__add_pollfd(rec->evlist, done_fd); 1668 if (err < 0) { 1669 pr_err("Failed to add wakeup eventfd to poll list\n"); 1670 status = err; 1671 goto out_delete_session;1672 }
1673 #endif //HAVE_EVENTFD_SUPPORT
1674
1675session->header.env.comp_type=PERF_COMP_ZSTD;
1676session->header.env.comp_level=rec->opts.comp_level;Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Jiri, does your Acked-by stands? Namhyung?
Thanks tested and applied, together with Jiri's Tested-by,
- Arnaldo
.Is this patch okay? Is there anything that needs to be modified?
Quoted 7 lines
It was merged:
- Arnaldo
.
Thanks.
Yang