Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CABFC282D7 for ; Wed, 6 Feb 2019 13:48:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 644C12175B for ; Wed, 6 Feb 2019 13:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729656AbfBFNsA (ORCPT ); Wed, 6 Feb 2019 08:48:00 -0500 Received: from verein.lst.de ([213.95.11.211]:59777 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727179AbfBFNsA (ORCPT ); Wed, 6 Feb 2019 08:48:00 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id 88C7068DD3; Wed, 6 Feb 2019 14:47:58 +0100 (CET) Date: Wed, 6 Feb 2019 14:47:58 +0100 From: Christoph Hellwig To: Miklos Szeredi Cc: Bart Van Assche , Christoph Hellwig , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-aio , syzbot , Avi Kivity , Eric Dumazet , stable Subject: Re: [PATCH] aio: Fix locking in aio_poll() Message-ID: <20190206134758.GB29185@lst.de> References: <20190204174555.83603-1-bvanassche@acm.org> <20190204174900.GA16229@lst.de> <1549414384.34241.77.camel@acm.org> <20190206083626.GA19821@veci.piliscsaba.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190206083626.GA19821@veci.piliscsaba.redhat.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Feb 06, 2019 at 09:36:26AM +0100, Miklos Szeredi wrote: > Yep. And is AIO doing anything in irq context? If so, why? Because all waitqueues can be woken, and often are woken from irq context. > > Would it make sense to just disable AIO on file descriptors where it makes zero > sense? using aio poll makes sense on every fd, just like you can use epoll or the upcoming io_uring poll on every fd. Just use the waitqueue API properly in fuse and we are done: diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index a5e516a40e7a..1c693bb6339a 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -387,7 +387,7 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, forget->forget_one.nodeid = nodeid; forget->forget_one.nlookup = nlookup; - spin_lock(&fiq->waitq.lock); + spin_lock_irq(&fiq->waitq.lock); if (fiq->connected) { fiq->forget_list_tail->next = forget; fiq->forget_list_tail = forget; @@ -396,7 +396,7 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, } else { kfree(forget); } - spin_unlock(&fiq->waitq.lock); + spin_unlock_irq(&fiq->waitq.lock); } static void flush_bg_queue(struct fuse_conn *fc) @@ -410,10 +410,10 @@ static void flush_bg_queue(struct fuse_conn *fc) req = list_first_entry(&fc->bg_queue, struct fuse_req, list); list_del(&req->list); fc->active_background++; - spin_lock(&fiq->waitq.lock); + spin_lock_irq(&fiq->waitq.lock); req->in.h.unique = fuse_get_unique(fiq); queue_request(fiq, req); - spin_unlock(&fiq->waitq.lock); + spin_unlock_irq(&fiq->waitq.lock); } } @@ -472,7 +472,7 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) static void queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req) { - spin_lock(&fiq->waitq.lock); + spin_lock_irq(&fiq->waitq.lock); if (test_bit(FR_FINISHED, &req->flags)) { spin_unlock(&fiq->waitq.lock); return; @@ -481,7 +481,7 @@ static void queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req) list_add_tail(&req->intr_entry, &fiq->interrupts); wake_up_locked(&fiq->waitq); } - spin_unlock(&fiq->waitq.lock); + spin_unlock_irq(&fiq->waitq.lock); kill_fasync(&fiq->fasync, SIGIO, POLL_IN); } @@ -535,9 +535,9 @@ static void __fuse_request_send(struct fuse_conn *fc, struct fuse_req *req) struct fuse_iqueue *fiq = &fc->iq; BUG_ON(test_bit(FR_BACKGROUND, &req->flags)); - spin_lock(&fiq->waitq.lock); + spin_lock_irq(&fiq->waitq.lock); if (!fiq->connected) { - spin_unlock(&fiq->waitq.lock); + spin_unlock_irq(&fiq->waitq.lock); req->out.h.error = -ENOTCONN; } else { req->in.h.unique = fuse_get_unique(fiq); @@ -545,7 +545,7 @@ static void __fuse_request_send(struct fuse_conn *fc, struct fuse_req *req) /* acquire extra reference, since request is still needed after request_end() */ __fuse_get_request(req); - spin_unlock(&fiq->waitq.lock); + spin_unlock_irq(&fiq->waitq.lock); request_wait_answer(fc, req); /* Pairs with smp_wmb() in request_end() */ @@ -676,12 +676,12 @@ static int fuse_request_send_notify_reply(struct fuse_conn *fc, __clear_bit(FR_ISREPLY, &req->flags); req->in.h.unique = unique; - spin_lock(&fiq->waitq.lock); + spin_lock_irq(&fiq->waitq.lock); if (fiq->connected) { queue_request(fiq, req); err = 0; } - spin_unlock(&fiq->waitq.lock); + spin_unlock_irq(&fiq->waitq.lock); return err; }