lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 7 Mar 2017 00:02:57 -0800 From: tip-bot for Arnaldo Carvalho de Melo <tipbot@...or.com> To: linux-tip-commits@...r.kernel.org Cc: acme@...hat.com, dsahern@...il.com, mingo@...nel.org, elena.reshetova@...el.com, tglx@...utronix.de, wangnan0@...wei.com, adrian.hunter@...el.com, linux-kernel@...r.kernel.org, jolsa@...nel.org, peterz@...radead.org, namhyung@...nel.org, hpa@...or.com Subject: [tip:perf/core] perf evlist: Clarify a bit the use of perf_mmap->refcnt Commit-ID: 4738ca30b4a7a113084d7863846175094f95c62f Gitweb: http://git.kernel.org/tip/4738ca30b4a7a113084d7863846175094f95c62f Author: Arnaldo Carvalho de Melo <acme@...hat.com> AuthorDate: Thu, 23 Feb 2017 13:24:34 -0300 Committer: Arnaldo Carvalho de Melo <acme@...hat.com> CommitDate: Fri, 3 Mar 2017 19:07:16 -0300 perf evlist: Clarify a bit the use of perf_mmap->refcnt This is an odd refcount use case, so add some more comments to help understand that when it hits zero it really means that the mmap()ed area (on a perf_event_open() returned fd) has been munmap()ed. Cc: Adrian Hunter <adrian.hunter@...el.com> Cc: David Ahern <dsahern@...il.com> Cc: Elena Reshetova <elena.reshetova@...el.com> Cc: Jiri Olsa <jolsa@...nel.org> Cc: Namhyung Kim <namhyung@...nel.org> Cc: Peter Zijlstra <peterz@...radead.org> Cc: Wang Nan <wangnan0@...wei.com> Link: http://lkml.kernel.org/r/20170223162344.GD3595@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com> --- tools/perf/util/evlist.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 564b924..50420cd 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -974,8 +974,19 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct perf_evlist *evlist) if (!map) return NULL; - for (i = 0; i < evlist->nr_mmaps; i++) + for (i = 0; i < evlist->nr_mmaps; i++) { map[i].fd = -1; + /* + * When the perf_mmap() call is made we grab one refcount, plus + * one extra to let perf_evlist__mmap_consume() get the last + * events after all real references (perf_mmap__get()) are + * dropped. + * + * Each PERF_EVENT_IOC_SET_OUTPUT points to this mmap and + * thus does perf_mmap__get() on it. + */ + refcount_set(&map[i].refcnt, 0); + } return map; }
Powered by blists - more mailing lists