Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1139354pxx; Fri, 30 Oct 2020 03:08:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0po2uzrXsuIT644M8nJ9HQTJGRlc+vLhGBYz1ATTPcg6zLBJ2EPj5RUsM1mCxlsn4kUSc X-Received: by 2002:a17:906:7844:: with SMTP id p4mr1646942ejm.26.1604052511181; Fri, 30 Oct 2020 03:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604052511; cv=none; d=google.com; s=arc-20160816; b=AoyjDgDjUcql0qCUeo32l8XDEeRdBbIxTucul1olAXCAgvKozplxBlCyLUAswTizoq YwEJ/ke08mAMIgnNn/JPl+AYMKjFU60wDfknaFB44ZHpsm/kwC5aq/p979C8f/IcYLvR milRhb2kZc8XkLwEPKBc97UtXpgegX9CoBKs2pm8hWvVgavRJ3yvBbkFj5eknM7Hb42E O2ZVRrT8mQiDixYVbwG+unZ0crI7xAruISXM447d4cBawijYODjwj7SPfWTsXKIMPXff r5AEacaXluzIPoGbwn/qppX7oawQPuiA+6I6EhTyz/NK45lGfVJ+ATY8SgWnELmEix7k 3PAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tELbhXfQariElQPBOqAGKxNGlZL8E/ZXdebHFJy/Swk=; b=kZ1BJYISbG6ROlbeI3j8j5UWYKWKx15yO4KYDWXSX7PDB1xTTgy2eHTam0S8sHUWkE yWop4nfSxqtHPQFSLyEqIlQWf35UUEeRPEM+1NJy4gAvi6AnvCmhICzakC9YFfzLNzPM 9tnOjSf94pg1rOFDrxX6UVAXZIdiicIV9xxl7NikO9Cti7ESSiRcdI4KrTVndwZvqMO3 GcL0Y33gdtCATUc1Uzk/J9ZAL+kbcbwxSOKuddwe7mov3eQZD7oxxVPIt3CtY9rIyDoQ oMwu1NrQdQDjB7Pe/bdulHxozsr9WAw8cI5223Uff2QyzIfgXLbGXouRmrqT7u26stZ8 fJ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dELZIPti; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly1si3825516ejb.288.2020.10.30.03.08.07; Fri, 30 Oct 2020 03:08:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dELZIPti; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbgJ3KGn (ORCPT + 99 others); Fri, 30 Oct 2020 06:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbgJ3KGn (ORCPT ); Fri, 30 Oct 2020 06:06:43 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DAB9C0613D4 for ; Fri, 30 Oct 2020 03:06:43 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id q1so402106qvn.5 for ; Fri, 30 Oct 2020 03:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tELbhXfQariElQPBOqAGKxNGlZL8E/ZXdebHFJy/Swk=; b=dELZIPtiqtXpHQ7fjyuo6GNNLMPs9DWb1SMjCY5eGwM76MPPy2eDyZ83N4PcOAIdw4 azxWdm/nMgQB+vwbL7e+vM6rC8RxvpnG8J0HI2DVrPTRokppZTH1IRHAaNNtdbJ4e0fl QTjg0w+zCa3J9iS69rMs9evPg5HihkvUxD4Gjqi5UdZzKfYHq3qWqGxmzlkLTAmQ4yO8 2/lSCoVhAhMykIiGXz2yfbE0KeBjUBSU/4mPnf76/PzSPtX3LigZ4+mYrLTFUNo2W1sY huVfAUajc8PLsdlzL+Zec2BKncYiE/5Gp8Um1ls03omFXuz23v8lQvEhHYlf5mRRJTI6 B9Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tELbhXfQariElQPBOqAGKxNGlZL8E/ZXdebHFJy/Swk=; b=r2+Hyk0BxNkCgN1GikT+OkG9s9xdiuLdq7mDPjTGckVyG/x5CAGTXv49FH6J5F7rDx +/HTBs4+HGGyUHJaBl5EQ1BZqLmuFmWSkDAtO8ecpp58kN3cCMBQR4ueVihjV/8kljwB wuMNd/QzfqBIgS5rQrUM4gqIvBe23YGDTXFIKt671uKG2adJF2jFUyNwF8nqCOGu/8hk cnKLOk9oKaubcS9MqWALPWguxrwCCyU/XFIA/WhPjmgGWmYlygh9+q/F2IltutqeqK98 JI/in7OvqzzxRTcPB1eSVJ10NgiQOp9egz7NOCxBS8raMp+7gs1KI6gMMTZiQ3kSLsUU 2fuw== X-Gm-Message-State: AOAM53359/Y/+8Q4jsxrlTdioBFDJbrvzg6oOFaPs2kDaVibfFjXpBo3 iVlzvKWSIvwR8JmYeBgiOBHaPUJwqoFidqsr5Oe+XQ== X-Received: by 2002:ad4:414d:: with SMTP id z13mr8680267qvp.37.1604052402013; Fri, 30 Oct 2020 03:06:42 -0700 (PDT) MIME-Version: 1.0 References: <00000000000030a45905aedd879d@google.com> <20200909134317.19732-1-hdanton@sina.com> <4d55d988-d45e-ba36-fed7-342e0a6ab16e@kernel.dk> <20200909153235.joqj6hjyxug3wtwv@steredhat> In-Reply-To: <20200909153235.joqj6hjyxug3wtwv@steredhat> From: Dmitry Vyukov Date: Fri, 30 Oct 2020 11:06:30 +0100 Message-ID: Subject: Re: INFO: task hung in io_sq_thread_stop To: Stefano Garzarella Cc: Jens Axboe , Hillf Danton , syzbot , io-uring@vger.kernel.org, linux-fsdevel , LKML , Pavel Begunkov , syzkaller-bugs , Al Viro Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 9, 2020 at 5:32 PM Stefano Garzarella wrote: > > On Wed, Sep 09, 2020 at 08:05:33AM -0600, Jens Axboe wrote: > > On 9/9/20 7:43 AM, Hillf Danton wrote: > > > > > > On Wed, 9 Sep 2020 12:03:55 +0200 Stefano Garzarella wrote: > > >> On Wed, Sep 09, 2020 at 01:49:22AM -0700, syzbot wrote: > > >>> Hello, > > >>> > > >>> syzbot found the following issue on: > > >>> > > >>> HEAD commit: dff9f829 Add linux-next specific files for 20200908 > > >>> git tree: linux-next > > >>> console output: https://syzkaller.appspot.com/x/log.txt?x=112f880d900000 > > >>> kernel config: https://syzkaller.appspot.com/x/.config?x=37b3426c77bda44c > > >>> dashboard link: https://syzkaller.appspot.com/bug?extid=3c23789ea938faaef049 > > >>> compiler: gcc (GCC) 10.1.0-syz 20200507 > > >>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17c082a5900000 > > >>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1474f5f9900000 > > >>> > > >>> Bisection is inconclusive: the first bad commit could be any of: > > >>> > > >>> d730b1a2 io_uring: add IOURING_REGISTER_RESTRICTIONS opcode > > >>> 7ec3d1dd io_uring: allow disabling rings during the creation > > >> > > >> I'm not sure it is related, but while rebasing I forgot to update the > > >> right label in the error path. > > >> > > >> Since the check of ring state is after the increase of ctx refcount, we > > >> need to decrease it jumping to 'out' label instead of 'out_fput': > > > > > > I think we need to fix 6a7bb9ff5744 ("io_uring: remove need for > > > sqd->ctx_lock in io_sq_thread()") because the syzbot report > > > indicates the io_sq_thread has to wake up the kworker before > > > scheduling, and in turn the kworker has the chance to unpark it. > > > > > > Below is the minimum walkaround I can have because it can't > > > ensure the parker will be waken in every case. > > > > > > --- a/fs/io_uring.c > > > +++ b/fs/io_uring.c > > > @@ -6834,6 +6834,10 @@ static int io_sq_thread(void *data) > > > io_sq_thread_drop_mm(); > > > } > > > > > > + if (kthread_should_park()) { > > > + /* wake up parker before scheduling */ > > > + continue; > > > + } > > > if (ret & SQT_SPIN) { > > > io_run_task_work(); > > > cond_resched(); > > > > > > > I think this should go in the slow path: > > > > > > diff --git a/fs/io_uring.c b/fs/io_uring.c > > index 652cc53432d4..1c4fa2a0fd82 100644 > > --- a/fs/io_uring.c > > +++ b/fs/io_uring.c > > @@ -6839,6 +6839,8 @@ static int io_sq_thread(void *data) > > } else if (ret == SQT_IDLE) { > > list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) > > io_ring_set_wakeup_flag(ctx); > > + if (kthread_should_park()) > > + continue; > > schedule(); > > start_jiffies = jiffies; > > } > > > > Yes, I agree since only in this case the kthread is not rescheduled. > > Thanks both for the fix :-) > Feel free to add my R-b: > > Reviewed-by: Stefano Garzarella What happened with this fix? The bug is marked as fixed with commit "io_uring: don't sleep schedule in SQPOLL thread if we need to park": https://syzkaller.appspot.com/bug?id=d0cf0b29fc5520a8987b28f1a7b63264ae02535e But such commit cannot be found in any tree.