Subject: Re: -mm7 go boom
From: Suparna Bhattacharya <[email-masked]>
To: Andrew Morton <[email-masked]>
Cc: [email-masked]
Date: Wed, 11 Jun 2003 12:09:55 +0530

On Tue, Jun 10, 2003 at 10:53:58PM -0700, Andrew Morton wrote:
> Suparna Bhattacharya <[email-masked]> wrote:
> >
> > > 
> >  > I'm suspecting that there's garbage on the workqueue pointed to
> >  > by local var `cwq'.  ie: a kioctx got freed up while it was still
> >  > queued up via schedule_work().
> >  > 
> > 
> >  Hmm, looking at the code, I don't see a protection against this
> >  case, so that's something to fix anyway I guess. However, we'd
> >  see this only if the program is done with the ioctx (e.g exit or
> >  Ctrl C, or an explicit call to destroy the ioctx).
> > 
> >  Phil, Do you see this when the program is about to exit (normally
> >  or due to some other signal) ? 
> 
> Apparently tasks were exitting at the time.   The test runs over
> a thousand processes.

OK. Could try the attached patch and see if it helps.
Its a little strong, but I didn't find a direct way to just flush
/delete a particular workqueue entry.

Regards
Suparna

-- 
Suparna Bhattacharya ([email-masked])
Linux Technology Center
IBM Software Labs, India

diff -ur -X dontdiff linux-2.5.70-mm5/fs/aio.c linux-2.5.70-mm5-dbg/fs/aio.c
--- linux-2.5.70-mm5/fs/aio.c	Fri Jun  6 17:45:26 2003
+++ linux-2.5.70-mm5-dbg/fs/aio.c	Wed Jun 11 13:35:55 2003
@@ -346,6 +347,11 @@
 		aio_cancel_all(ctx);
 
 		wait_for_all_aios(ctx);
+		/* 
+		 * this is an overkill, but ensures we don't leave 
+		 * the ctx on the aio_wq
+		 */
+		flush_workqueue(aio_wq);
 
 		if (1 != atomic_read(&ctx->users))
 			printk(KERN_DEBUG
@@ -1147,6 +1171,11 @@
 
 	aio_cancel_all(ioctx);
 	wait_for_all_aios(ioctx);
+	/* 
+	 * this is an overkill, but ensures we don't leave 
+	 * the ctx on the aio_wq
+	 */
+	flush_workqueue(aio_wq);
 	put_ioctx(ioctx);	/* once for the lookup */
 }