Commit 6ba3093f authored by Stéphane Eranian's avatar Stéphane Eranian Committed by Tony Luck

[IA64] perfmon2 fasync fix

the pfm_fasync() function must not lock the context and mask interrupts
because the fasync_helper() function may allocate memory and this could
lead to sleeping, due to SLAB_KERNEL memory type, if no memory is available.
Going to sleep with interrupts mask is not allowed otherwise you have a deadlock.
The locking of the context is not necessary in this function because it is protected
by caller via get_fd()/put_fd(). The async_queue is also protected. Serialization to
pfm_fasync() is also ensured by caller. The fix is to drop the PROTECT_CTX()
and UNPROTECT_CTX() calls.
signed-off-by: default avatarstephane eranian <eranian@hpl.hp.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent ab135bf7
......@@ -1678,7 +1678,6 @@ static int
pfm_fasync(int fd, struct file *filp, int on)
{
pfm_context_t *ctx;
unsigned long flags;
int ret;
if (PFM_IS_FILE(filp) == 0) {
......@@ -1691,19 +1690,21 @@ pfm_fasync(int fd, struct file *filp, int on)
printk(KERN_ERR "perfmon: pfm_fasync NULL ctx [%d]\n", current->pid);
return -EBADF;
}
PROTECT_CTX(ctx, flags);
/*
* we cannot mask interrupts during this call because this may
* may go to sleep if memory is not readily avalaible.
*
* We are protected from the conetxt disappearing by the get_fd()/put_fd()
* done in caller. Serialization of this function is ensured by caller.
*/
ret = pfm_do_fasync(fd, filp, ctx, on);
DPRINT(("pfm_fasync called on ctx_fd=%d on=%d async_queue=%p ret=%d\n",
fd,
on,
ctx->ctx_async_queue, ret));
UNPROTECT_CTX(ctx, flags);
return ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment