public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin LaHaise <bcrl@linux.intel.com>
To: "Sébastien Dugué" <sebastien.dugue@bull.net>
Cc: linux-aio@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [AIO] aio-2.6.13-rc6-B1
Date: Tue, 20 Sep 2005 15:13:29 -0400	[thread overview]
Message-ID: <20050920191329.GA6579@linux.intel.com> (raw)
In-Reply-To: <1127211790.2051.9.camel@frecb000686>

On Tue, Sep 20, 2005 at 12:23:10PM +0200, Sébastien Dugué wrote:
>   what's the point of calling wake_up_locked(&sem->wait) in 
> aio_down_wait? We're already in a wakeup path and end up
> calling __wake_up_common recursively.

That's necessary to kick the next semaphore op in the list.  The 
list_del_init() right above that makes sure that we don't recurse 
and run the routine again.

>   I think it may be one of the cause of my kernel hanging at the
> very beginning.
> 
>   When I remove this call things go further but at some point a
> semaphore wait queue gets thrashed and __wake_up_common tries to
> call an invalid callback function.

This patch from Zach might make a difference.  Let me know if it changes 
the symptoms at all.  Sorry if it doesn't apply cleanly, as it is against 
a base kernel.  Basically, we could sleep while holding ctx_lock, which 
does Bad Things(tm) on SMP systems.

		-ben


Index: 2.6.13-git12-lock-kiocb/fs/aio.c
===================================================================
--- 2.6.13-git12-lock-kiocb.orig/fs/aio.c
+++ 2.6.13-git12-lock-kiocb/fs/aio.c
@@ -398,7 +398,7 @@ static struct kiocb fastcall *__aio_get_
 	if (unlikely(!req))
 		return NULL;
 
-	req->ki_flags = 1 << KIF_LOCKED;
+	req->ki_flags = 0;
 	req->ki_users = 2;
 	req->ki_key = 0;
 	req->ki_ctx = ctx;
@@ -717,6 +717,8 @@ static ssize_t aio_run_iocb(struct kiocb
 	iocb->ki_run_list.next = iocb->ki_run_list.prev = NULL;
 	spin_unlock_irq(&ctx->ctx_lock);
 
+	lock_kiocb(iocb);
+
 	/* Quit retrying if the i/o has been cancelled */
 	if (kiocbIsCancelled(iocb)) {
 		ret = -EINTR;
@@ -781,6 +783,7 @@ out:
 			aio_queue_work(ctx);
 		}
 	}
+	unlock_kiocb(iocb);
 	return ret;
 }
 
@@ -805,9 +808,7 @@ static int __aio_run_iocbs(struct kioctx
 		 * Hold an extra reference while retrying i/o.
 		 */
 		iocb->ki_users++;       /* grab extra reference */
-		lock_kiocb(iocb);
 		aio_run_iocb(iocb);
-		unlock_kiocb(iocb);
 		if (__aio_put_req(ctx, iocb))  /* drop extra ref */
 			put_ioctx(ctx);
  	}
@@ -1549,7 +1550,6 @@ int fastcall io_submit_one(struct kioctx
 
 	spin_lock_irq(&ctx->ctx_lock);
 	aio_run_iocb(req);
-	unlock_kiocb(req);
 	if (!list_empty(&ctx->run_list)) {
 		/* drain the run list */
 		while (__aio_run_iocbs(ctx))

  reply	other threads:[~2005-09-20 19:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-17 18:44 [AIO] aio-2.6.13-rc6-B1 Benjamin LaHaise
2005-08-18 10:02 ` Suparna Bhattacharya
2005-08-17 23:16   ` Benjamin LaHaise
2005-08-18 16:22     ` Suparna Bhattacharya
2005-09-20 10:23 ` Sébastien Dugué
2005-09-20 19:13   ` Benjamin LaHaise [this message]
2005-09-21 11:33     ` Sébastien Dugué

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050920191329.GA6579@linux.intel.com \
    --to=bcrl@linux.intel.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sebastien.dugue@bull.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox