Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp486653pxk; Wed, 9 Sep 2020 10:23:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8w2EBKFtmHdexoY3ndMZyWn+DynSQhS38tNBt+VHvDe/kpllOOHg1T8nX8oxloJMpCZQm X-Received: by 2002:a17:906:d94:: with SMTP id m20mr4954250eji.133.1599672222306; Wed, 09 Sep 2020 10:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599672222; cv=none; d=google.com; s=arc-20160816; b=V6qHuO0v3Thu8oXjlz+n5UuL3to0KUXP65VrN3b3T756Y2HOD/NwWkVUCst9KYlhLG Dt4pdga+XKbqnK05+N+osog+ZGm/Bi16DCF07lNFL7nzK29lsmfq2QT1qcUYlZwdltO4 qe19f5StpKP7j07/5LJ1VDmkVBKypj+ZjR+UEM7o7P1KBow1TTFUbmwTKVQNvfaWJb1d VGdkKyCEbbj+PqsdwxLPdVlWa4JhAlM+0rVgqjjscFhnYOxZpsCmaGZjsvltzv9CQJA1 QIWjEAqBipwXTj6b1lJ6SMv/A4ACMKcZSR14vrJxfM69Tv3eiAOAmq4MiwqXmxnZGp2X o/qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=1GNvQaJVVbJaa5hqastQ4V9UWSsrJ3TzEQOTc6YZGA0=; b=BB4cLfASV8PulVb9bdV5k16dDA6Q0MYKPNydP5+jy2zl7s0RTcNK/DzFdbfwEu0OAi V5IBHQURDLHlj9M+WjiGQ0Ktri5RMzYLq8cdhXlCGMitt4KlGCVY0eq+8tvF0ju4lahV tLwkZqYnLL++wJLEZuoJibFgdplgfy7T6lYEPGIYZWfMwnCqgTUa35KC8Wywj0DgoH4P q8w4xF0jmPRrtkZzQXjZJIc9tnrWi16pE/0Jvs2d3ArjYzuz87aOrH3GrGHhlB77cgt+ V4Eb2TiXTXp1+X+7ugvGepgPaTE8FPdD+MtJbFGIV65dfr40/bOf5Wajcx+mDDUihQos /tWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Wz131WDa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr1si2003524ejb.164.2020.09.09.10.23.19; Wed, 09 Sep 2020 10:23:42 -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=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Wz131WDa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726920AbgIIRUv (ORCPT + 99 others); Wed, 9 Sep 2020 13:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729941AbgIIPZN (ORCPT ); Wed, 9 Sep 2020 11:25:13 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A9E2C061360 for ; Wed, 9 Sep 2020 07:05:36 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id d190so3273372iof.3 for ; Wed, 09 Sep 2020 07:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=1GNvQaJVVbJaa5hqastQ4V9UWSsrJ3TzEQOTc6YZGA0=; b=Wz131WDagK/Rxky/VsKTxm9iJtyF3lZsrhvUt6kH/ULppLy487y62HkZGYeM1pXKOZ DeQ8y3Q16GCVRKCyngWbLjZIjWc72QhidG0e5bcZSKpjLE09P3yHLmATe3Z+FpCFgcTQ W2/C/2AzVGHUu6cHHEPWt6mkn5ZNMcG4xCvMcuGt+NA0M9fQHvWeaRORq0/VJy00UBFW SVuEXZBNl1PaMP21xD5W8PtNgRJ4ghTKDdVbnJzTuhHM+YiLMWOFq46dlbALB9SQ435V /wamSrkHIbLha24honWVVkDwyaCkp0a1caYMHllncnc93uHxavoJRQhw5/gkMF+A5Q2G wUVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1GNvQaJVVbJaa5hqastQ4V9UWSsrJ3TzEQOTc6YZGA0=; b=CnRKdAIYJ2t9qtyQFfwvikkUXYbU1JQq4jxfRQHhdh/sxKbptzLXoZcbea/OnnNLj/ qFlyACwjssFHvpa1IltzjyyXI9fTNeWIJuiLXmGnt4ZtwpO3yhYKgMqLZspWHlbAyVC7 y3MW56gbzpfYKSXnq0MvAixQ0lEy9YgDXzWzf3n276zWlkZC9z+ewHT24ximdN+hxbdN ZEktDRv6fCkbz/oC2SOEbaHrnRPjpiHjCsmD1xDzybBHPdcDc8FwlCEcSfqMDqsU5pq4 WqkcfNDsRnpVHhBB+m3dxBB3Ltzy2x2p05PhIEHHKypv229bmLaf2J9qWJYLkXYnhaG+ JSZA== X-Gm-Message-State: AOAM5300NEKyCkuQzoIICdEySfLbXKhOXNeDy9ZIauXbJC5KByTcvhxM Es8awQDViyApdAoU6k1F6hLhHQ== X-Received: by 2002:a02:cb99:: with SMTP id u25mr3965325jap.99.1599660335262; Wed, 09 Sep 2020 07:05:35 -0700 (PDT) Received: from [192.168.1.10] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id m15sm1464546ild.8.2020.09.09.07.05.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Sep 2020 07:05:34 -0700 (PDT) Subject: Re: INFO: task hung in io_sq_thread_stop To: Hillf Danton , Stefano Garzarella Cc: syzbot , io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Begunkov , syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk References: <00000000000030a45905aedd879d@google.com> <20200909134317.19732-1-hdanton@sina.com> From: Jens Axboe Message-ID: <4d55d988-d45e-ba36-fed7-342e0a6ab16e@kernel.dk> Date: Wed, 9 Sep 2020 08:05:33 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200909134317.19732-1-hdanton@sina.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- Jens Axboe