Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp39974pxj; Wed, 23 Jun 2021 15:06:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNuevGIxTr9+L6+Ruvuv62sUf6XPwQslvXvO0itxIk2cCLjSqqjXHlqbdZfBhHaMftfQum X-Received: by 2002:a05:6402:1d55:: with SMTP id dz21mr2492730edb.338.1624485991255; Wed, 23 Jun 2021 15:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624485991; cv=none; d=google.com; s=arc-20160816; b=MtCKN8IHOM7YU6vUNJa9dU0sTEGC03Tdfh+iulKNkasAVUx2yn2E8+9ZVUw6qsETmE cuTXPoCRQW/P45xpZfEEFHVAmNc4RFN3aMcjoA10JUn0GaTDStdnsEQdZpbyDLDSmvO2 BSXuZ1mqq2pIE+TElcrK6qDhkJB1V+Li8Vryhvi/011V2L2BLW26HBNVQ8UhoPka5quM HQYFiOZtQ/75lmMGMZrSw8uDF49hUo+WAP/lZWzehYRKUV6oxX4u+cepBTdC4cPyEber GVm+fO+2A2D+Y8lJy2wlXNqLDNQLBp+5pjdjnqXAGJOTS6LNBK7wcVRRQtpWmARTlT65 vI6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=du/+9bci9BS1zxPiO5bZhcvo8DRuSdwuL5QAgI4buTI=; b=vOA8Ws7vql5erfwXAMT0naLXPnT/ZgqrG7ZmGIdInkxisUP5iUcRIOaakNiLO/NxOd WrOcZIWhFKJjBaMs5F5Fm20FRpxz5x+Wfmapp/x8zgWGV5YplZZT0kuDmFg9yRXIe5xq 0IbTxmpncyhscX/MtXECJl+rx8F9D/U22RcERH5N9ryNPKryjUMxbxOLOtgGsHfh8LZZ PwUi/5/TiCiPA7btWa2h6zx4vGtp81pUGpWqtdKR3Spdk2rxVzUgnOAAM8mR+4nLZIF1 Fh/f9JA22UXR7FKZP1RcqLdGWoBXDt+RGJIFcuh2Obm3fmtXSqPMrxvAor01TYvlJSmJ Dwlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pfmCYYJ1; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz19si1082480ejb.272.2021.06.23.15.06.08; Wed, 23 Jun 2021 15:06: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=@gmail.com header.s=20161025 header.b=pfmCYYJ1; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229902AbhFWWE6 (ORCPT + 99 others); Wed, 23 Jun 2021 18:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbhFWWE5 (ORCPT ); Wed, 23 Jun 2021 18:04:57 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D54BC061574; Wed, 23 Jun 2021 15:02:38 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id m18so4303797wrv.2; Wed, 23 Jun 2021 15:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=du/+9bci9BS1zxPiO5bZhcvo8DRuSdwuL5QAgI4buTI=; b=pfmCYYJ18anm5/1Y5MeQ7PEl0yrPZ+ANXlgkmEuViWHPOQlbwj7QNCE4CP6M/BT/Mc Nq9x9eN/BxTxohygov9RWOgv2jp4biRPitzbBku+fVqS0sfklkzDm0alpTOL56LhDh4n wHX6jcc22rDU3ysV1MFYon1IX2N0ooi0hpn5+0TzUzzQbDN/3ggg2fCiT2s/fGrjKud3 2MG4kP/m9e3iosFP+hAeJzvYPLv/LZ+DaENihkt/RbHaiodt7aeQWOdm2CgeQhZbWRwm o6gL57ordpwIqrwVLkJuUfgh1fqQcMg1Y+Fb8KxPWrSL8vdand5xAkglqmAeAgX+K1df oSEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=du/+9bci9BS1zxPiO5bZhcvo8DRuSdwuL5QAgI4buTI=; b=hiktt6zwfDXIyXRDgVedW3Y2+WFUBOwGq1/vSihTP8kwM/Uqc+2SXRSjHi73aI499C nyQmlpJbPrTlGo8CDQSuQGkmF5PU6qUqnduyicUVk0rbwWgnEahrGA+r6PqzbWtgNO3w SpQuMPAdfwUVOHBxFSY+l1FeJsKONsRDc5txJl68H8R27REq5nVBxxg3yStl/hxSi7+5 5J/HURvUzEZwb3vCav7L1y5kCNk+6s3lptQ6e5Z4ZPdWQ3XkIe45IHfC2fyelxrbFIt2 34hZ8euA1Yq7lm/PymgOMQ++ith/ycrmEFgbTbVaSkW2NAY04qLq92V+ULNncjWWb1/L 6D5Q== X-Gm-Message-State: AOAM532Lvg+zdDbzNQBszTIFTtCbbJuMIKTynjpY5qd9R5tiWZm+1w6H BLj3DL6KEDhKZMPlK8b2za0AljnzX09WeeDj X-Received: by 2002:a5d:45c5:: with SMTP id b5mr316612wrs.221.1624485756956; Wed, 23 Jun 2021 15:02:36 -0700 (PDT) Received: from [192.168.8.197] ([148.252.132.93]) by smtp.gmail.com with ESMTPSA id p20sm1028853wma.19.2021.06.23.15.02.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Jun 2021 15:02:36 -0700 (PDT) Subject: Re: [PATCH v2 1/2] io_uring: Fix race condition when sqp thread goes to sleep To: Olivier Langlois , Jens Axboe , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Pavel Begunkov Message-ID: <876d12ba-b71c-ba49-342e-6ad59b8dea15@gmail.com> Date: Wed, 23 Jun 2021 23:02:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/23/21 7:50 PM, Olivier Langlois wrote: > If an asynchronous completion happens before the task is preparing > itself to wait and set its state to TASK_INTERRUPTIBLE, the completion > will not wake up the sqp thread. Looks good, the bug should be pretty old. Cc: stable@vger.kernel.org Reviewed-by: Pavel Begunkov > Signed-off-by: Olivier Langlois > --- > fs/io_uring.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/io_uring.c b/fs/io_uring.c > index fc8637f591a6..7c545fa66f31 100644 > --- a/fs/io_uring.c > +++ b/fs/io_uring.c > @@ -6902,7 +6902,7 @@ static int io_sq_thread(void *data) > } > > prepare_to_wait(&sqd->wait, &wait, TASK_INTERRUPTIBLE); > - if (!io_sqd_events_pending(sqd)) { > + if (!io_sqd_events_pending(sqd) && !io_run_task_work()) { > needs_sched = true; > list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) { > io_ring_set_wakeup_flag(ctx); > -- Pavel Begunkov