Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3813439pxm; Tue, 1 Mar 2022 06:02:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPoAglcUHMd+j4dIEccWBafkU7A3RfnXk4I70ZI4bKS1DtOgo/XZODEZn/9cdLoWsCWbxT X-Received: by 2002:a17:902:e884:b0:150:ecbb:d089 with SMTP id w4-20020a170902e88400b00150ecbbd089mr20200642plg.142.1646143322257; Tue, 01 Mar 2022 06:02:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646143322; cv=none; d=google.com; s=arc-20160816; b=QdxPV9RoablLu2cuV6diEdA9qJd0LFDf5fqEqDH33VlkHvlyBTIOioadviC5gh3vt5 y6OLhE8s0MCVjhFdNn7Dh2qv6tl+F6TzT4PEJxYIxyJqaYCUZXWxa79EHQve+4bsWah3 AFNPK+D2OTNoAtyzr1jrERLuofxD17+XBkOsQVoHLyLdDn/AiD5fonwrpZZg+hZr6Waf gO4KXkX1r08CjTVpA43uaXDtZr/X3PXqacJLlCMELr/D2EVdoe2B/5MFZJgY+tHwS0MF kfI2OKi9YsYONK9WMEURVKATuEXk2dXR5GihqMU0gCJoZaX8hRc797nJ6QyqqpcEFTBv Hzvw== 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=ZWBEauztfyD4o50Nrl8/GUFMydbCfk3qyb68NBVgyz8=; b=T/iOKaos1y2WsqCoXZDzDi+LSzbSR5fKuMyW6lfacstcCH4PiXA0DlYipKGVSpIcGL bpordfqTTLEWAiQiToVA/vZH50toeEbgqCBindB2HRu7diNQgaKmvZ2vY93bSerdRY5n 0J6Wb3O/xxPVUNrVmRW07gDWPyn/NHtYliRDZ0+ExLXsT0YatEWNiWWeCpV650GnZrBI YWFxMNVSJU4ePzDKCunGMYMBEdnf0Ilzs7cuqIZxZzVWXuwpl2dBgOLOhsIkMsn8H4R5 MAvqm+S0Pc3a0Glgu3rsqAUvkU8fJ53CiHm3muFGxLVi5QyKJwUVA2Z0G1DwSviTpPVp 86Nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e5-20020a6558c5000000b00374a41b4a51si11853556pgu.291.2022.03.01.06.01.40; Tue, 01 Mar 2022 06:02:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235122AbiCANsK (ORCPT + 99 others); Tue, 1 Mar 2022 08:48:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235094AbiCANsH (ORCPT ); Tue, 1 Mar 2022 08:48:07 -0500 Received: from cloud48395.mywhc.ca (cloud48395.mywhc.ca [173.209.37.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E8C06350; Tue, 1 Mar 2022 05:47:26 -0800 (PST) Received: from [45.44.224.220] (port=56378 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 1nP2qa-0002Gr-Rf; Tue, 01 Mar 2022 08:47:24 -0500 Date: Tue, 01 Mar 2022 08:47:24 -0500 Message-Id: <84513f7cc1b1fb31d8f4cb910aee033391d036b4.1646142288.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 v4 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,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 exectuing 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