Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf evsel: Record fd into perf_mmap

Add a fd field into struct perf_mmap so that perf can track the mmap fd.

This feature will be used for toggling overwrite ring buffers.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1463762315-155689-3-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Wang Nan and committed by
Arnaldo Carvalho de Melo
d4c6fb36 b90dc17a

+7
+6
tools/perf/util/evlist.c
··· 881 881 if (evlist->mmap[idx].base != NULL) { 882 882 munmap(evlist->mmap[idx].base, evlist->mmap_len); 883 883 evlist->mmap[idx].base = NULL; 884 + evlist->mmap[idx].fd = -1; 884 885 atomic_set(&evlist->mmap[idx].refcnt, 0); 885 886 } 886 887 auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap); ··· 902 901 903 902 static int perf_evlist__alloc_mmap(struct perf_evlist *evlist) 904 903 { 904 + int i; 905 + 905 906 evlist->nr_mmaps = cpu_map__nr(evlist->cpus); 906 907 if (cpu_map__empty(evlist->cpus)) 907 908 evlist->nr_mmaps = thread_map__nr(evlist->threads); 908 909 evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap)); 910 + for (i = 0; i < evlist->nr_mmaps; i++) 911 + evlist->mmap[i].fd = -1; 909 912 return evlist->mmap != NULL ? 0 : -ENOMEM; 910 913 } 911 914 ··· 946 941 evlist->mmap[idx].base = NULL; 947 942 return -1; 948 943 } 944 + evlist->mmap[idx].fd = fd; 949 945 950 946 if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap, 951 947 &mp->auxtrace_mp, evlist->mmap[idx].base, fd))
+1
tools/perf/util/evlist.h
··· 28 28 struct perf_mmap { 29 29 void *base; 30 30 int mask; 31 + int fd; 31 32 atomic_t refcnt; 32 33 u64 prev; 33 34 struct auxtrace_mmap auxtrace_mmap;