mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
perf namespace: Protect reading thread's namespace
It seems that the current code lacks holding the namespace lock in thread__namespaces(). Otherwise it can see inconsistent results. Signed-off-by: Namhyung Kim <[email protected]> Cc: Hari Bathini <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Krister Johansen <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
parent
9903c64f0f
commit
6584140ba9
1 changed files with 13 additions and 2 deletions
|
|
@ -133,7 +133,7 @@ void thread__put(struct thread *thread)
|
|||
}
|
||||
}
|
||||
|
||||
struct namespaces *thread__namespaces(const struct thread *thread)
|
||||
static struct namespaces *__thread__namespaces(const struct thread *thread)
|
||||
{
|
||||
if (list_empty(&thread->namespaces_list))
|
||||
return NULL;
|
||||
|
|
@ -141,10 +141,21 @@ struct namespaces *thread__namespaces(const struct thread *thread)
|
|||
return list_first_entry(&thread->namespaces_list, struct namespaces, list);
|
||||
}
|
||||
|
||||
struct namespaces *thread__namespaces(const struct thread *thread)
|
||||
{
|
||||
struct namespaces *ns;
|
||||
|
||||
down_read((struct rw_semaphore *)&thread->namespaces_lock);
|
||||
ns = __thread__namespaces(thread);
|
||||
up_read((struct rw_semaphore *)&thread->namespaces_lock);
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
||||
static int __thread__set_namespaces(struct thread *thread, u64 timestamp,
|
||||
struct namespaces_event *event)
|
||||
{
|
||||
struct namespaces *new, *curr = thread__namespaces(thread);
|
||||
struct namespaces *new, *curr = __thread__namespaces(thread);
|
||||
|
||||
new = namespaces__new(event);
|
||||
if (!new)
|
||||
|
|
|
|||
Loading…
Reference in a new issue