perf_event_open: Propagate return value
Refs: #1236 Change-Id: I61a4683a533fb199a73a99bc7b2e6f2638212000
This commit is contained in:
@@ -3763,7 +3763,7 @@ SYSCALL_DECLARE(signalfd4)
|
|||||||
int
|
int
|
||||||
perf_counter_alloc(struct thread *thread)
|
perf_counter_alloc(struct thread *thread)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -EINVAL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
// find avail generic counter
|
// find avail generic counter
|
||||||
@@ -4148,20 +4148,23 @@ static int vm_policy_insert(struct process_vm *vm, struct vm_range_numa_policy *
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PERF
|
#ifdef ENABLE_PERF
|
||||||
struct mc_perf_event*
|
static int mc_perf_event_alloc(struct mc_perf_event **out,
|
||||||
mc_perf_event_alloc(struct perf_event_attr *attr)
|
struct perf_event_attr *attr)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
unsigned long val = 0, extra_config = 0;
|
unsigned long val = 0, extra_config = 0;
|
||||||
struct mc_perf_event *event;
|
struct mc_perf_event *event = NULL;
|
||||||
int ereg_id;
|
int ereg_id;
|
||||||
|
|
||||||
if (!attr) {
|
if (!attr) {
|
||||||
return NULL;
|
ret = -EINVAL;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
event = kmalloc(sizeof(struct mc_perf_event), IHK_MC_AP_NOWAIT);
|
event = kmalloc(sizeof(struct mc_perf_event), IHK_MC_AP_NOWAIT);
|
||||||
if (!event) {
|
if (!event) {
|
||||||
return NULL;
|
ret = -ENOMEM;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
memset(event, 0, sizeof(struct mc_perf_event));
|
memset(event, 0, sizeof(struct mc_perf_event));
|
||||||
|
|
||||||
@@ -4189,11 +4192,13 @@ mc_perf_event_alloc(struct perf_event_attr *attr)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// Unexpected type
|
// Unexpected type
|
||||||
return NULL;
|
ret = -EINVAL;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
return NULL;
|
ret = -EINVAL;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
event->hw_config = val;
|
event->hw_config = val;
|
||||||
@@ -4205,11 +4210,19 @@ mc_perf_event_alloc(struct perf_event_attr *attr)
|
|||||||
event->extra_reg.reg = ihk_mc_get_extra_reg_msr(ereg_id);
|
event->extra_reg.reg = ihk_mc_get_extra_reg_msr(ereg_id);
|
||||||
event->extra_reg.idx = ihk_mc_get_extra_reg_idx(ereg_id);
|
event->extra_reg.idx = ihk_mc_get_extra_reg_idx(ereg_id);
|
||||||
}
|
}
|
||||||
return event;
|
|
||||||
|
*out = event;
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (ret) {
|
||||||
|
kfree(event);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSCALL_DECLARE(perf_event_open)
|
SYSCALL_DECLARE(perf_event_open)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
struct syscall_request request IHK_DMA_ALIGN;
|
struct syscall_request request IHK_DMA_ALIGN;
|
||||||
struct thread *thread = cpu_local_var(current);
|
struct thread *thread = cpu_local_var(current);
|
||||||
struct process *proc = thread->proc;
|
struct process *proc = thread->proc;
|
||||||
@@ -4260,16 +4273,16 @@ SYSCALL_DECLARE(perf_event_open)
|
|||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
event = mc_perf_event_alloc((struct perf_event_attr*)attr);
|
ret = mc_perf_event_alloc(&event, (struct perf_event_attr *)attr);
|
||||||
if (!event) {
|
if (ret) {
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
event->pid = pid;
|
event->pid = pid;
|
||||||
|
|
||||||
counter_idx = perf_counter_alloc(thread);
|
counter_idx = perf_counter_alloc(thread);
|
||||||
if (counter_idx < 0) {
|
if (counter_idx < 0) {
|
||||||
return -1;
|
return counter_idx;
|
||||||
}
|
}
|
||||||
event->counter_id = counter_idx;
|
event->counter_id = counter_idx;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user