Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3546274pxp; Tue, 8 Mar 2022 17:07:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLVUjuuoxSWgPpNwVfJaTnBK2H35PbAk+vSMkJugDx7Zj5NrXuTZfeegOfyKySQboklUWz X-Received: by 2002:a05:6a00:1312:b0:4e1:58c4:ddfd with SMTP id j18-20020a056a00131200b004e158c4ddfdmr21340490pfu.65.1646788054625; Tue, 08 Mar 2022 17:07:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646788054; cv=none; d=google.com; s=arc-20160816; b=BRh06r2wS92RPZVuI8sthezrHWwJeIJLNuV89IornHhrzp7Tmwndrdr+J60pdCSEyk n4alLpkXlyTEPHGKEQjzi0KAeN39vE2irk1rOjxWPey8m9pkYLodF6PJYinnrkruXyFb UhycaE/s6dsxy6c8A+nu6Ck/IK4rLce/lRmd2KArBQTZhGO2AuQlAKDhHcGox+3dc8ua psYPhKDHWmMt8KuK4Y91zOxftRHlScJS4Kzt/rAWKaoerrGQxnYbGrmWKQ+Z7bOHUUMp dyLJ4lfphnI/D5CZbtO7Sf4DAhJeNU3+1EYvTyrsTIwBPTyr/Y77de10UGO7bmFUVCBo 0Law== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:references:in-reply-to :message-id:date; bh=/hmkpXlNrvzwcKk0PTfQ0/vkENIVTrR4OKVtxzmsx+o=; b=panjtOQD0S3dakozPCPTHDMt+1at/FWGYCaVjoP8omL2ASM8H/Z9k6yvP1t7+2drtI JvKNZ6YrfjYAV07SbvtDAJqq7J2H0pReao8tCLdpfhwOfLXbf5hfThrz3I5OqAWkup17 QwDHotDqVHNcUnHqafLHfJpbOClvxx0T72DrguBMJNYRSL5YRIo7/oJwW0qdVOoKrVQp hKajPCWRGyBHOKbh0vSeyO4Dmxe6Ep/IfNwUT0D+/pVCQqotypy8Hh1CWLMEHr5tQ9qg oHr5HDsGLnF7Rc12LB3tNzwUkQQYusQr6YDWwRW9bV2rKIvseUvq3dOpQNecKkSYhCB2 5djg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n5-20020a170903110500b0014f9a7c7ce0si495868plh.307.2022.03.08.17.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 17:07:34 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E312617BC75; Tue, 8 Mar 2022 16:12:37 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350713AbiCHWSb (ORCPT + 99 others); Tue, 8 Mar 2022 17:18:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350945AbiCHWSU (ORCPT ); Tue, 8 Mar 2022 17:18:20 -0500 Received: from cloud48395.mywhc.ca (cloud48395.mywhc.ca [173.209.37.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 773035749F; Tue, 8 Mar 2022 14:17:23 -0800 (PST) Received: from [45.44.224.220] (port=42888 helo=localhost) by cloud48395.mywhc.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nRi8w-0000Sr-6k; Tue, 08 Mar 2022 17:17:22 -0500 Date: Tue, 08 Mar 2022 17:17:21 -0500 Message-Id: <84513f7cc1b1fb31d8f4cb910aee033391d036b4.1646777484.git.olivier@trillion01.com> In-Reply-To: References: From: Olivier Langlois To: Jens Axboe , Pavel Begunkov Cc: Hao Xu , io-uring , linux-kernel Subject: [PATCH v5 1/2] io_uring: minor io_cqring_wait() optimization X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud48395.mywhc.ca X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - trillion01.com X-Get-Message-Sender-Via: cloud48395.mywhc.ca: authenticated_id: olivier@trillion01.com X-Authenticated-Sender: cloud48395.mywhc.ca: olivier@trillion01.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move up the block manipulating the sig variable to execute code that may encounter an error and exit first before continuing executing the rest of the function and avoid useless computations Signed-off-by: Olivier Langlois --- fs/io_uring.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 4715980e9015..f7b8df79a02b 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7732,14 +7732,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, break; } while (1); - if (uts) { - struct timespec64 ts; - - if (get_timespec64(&ts, uts)) - return -EFAULT; - timeout = ktime_add_ns(timespec64_to_ktime(ts), ktime_get_ns()); - } - if (sig) { #ifdef CONFIG_COMPAT if (in_compat_syscall()) @@ -7753,6 +7745,14 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, return ret; } + if (uts) { + struct timespec64 ts; + + if (get_timespec64(&ts, uts)) + return -EFAULT; + timeout = ktime_add_ns(timespec64_to_ktime(ts), ktime_get_ns()); + } + init_waitqueue_func_entry(&iowq.wq, io_wake_function); iowq.wq.private = current; INIT_LIST_HEAD(&iowq.wq.entry); -- 2.35.1