int sysctl_perf_counter_mlock __read_mostly = 512; /* 'free' kb per user */
int sysctl_perf_counter_limit __read_mostly = 100000; /* max NMIs per second */
+static atomic64_t perf_counter_id;
+
/*
* Lock for (sysadmin-configurable) counter reservations:
*/
mutex_init(&counter->mmap_mutex);
- counter->cpu = cpu;
+ counter->cpu = cpu;
counter->attr = *attr;
- counter->group_leader = group_leader;
- counter->pmu = NULL;
- counter->ctx = ctx;
- counter->oncpu = -1;
+ counter->group_leader = group_leader;
+ counter->pmu = NULL;
+ counter->ctx = ctx;
+ counter->oncpu = -1;
+
+ counter->ns = get_pid_ns(current->nsproxy->pid_ns);
+ counter->id = atomic64_inc_return(&perf_counter_id);
+
+ counter->state = PERF_COUNTER_STATE_INACTIVE;
- counter->state = PERF_COUNTER_STATE_INACTIVE;
if (attr->disabled)
counter->state = PERF_COUNTER_STATE_OFF;
err = PTR_ERR(pmu);
if (err) {
+ if (counter->ns)
+ put_pid_ns(counter->ns);
kfree(counter);
return ERR_PTR(err);
}
return counter;
}
-static atomic64_t perf_counter_id;
-
/**
* sys_perf_counter_open - open a performance counter, associate it to a task/cpu
*
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);
- counter->id = atomic64_inc_return(&perf_counter_id);
-
fput_light(counter_file, fput_needed2);
out_fput: