[PATCH] perfmon: fix async exit bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Tony,

Recently, some users have identified a problem with the current
Linux/ia64 perfmon implementation.

There was a bug with the way perfmon cleans up the asynchronous
notification queue used when
you enable O_ASYNC of the file descriptor. the bug was due to the fact
that we were cleaning up
the queue too early, in the flush callback of the file instead of the
close callback.  This was causing
problems with fork() and the child potentially stoppping signal
notification in the parent session.

The following patch fixes the problem. Please apply.

Changelog:

       Move the cleanup of the async queue to the close callback from
the flush callback. This avoids losing
       asynchronous overflow notifications when the file descriptor is
shared by multiple processes and one
       terminates.

 Signed-off-by: Stephane Eranian <eranian@xxxxxxxxx>
--

diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 71d0513..7cee6e2 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -1864,11 +1864,6 @@ pfm_flush(struct file *filp, fl_owner_t id)
 	 * invoked after, it will find an empty queue and no
 	 * signal will be sent. In both case, we are safe
 	 */
-	if (filp->f_flags & FASYNC) {
-		DPRINT(("cleaning up async_queue=%p\n", ctx->ctx_async_queue));
-		pfm_do_fasync (-1, filp, ctx, 0);
-	}
-
 	PROTECT_CTX(ctx, flags);

 	state     = ctx->ctx_state;
@@ -1999,6 +1994,11 @@ pfm_close(struct inode *inode, struct file *filp)
 		return -EBADF;
 	}

+	if (filp->f_flags & FASYNC) {
+		DPRINT(("cleaning up async_queue=%p\n", ctx->ctx_async_queue));
+		pfm_do_fasync (-1, filp, ctx, 0);
+	}
+
 	PROTECT_CTX(ctx, flags);

 	state     = ctx->ctx_state;
--
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Sparc Linux]     [DCCP]     [Linux ARM]     [Yosemite News]     [Linux SCSI]     [Linux x86_64]     [Linux for Ham Radio]

  Powered by Linux