*enabled = 0;
*running = 0;
+ mutex_lock(&event->child_mutex);
total += perf_event_read(event);
*enabled += event->total_time_enabled +
atomic64_read(&event->child_total_time_enabled);
*enabled += child->total_time_enabled;
*running += child->total_time_running;
}
+ mutex_unlock(&event->child_mutex);
return total;
}
u64 read_format, char __user *buf)
{
struct perf_event *leader = event->group_leader, *sub;
- int n = 0, size = 0, ret = 0;
+ int n = 0, size = 0, ret = -EFAULT;
+ struct perf_event_context *ctx = leader->ctx;
u64 values[5];
u64 count, enabled, running;
+ mutex_lock(&ctx->mutex);
count = perf_event_read_value(leader, &enabled, &running);
values[n++] = 1 + leader->nr_siblings;
size = n * sizeof(u64);
if (copy_to_user(buf, values, size))
- return -EFAULT;
+ goto unlock;
- ret += size;
+ ret = size;
list_for_each_entry(sub, &leader->sibling_list, group_entry) {
n = 0;
size = n * sizeof(u64);
- if (copy_to_user(buf + size, values, size))
- return -EFAULT;
+ if (copy_to_user(buf + size, values, size)) {
+ ret = -EFAULT;
+ goto unlock;
+ }
ret += size;
}
+unlock:
+ mutex_unlock(&ctx->mutex);
return ret;
}
return -ENOSPC;
WARN_ON_ONCE(event->ctx->parent_ctx);
- mutex_lock(&event->child_mutex);
if (read_format & PERF_FORMAT_GROUP)
ret = perf_event_read_group(event, read_format, buf);
else
ret = perf_event_read_one(event, read_format, buf);
- mutex_unlock(&event->child_mutex);
return ret;
}