From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 4F84CC433DF for ; Fri, 9 Oct 2020 01:09:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED82922256 for ; Fri, 9 Oct 2020 01:09:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="nbww3YdN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728947AbgJIBJq (ORCPT ); Thu, 8 Oct 2020 21:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726348AbgJIBJq (ORCPT ); Thu, 8 Oct 2020 21:09:46 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC4D1C0613D4 for ; Thu, 8 Oct 2020 18:09:44 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id b193so4908154pga.6 for ; Thu, 08 Oct 2020 18:09:44 -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=xVtaazHLap0AOGbhNnd3svkYUCPJJww/W0XS3nSiO+8=; b=nbww3YdNEubpRBuP77GrOtqtpaNcCVF1sBRT/DemJ9upzP2NEPwxnfX4P7aq51Yckv PpvkynNQZetIrV2l7mvwlppEm5vcY7BOFODRFm3xMAuHE7aE7D+VAyupKzEaIdGvkKVe VbuZC4z3kLeu9S71zb7RvUtcJwo1qLl90Br5t7hjRW8rct62xrLiHFthWhcqW/k/3Hf7 DrLbz2jpVbyUN3RgDBA/0PN3jefNXg/qmLMEPg9LXTaGQssns/Q7xOG0nGP5ZHJfi9W9 7S6v4zys7kI9mekUbJyhzXR5NfAC8lzEM2S+DAvDKOPoSHwxDsZpqeeQQiLvhsuG9siX Auwg== 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=xVtaazHLap0AOGbhNnd3svkYUCPJJww/W0XS3nSiO+8=; b=QuC/EIkZCo+P7zyebXg7gaMeHFsdAkVeeffUzM4vjl/8unQD+lkwRGBulnWMycUd0t +Q0Tilhmf4cglGR+rZCjZ7gYEhHFzlb41vzpF/3EFqma8dbK0AcEi8CV9y2NliJ/In5S VBBIwOIgYQbXvoNlN3BRrOsKVfdIINaxW3ODj6UYsUuH3jIurxXq7xRPgoFpO8ptX6vu +9xphjQgXZ1F+IANQD4QwoqkxarkmcGyNtmWbC6giInRNlMjIAt0W77oECOSlEKc04Pt qb3VEgMYfo3npZ6QWiGvMcF+8KpLIg7vVELvW6PLtdeiANm7Ep3pta54QF36iDO58D3L jxbg== X-Gm-Message-State: AOAM533zhWu4vPQoCt/iAtLLPn5fBSmhSb0m+zS8DnMVP3e2Gf4y9vkV 6DehlpXL5x7tvG2UEpTD/TuW+w== X-Google-Smtp-Source: ABdhPJywAib2tPyDFzjfzXQKUguHRN7peDDzdodPUGsMT4cGw3W1ThU3Wu2Dy09pW/3+4oyv8TaIyA== X-Received: by 2002:a17:90a:3804:: with SMTP id w4mr1710860pjb.171.1602205784152; Thu, 08 Oct 2020 18:09:44 -0700 (PDT) Received: from [192.168.1.134] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id l82sm3984061pfd.102.2020.10.08.18.09.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Oct 2020 18:09:43 -0700 (PDT) Subject: Re: io_uring: process task work in io_uring_register() To: Colin Ian King Cc: Alexander Viro , linux-fsdevel , io-uring@vger.kernel.org, "linux-kernel@vger.kernel.org" References: From: Jens Axboe Message-ID: <781195af-9d58-202f-0451-b36c1705fdc1@kernel.dk> Date: Thu, 8 Oct 2020 19:09:41 -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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On 10/8/20 12:23 PM, Colin Ian King wrote: > Hi, > > Static analysis with Coverity has detected a "dead-code" issue with the > following commit: > > commit af9c1a44f8dee7a958e07977f24ba40e3c770987 > Author: Jens Axboe > Date: Thu Sep 24 13:32:18 2020 -0600 > > io_uring: process task work in io_uring_register() > > The analysis is as follows: > > 9513 do { > 9514 ret = > wait_for_completion_interruptible(&ctx->ref_comp); > > cond_const: Condition ret, taking false branch. Now the value of ret is > equal to 0. > > 9515 if (!ret) > 9516 break; > 9517 if (io_run_task_work_sig() > 0) > 9518 continue; > 9519 } while (1); > 9520 > 9521 mutex_lock(&ctx->uring_lock); > 9522 > > const: At condition ret, the value of ret must be equal to 0. > dead_error_condition: The condition ret cannot be true. Thanks, yeah that condition is reversed, should be: diff --git a/fs/io_uring.c b/fs/io_uring.c index 4df5b14c2e56..80a0aa33db49 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -9511,8 +9511,8 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, ret = wait_for_completion_interruptible(&ctx->ref_comp); if (!ret) break; - if (io_run_task_work_sig() > 0) - continue; + if (io_run_task_work_sig() <= 0) + break; } while (1); mutex_lock(&ctx->uring_lock); -- Jens Axboe