struct perf_counter *counter;
counter = container_of(head, struct perf_counter, rcu_head);
+ if (counter->ns)
+ put_pid_ns(counter->ns);
kfree(counter);
}
rcu_read_unlock();
}
+static u32 perf_counter_pid(struct perf_counter *counter, struct task_struct *p)
+{
+ /*
+ * only top level counters have the pid namespace they were created in
+ */
+ if (counter->parent)
+ counter = counter->parent;
+
+ return task_tgid_nr_ns(p, counter->ns);
+}
+
+static u32 perf_counter_tid(struct perf_counter *counter, struct task_struct *p)
+{
+ /*
+ * only top level counters have the pid namespace they were created in
+ */
+ if (counter->parent)
+ counter = counter->parent;
+
+ return task_pid_nr_ns(p, counter->ns);
+}
+
static void perf_counter_output(struct perf_counter *counter,
int nmi, struct pt_regs *regs, u64 addr)
{
if (record_type & PERF_RECORD_TID) {
/* namespace issues */
- tid_entry.pid = current->group_leader->pid;
- tid_entry.tid = current->pid;
+ tid_entry.pid = perf_counter_pid(counter, current);
+ tid_entry.tid = perf_counter_tid(counter, current);
header.type |= PERF_RECORD_TID;
header.size += sizeof(tid_entry);
if (ret)
return;
+ comm_event->event.pid = perf_counter_pid(counter, comm_event->task);
+ comm_event->event.tid = perf_counter_tid(counter, comm_event->task);
+
perf_output_put(&handle, comm_event->event);
perf_output_copy(&handle, comm_event->comm,
comm_event->comm_size);
.task = task,
.event = {
.header = { .type = PERF_EVENT_COMM, },
- .pid = task->group_leader->pid,
- .tid = task->pid,
},
};
if (ret)
return;
+ mmap_event->event.pid = perf_counter_pid(counter, current);
+ mmap_event->event.tid = perf_counter_tid(counter, current);
+
perf_output_put(&handle, mmap_event->event);
perf_output_copy(&handle, mmap_event->file_name,
mmap_event->file_size);
.file = file,
.event = {
.header = { .type = PERF_EVENT_MMAP, },
- .pid = current->group_leader->pid,
- .tid = current->pid,
.start = addr,
.len = len,
.pgoff = pgoff,
.file = file,
.event = {
.header = { .type = PERF_EVENT_MUNMAP, },
- .pid = current->group_leader->pid,
- .tid = current->pid,
.start = addr,
.len = len,
.pgoff = pgoff,
list_add_tail(&counter->owner_entry, ¤t->perf_counter_list);
mutex_unlock(¤t->perf_counter_mutex);
+ counter->ns = get_pid_ns(current->nsproxy->pid_ns);
+
fput_light(counter_file, fput_needed2);
out_fput: