mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
b91fc39f4a
In addition to using refcounts for the struct thread lifetime management, we need to protect access to machine->threads from concurrent access. That happens in 'perf top', where a thread processes events, inserting and deleting entries from that rb_tree while another thread decays hist_entries, that end up dropping references and ultimately deleting threads from the rb_tree and releasing its resources when no further hist_entry (or other data structures, like in 'perf sched') references it. So the rule is the same for refcounts + protected trees in the kernel, get the tree lock, find object, bump the refcount, drop the tree lock, return, use object, drop the refcount if no more use of it is needed, keep it if storing it in some other data structure, drop when releasing that data structure. I.e. pair "t = machine__find(new)_thread()" with a "thread__put(t)", and "perf_event__preprocess_sample(&al)" with "addr_location__put(&al)". The addr_location__put() one is because as we return references to several data structures, we may end up adding more reference counting for the other data structures and then we'll drop it at addr_location__put() time. Acked-by: David Ahern <dsahern@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-bs9rt4n0jw3hi9f3zxyy3xln@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> |
||
---|---|---|
.. | ||
attr | ||
attr.c | ||
attr.py | ||
bp_signal_overflow.c | ||
bp_signal.c | ||
Build | ||
builtin-test.c | ||
code-reading.c | ||
dso-data.c | ||
dwarf-unwind.c | ||
evsel-roundtrip-name.c | ||
evsel-tp-sched.c | ||
fdarray.c | ||
hists_common.c | ||
hists_common.h | ||
hists_cumulate.c | ||
hists_filter.c | ||
hists_link.c | ||
hists_output.c | ||
keep-tracking.c | ||
kmod-path.c | ||
make | ||
mmap-basic.c | ||
mmap-thread-lookup.c | ||
open-syscall-all-cpus.c | ||
open-syscall-tp-fields.c | ||
open-syscall.c | ||
parse-events.c | ||
parse-no-sample-id-all.c | ||
perf-record.c | ||
perf-targz-src-pkg | ||
perf-time-to-tsc.c | ||
pmu.c | ||
python-use.c | ||
rdpmc.c | ||
sample-parsing.c | ||
sw-clock.c | ||
switch-tracking.c | ||
task-exit.c | ||
tests.h | ||
thread-mg-share.c | ||
vmlinux-kallsyms.c |