From: Eric Dumazet <dada1@cosmosbay.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jeff Moyer <jmoyer@redhat.com>, Avi Kivity <avi@redhat.com>,
linux-aio <linux-aio@kvack.org>,
zach.brown@oracle.com, bcrl@kvack.org,
linux-kernel@vger.kernel.org,
Davide Libenzi <davidel@xmailserver.org>,
Christoph Lameter <cl@linux-foundation.org>
Subject: [PATCH] aio: fput() can be called from interrupt context
Date: Thu, 12 Mar 2009 06:42:17 +0100 [thread overview]
Message-ID: <49B8A0B9.2060602@cosmosbay.com> (raw)
In-Reply-To: <49B89B22.7080303@cosmosbay.com>
Eric Dumazet a écrit :
>> Path could be :
>>
>> 1) fput() changes so that calling it from interrupt context is possible
>> (Using a working queue to make sure __fput() is called from process context)
>>
>> 2) Changes aio to use fput() as is (and zap its internal work_queue and aio_fput_routine() stuff)
>>
>> 3) Once atomic_long_dec_and_test(&filp->f_count) only performed in fput(),
>> SLAB_DESTROY_BY_RCU for "struct file" get back :)
>>
Here is the second patch
Thank you
[PATCH] aio: cleanup, since fput() is IRQ safe
Once fput() is IRQ safe, we can cleanup aio code and delete its work_queue.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
---
fs/aio.c | 52 ++--------------------------------------------------
1 files changed, 2 insertions(+), 50 deletions(-)
diff --git a/fs/aio.c b/fs/aio.c
index 8fa77e2..b0351a1 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -53,13 +53,6 @@ static struct kmem_cache *kioctx_cachep;
static struct workqueue_struct *aio_wq;
-/* Used for rare fput completion. */
-static void aio_fput_routine(struct work_struct *);
-static DECLARE_WORK(fput_work, aio_fput_routine);
-
-static DEFINE_SPINLOCK(fput_lock);
-static LIST_HEAD(fput_head);
-
static void aio_kick_handler(struct work_struct *);
static void aio_queue_work(struct kioctx *);
@@ -469,15 +462,7 @@ static struct kiocb *__aio_get_req(struct kioctx *ctx)
static inline struct kiocb *aio_get_req(struct kioctx *ctx)
{
struct kiocb *req;
- /* Handle a potential starvation case -- should be exceedingly rare as
- * requests will be stuck on fput_head only if the aio_fput_routine is
- * delayed and the requests were the last user of the struct file.
- */
req = __aio_get_req(ctx);
- if (unlikely(NULL == req)) {
- aio_fput_routine(NULL);
- req = __aio_get_req(ctx);
- }
return req;
}
@@ -498,30 +483,6 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)
wake_up(&ctx->wait);
}
-static void aio_fput_routine(struct work_struct *data)
-{
- spin_lock_irq(&fput_lock);
- while (likely(!list_empty(&fput_head))) {
- struct kiocb *req = list_kiocb(fput_head.next);
- struct kioctx *ctx = req->ki_ctx;
-
- list_del(&req->ki_list);
- spin_unlock_irq(&fput_lock);
-
- /* Complete the fput */
- __fput(req->ki_filp);
-
- /* Link the iocb into the context's free list */
- spin_lock_irq(&ctx->ctx_lock);
- really_put_req(ctx, req);
- spin_unlock_irq(&ctx->ctx_lock);
-
- put_ioctx(ctx);
- spin_lock_irq(&fput_lock);
- }
- spin_unlock_irq(&fput_lock);
-}
-
/* __aio_put_req
* Returns true if this put was the last user of the request.
*/
@@ -540,17 +501,8 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
req->ki_cancel = NULL;
req->ki_retry = NULL;
- /* Must be done under the lock to serialise against cancellation.
- * Call this aio_fput as it duplicates fput via the fput_work.
- */
- if (unlikely(atomic_long_dec_and_test(&req->ki_filp->f_count))) {
- get_ioctx(ctx);
- spin_lock(&fput_lock);
- list_add(&req->ki_list, &fput_head);
- spin_unlock(&fput_lock);
- queue_work(aio_wq, &fput_work);
- } else
- really_put_req(ctx, req);
+ fput(req->ki_filp);
+ really_put_req(ctx, req);
return 1;
}
next prev parent reply other threads:[~2009-03-12 5:44 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-09 15:49 [patch] aio: remove aio-max-nr and instead use the memlock rlimit to limit the number of pages pinned for the aio completion ring Jeff Moyer
2009-03-09 15:54 ` [patch] factor out checks against the memlock rlimit Jeff Moyer
2009-03-09 15:59 ` [patch] man-pages: add documentation about the memlock implications of io_setup Jeff Moyer
2009-03-09 16:45 ` Michael Kerrisk
2009-03-09 16:48 ` Michael Kerrisk
2009-03-09 20:44 ` Jeff Moyer
2009-03-09 16:18 ` [patch] aio: remove aio-max-nr and instead use the memlock rlimit to limit the number of pages pinned for the aio completion ring Avi Kivity
2009-03-09 17:57 ` Jeff Moyer
2009-03-09 19:45 ` Avi Kivity
2009-03-09 20:36 ` Jamie Lokier
2009-03-10 8:36 ` Avi Kivity
2009-03-09 20:31 ` Eric Dumazet
2009-03-12 2:39 ` Eric Dumazet
2009-03-12 2:44 ` Benjamin LaHaise
2009-03-12 3:24 ` Eric Dumazet
2009-03-12 3:29 ` Benjamin LaHaise
2009-03-12 3:33 ` Eric Dumazet
2009-03-12 3:36 ` Benjamin LaHaise
2009-03-12 3:40 ` Eric Dumazet
2009-03-12 3:09 ` Eric Dumazet
2009-03-12 5:18 ` [PATCH] fs: fput() can be called from interrupt context Eric Dumazet
2009-03-12 5:42 ` Eric Dumazet [this message]
2009-03-12 5:47 ` Andrew Morton
2009-03-12 6:10 ` Eric Dumazet
2009-03-12 6:39 ` Andrew Morton
2009-03-12 13:39 ` Davide Libenzi
2009-03-13 22:34 ` Davide Libenzi
2009-03-13 22:43 ` Eric Dumazet
2009-03-13 23:28 ` Trond Myklebust
2009-03-14 1:40 ` Davide Libenzi
2009-03-14 4:02 ` Trond Myklebust
2009-03-14 14:32 ` Davide Libenzi
2009-03-15 1:36 ` [patch] eventfd - remove fput() call from possible IRQ context Davide Libenzi
2009-03-15 17:44 ` Benjamin LaHaise
2009-03-15 20:08 ` [patch] eventfd - remove fput() call from possible IRQ context (2nd rev) Davide Libenzi
2009-03-16 17:25 ` Jamie Lokier
2009-03-16 18:36 ` Davide Libenzi
2009-03-18 14:22 ` Jeff Moyer
2009-03-18 14:46 ` Davide Libenzi
2009-03-18 14:55 ` Eric Dumazet
2009-03-18 15:25 ` Jeff Moyer
2009-03-18 15:43 ` Eric Dumazet
2009-03-18 16:13 ` Jeff Moyer
2009-03-18 17:25 ` [patch] eventfd - remove fput() call from possible IRQ context (3rd rev) Davide Libenzi
2009-03-18 17:34 ` Jeff Moyer
2009-03-12 19:22 ` [PATCH] fs: fput() can be called from interrupt context Eric Dumazet
2009-03-12 20:21 ` Andrew Morton
2009-03-09 22:36 ` [patch] aio: remove aio-max-nr and instead use the memlock rlimit to limit the number of pages pinned for the aio completion ring Andrew Morton
2009-03-10 13:43 ` Jeff Moyer
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=49B8A0B9.2060602@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=bcrl@kvack.org \
--cc=cl@linux-foundation.org \
--cc=davidel@xmailserver.org \
--cc=jmoyer@redhat.com \
--cc=linux-aio@kvack.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zach.brown@oracle.com \
/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