Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp803242pxb; Fri, 22 Apr 2022 11:28:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj7zHJoTw9Oh/VeS4OuXA4saoF8PkT/EGV+YBPyvaSC0q06Lg1+PI/MBq5IsnnW8uR2aGY X-Received: by 2002:a17:902:aa85:b0:155:ceb9:3710 with SMTP id d5-20020a170902aa8500b00155ceb93710mr5829884plr.59.1650652096896; Fri, 22 Apr 2022 11:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650652096; cv=none; d=google.com; s=arc-20160816; b=1D6MEsqHbSJFficsLV1ICFVNpm0ktVsEn2Fl5PAgay7ZLGcPcfZymXdx0oQe6FsDX0 51apW6jF2+L4RL6MDfu6RVIWyKEHut7K+vlBFvz3uz5kyEVIHOV7dx4Ayi746yg1O6Ry EVe28IXVS5j9BSW5emNpkvYgIt0ewUaR/LmBSEDLqz7Iv0fMiC5OvMCmZnj38EPFEeUa GnTswr19fT4COCfyBCMpne1cj3mb9P3wn/yt1CgxzTpkgarK5IPW40e4KpTatg3uq2vg dMQ/SZZasMZmpOiOht3nuq5d+RrrtWTA2a7z1qd1hehChGISVAyD5n9wg9PFLJ+UVLkX PlZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OvpskX5wjD7culEON5XL98GA5r5k8R6m/m81IDYjyjQ=; b=HPZSD2BNA2iUXYqwrCbSQHQX7XjadnFeZYzssaOnzokN1K9/E7oqhklZD1PS1yssC8 A+Lgqqnz1Etd/YzHuHNSPvWpGQQPhfJsBrKfiPMFJe8xCV3VQs0GXvlKi86jcTrplOLn b3AdByTuZXfOnV4J73nmofEIQHFJKIaboQcHio8kJjvC55r0B2ek5uaP4hW8kOAGVUw+ 1L4tBy7se91MvOJyRG3bw8DMbNHlGi89RvkEIPV0lrr3x5/cHGw33yO2Mq5LubLM8hsd bhEgRdxcMxlJwd7AN94nuiY6ld5PFy9jmBaKzSvU1JOWp5Ikp25kZwqKrLFFZvs4KNwZ MhfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b="NT/b0dr9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d1-20020a636801000000b003aa89c761acsi6524104pgc.798.2022.04.22.11.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:28:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b="NT/b0dr9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A4774F3E61; Fri, 22 Apr 2022 10:57:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387454AbiDUJT6 (ORCPT + 99 others); Thu, 21 Apr 2022 05:19:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387542AbiDUJTt (ORCPT ); Thu, 21 Apr 2022 05:19:49 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1645220C4 for ; Thu, 21 Apr 2022 02:16:59 -0700 (PDT) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.1.2/8.16.1.2) with ESMTP id 23L7Ai08007753 for ; Thu, 21 Apr 2022 02:16:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=OvpskX5wjD7culEON5XL98GA5r5k8R6m/m81IDYjyjQ=; b=NT/b0dr9o2DbaGRdOCamlPlQidzL9kWJUAJavXx5s/MN1DSTiWs4WVcCoSZJDSsZEd/v 4WFYyfX7eSp4EjGkGalTRRifctCpItLVQrtRMCbYoMISlhL+LXU50yFMvhhlIcKqp7xo YxhsEnOS/rtiBRr/donuuYLWxNLhgRh/Ul4= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net (PPS) with ESMTPS id 3fj7k3hetb-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Apr 2022 02:16:58 -0700 Received: from twshared6486.05.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 21 Apr 2022 02:16:57 -0700 Received: by devbig039.lla1.facebook.com (Postfix, from userid 572232) id EFD7B7CA75FE; Thu, 21 Apr 2022 02:14:01 -0700 (PDT) From: Dylan Yudaken To: CC: , , , , Dylan Yudaken Subject: [PATCH 3/6] io_uring: rework io_uring_enter to simplify return value Date: Thu, 21 Apr 2022 02:13:42 -0700 Message-ID: <20220421091345.2115755-4-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220421091345.2115755-1-dylany@fb.com> References: <20220421091345.2115755-1-dylany@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: ArglgWF-VBNlUexkYoiazy8Gw0MXgf0S X-Proofpoint-GUID: ArglgWF-VBNlUexkYoiazy8Gw0MXgf0S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-20_06,2022-04-20_01,2022-02-23_01 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 io_uring_enter returns the count submitted preferrably over an error code. In some code paths this check is not required, so reorganise the code so that the check is only done as needed. This is also a prep for returning error codes only in waiting scenarios. Signed-off-by: Dylan Yudaken --- fs/io_uring.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index d654faffa486..1837b3afa47f 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -10843,7 +10843,6 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd,= u32, to_submit, size_t, argsz) { struct io_ring_ctx *ctx; - int submitted =3D 0; struct fd f; long ret; =20 @@ -10906,15 +10905,15 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, f= d, u32, to_submit, if (ret) goto out; } - submitted =3D to_submit; + ret =3D to_submit; } else if (to_submit) { ret =3D io_uring_add_tctx_node(ctx); if (unlikely(ret)) goto out; =20 mutex_lock(&ctx->uring_lock); - submitted =3D io_submit_sqes(ctx, to_submit); - if (submitted !=3D to_submit) { + ret =3D io_submit_sqes(ctx, to_submit); + if (ret !=3D to_submit) { mutex_unlock(&ctx->uring_lock); goto out; } @@ -10923,6 +10922,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd,= u32, to_submit, mutex_unlock(&ctx->uring_lock); } if (flags & IORING_ENTER_GETEVENTS) { + int ret2; if (ctx->syscall_iopoll) { /* * We disallow the app entering submit/complete with @@ -10932,22 +10932,29 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, f= d, u32, to_submit, */ mutex_lock(&ctx->uring_lock); iopoll_locked: - ret =3D io_validate_ext_arg(flags, argp, argsz); - if (likely(!ret)) { - min_complete =3D min(min_complete, ctx->cq_entries); - ret =3D io_iopoll_check(ctx, min_complete); + ret2 =3D io_validate_ext_arg(flags, argp, argsz); + if (likely(!ret2)) { + min_complete =3D min(min_complete, + ctx->cq_entries); + ret2 =3D io_iopoll_check(ctx, min_complete); } mutex_unlock(&ctx->uring_lock); } else { const sigset_t __user *sig; struct __kernel_timespec __user *ts; =20 - ret =3D io_get_ext_arg(flags, argp, &argsz, &ts, &sig); - if (unlikely(ret)) - goto out; - min_complete =3D min(min_complete, ctx->cq_entries); - ret =3D io_cqring_wait(ctx, min_complete, sig, argsz, ts); + ret2 =3D io_get_ext_arg(flags, argp, &argsz, &ts, &sig); + if (likely(!ret2)) { + min_complete =3D min(min_complete, + ctx->cq_entries); + ret2 =3D io_cqring_wait(ctx, min_complete, sig, + argsz, ts); + } } + + if (!ret) + ret =3D ret2; + } =20 out: @@ -10955,7 +10962,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd,= u32, to_submit, out_fput: if (!(flags & IORING_ENTER_REGISTERED_RING)) fdput(f); - return submitted ? submitted : ret; + return ret; } =20 #ifdef CONFIG_PROC_FS --=20 2.30.2