Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp401934iog; Thu, 30 Jun 2022 03:05:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u+4wIYkBMS6WXbecgMBC7RcQgBe/krCggmCDHP+3hYHtx02eB5tgj8RpSZvlOO5gqfZ7Eg X-Received: by 2002:a17:907:970b:b0:726:9af5:c7c7 with SMTP id jg11-20020a170907970b00b007269af5c7c7mr7561264ejc.417.1656583512406; Thu, 30 Jun 2022 03:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656583512; cv=none; d=google.com; s=arc-20160816; b=GM0zL7Hes+1khtrFIKZsUciaX3u66Sq/wyNukzGPLNAJVzNwRy66Qm40nVoCAs4nC+ XLiafJxtZMUd3oxV1r6yzJ13e3AU5zVuV1yykAz5H5vaqp8OiafLHxK5muqbktHAXaxh L062blAkPZeZRMRR+O7hIYKlJdfdux/mbkbUxcSQurdMC8VuDSbxLKqgeR7qCknLr4Sb 8pNSN28u433d1BWdrhD1zIIs1ucHH9UYLr0MpJhkFnSiZjJcPwKZ8GtdmVZ/p5sjaErN jv8LxFBLQ1uDupVoQh6eleRv18ouzpJfUMaz1198jSta6o/lBMTKb1KsRXMy1qqpS0KX qrPA== 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=sgvGDgKPrwLbeUqW4XYRdLuC4egsCzWZigh91QpoTW0=; b=lfjqeY8fi+6lk2J065/4UXlvfdxs+qAI158KRpOWftwHsNBMyxa4u/D/XMILFlmkmi li8F0gn0tMVVgeCCW5n8LneYqZb3MrZCfKftKHKsojstceW1ume5D62v7f5OlsUXX2fz Pj1+nUmABm8Ce8hXH2aP90td+m0ieo1Vi4HELd04qFaJx6vb0LwRASYsajUD3c7u5zMi jT32EgfwzVTGRr9puD+a0DqMm6kNPgigMRNbx5ESSPeLUtRiiHF7pLdKZGY2xf/D5OVf 5TY3C1mlc5nJyn6E2pXA2dC9TaKlLNsPgk79mrYK7+8qDi2e2VMVaLvuZMZTYC+XlwHR KmoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=U9579HFy; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020a056402354600b0043768221237si22674230edd.587.2022.06.30.03.04.47; Thu, 30 Jun 2022 03:05:12 -0700 (PDT) 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; dkim=pass header.i=@fb.com header.s=facebook header.b=U9579HFy; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234372AbiF3JTB (ORCPT + 99 others); Thu, 30 Jun 2022 05:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbiF3JSV (ORCPT ); Thu, 30 Jun 2022 05:18:21 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4188330F77 for ; Thu, 30 Jun 2022 02:17:09 -0700 (PDT) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 25U0LZOI020072 for ; Thu, 30 Jun 2022 02:17:08 -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=sgvGDgKPrwLbeUqW4XYRdLuC4egsCzWZigh91QpoTW0=; b=U9579HFyXBKCz7+TqYaTt2rR1YIrGtnMs2BVKi9O7Bro2EohjnrnQBYA0VH4aLnV/vep Iu+rDTsV/lAIW9uiVmSqsUizA8Jf2jttmbnqksyKM+ca/pOtSN+5ISs9fK2LTbFNyg0R dfGcBietoLtpZWxk6FFb3hetu0uvk1dyf5s= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3gywp2qpf0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 30 Jun 2022 02:17:08 -0700 Received: from twshared18317.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 30 Jun 2022 02:17:07 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id A5A552599FD6; Thu, 30 Jun 2022 02:14:08 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , CC: , , Dylan Yudaken Subject: [PATCH v2 for-next 05/12] io_uring: clean up io_poll_check_events return values Date: Thu, 30 Jun 2022 02:12:24 -0700 Message-ID: <20220630091231.1456789-6-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220630091231.1456789-1-dylany@fb.com> References: <20220630091231.1456789-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: bxsjyiMj-EUjMu_5Z--eti_J1VdwL_a6 X-Proofpoint-GUID: bxsjyiMj-EUjMu_5Z--eti_J1VdwL_a6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-30_05,2022-06-28_01,2022-06-22_01 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 The values returned are a bit confusing, where 0 and 1 have implied meaning, so add some definitions for them. Signed-off-by: Dylan Yudaken --- io_uring/poll.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/io_uring/poll.c b/io_uring/poll.c index fa25b88a7b93..922a3d1b2e31 100644 --- a/io_uring/poll.c +++ b/io_uring/poll.c @@ -192,13 +192,18 @@ static void io_poll_remove_entries(struct io_kiocb = *req) rcu_read_unlock(); } =20 +enum { + IOU_POLL_DONE =3D 0, + IOU_POLL_NO_ACTION =3D 1, +}; + /* * All poll tw should go through this. Checks for poll events, manages * references, does rewait, etc. * - * Returns a negative error on failure. >0 when no action require, which= is - * either spurious wakeup or multishot CQE is served. 0 when it's done w= ith - * the request, then the mask is stored in req->cqe.res. + * Returns a negative error on failure. IOU_POLL_NO_ACTION when no actio= n require, + * which is either spurious wakeup or multishot CQE is served. + * IOU_POLL_DONE when it's done with the request, then the mask is store= d in req->cqe.res. */ static int io_poll_check_events(struct io_kiocb *req, bool *locked) { @@ -214,10 +219,11 @@ static int io_poll_check_events(struct io_kiocb *re= q, bool *locked) =20 /* tw handler should be the owner, and so have some references */ if (WARN_ON_ONCE(!(v & IO_POLL_REF_MASK))) - return 0; + return IOU_POLL_DONE; if (v & IO_POLL_CANCEL_FLAG) return -ECANCELED; =20 + /* the mask was stashed in __io_poll_execute */ if (!req->cqe.res) { struct poll_table_struct pt =3D { ._key =3D req->apoll_events }; req->cqe.res =3D vfs_poll(req->file, &pt) & req->apoll_events; @@ -226,7 +232,7 @@ static int io_poll_check_events(struct io_kiocb *req,= bool *locked) if ((unlikely(!req->cqe.res))) continue; if (req->apoll_events & EPOLLONESHOT) - return 0; + return IOU_POLL_DONE; =20 /* multishot, just fill a CQE and proceed */ if (!(req->flags & REQ_F_APOLL_MULTISHOT)) { @@ -238,7 +244,7 @@ static int io_poll_check_events(struct io_kiocb *req,= bool *locked) return -ECANCELED; } else { ret =3D io_poll_issue(req, locked); - if (ret) + if (ret < 0) return ret; } =20 @@ -248,7 +254,7 @@ static int io_poll_check_events(struct io_kiocb *req,= bool *locked) */ } while (atomic_sub_return(v & IO_POLL_REF_MASK, &req->poll_refs)); =20 - return 1; + return IOU_POLL_NO_ACTION; } =20 static void io_poll_task_func(struct io_kiocb *req, bool *locked) @@ -256,12 +262,11 @@ static void io_poll_task_func(struct io_kiocb *req,= bool *locked) int ret; =20 ret =3D io_poll_check_events(req, locked); - if (ret > 0) + if (ret =3D=3D IOU_POLL_NO_ACTION) return; =20 - if (!ret) { + if (ret =3D=3D IOU_POLL_DONE) { struct io_poll *poll =3D io_kiocb_to_cmd(req); - req->cqe.res =3D mangle_poll(req->cqe.res & poll->events); } else { req->cqe.res =3D ret; @@ -280,7 +285,7 @@ static void io_apoll_task_func(struct io_kiocb *req, = bool *locked) int ret; =20 ret =3D io_poll_check_events(req, locked); - if (ret > 0) + if (ret =3D=3D IOU_POLL_NO_ACTION) return; =20 io_poll_remove_entries(req); --=20 2.30.2