From patchwork Wed Jun 15 10:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12882073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03BADC43334 for ; Wed, 15 Jun 2022 10:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239593AbiFOKXt (ORCPT ); Wed, 15 Jun 2022 06:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348688AbiFOKXf (ORCPT ); Wed, 15 Jun 2022 06:23:35 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 163FC165A7 for ; Wed, 15 Jun 2022 03:23:34 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id o8so14735211wro.3 for ; Wed, 15 Jun 2022 03:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LDQSAWiBnCEPM2LQzZO/iGVI5Xe9uF7XB3/IgLRw4W0=; b=haJqwUONFOm5BrCeCj5jEcIjW5+pvzHZQAOeOGHgnovX3i6iafl1mlCUXd/Q6t2Ag/ j/5vV1KKgOetnylSGdQVXQn5ECumLEnkxuG1F8REfTxw6hjYD659O/nG9f9sQcxgYfiY V+ljd3cE9j26LjHjdzhyquBVZPKgFlvLScEbxx3oS9ptMSaqEUAj3atG/ej5POwtKiXl p4rXuIjf/n5q44gjfHEJuATM120LCbylA2nSmUcrnBd5pQGwqTuPOF3h+k6L4UubuTYm 9fqCGGC/kHWEM4bY0/m/GhUp+zaoCa5VCRLO+7whL5Ap9UtA52lQK4eOC7SFF5xCYaTc QwQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LDQSAWiBnCEPM2LQzZO/iGVI5Xe9uF7XB3/IgLRw4W0=; b=ptQXYKWMd6HCRATnaeohgyqnlV8RBa8FXX+TAyYNu+UwY+9jFRb8rFy40HKcJkyeu3 AtAc+W1cNtGgHMlq/58/C/PI14+n61lXuLj2u/aDGS+4b7VczsxbEXSgl/inS9je0gUS uz62v/fPu+YfBkoF0ficKFyFamYRZgsc8Y8VCg9ff96xH1dnoKLW5wetBIwpElSfQ2SW aAC9QyeYoEbqaUvgTuw3AcoyXbpmg5+Ceav2mOlNGG3pMGV4K9bQrtXDZDc+9n9ZBcj0 eWdgQ9YKYmp6y8SwjraWtNA3DCJGYF0wypAI+IImMUY3s7Y5U7ZEDl2kI66iWroRGTAT p/Ew== X-Gm-Message-State: AJIora9Av3YFG6fGs/jUruv6JscPYOAD+SpG+JPnQvuciMYY9w7lGLn7 Nep5Tp/un0QVtDqLUVSFZqVvXmv+x+rwEA== X-Google-Smtp-Source: AGRyM1szXJU6YLzm511zHdijZ3r3+s9A0I+9DWosf9tciv5eC++xAaTH8U3X1w2tTk2Aq+7jzzgMbw== X-Received: by 2002:a5d:67c9:0:b0:218:4a6a:298e with SMTP id n9-20020a5d67c9000000b002184a6a298emr9428144wrw.153.1655288612214; Wed, 15 Jun 2022 03:23:32 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.125.106.threembb.co.uk. [188.28.125.106]) by smtp.gmail.com with ESMTPSA id p124-20020a1c2982000000b0039c7dbafa7asm1964984wmp.19.2022.06.15.03.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:23:31 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH 5.19 1/6] io_uring: get rid of __io_fill_cqe{32}_req() Date: Wed, 15 Jun 2022 11:23:02 +0100 Message-Id: X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org There are too many cqe filling helpers, kill __io_fill_cqe{32}_req(), use __io_fill_cqe{32}_req_filled() instead, and then rename it. It'll simplify fixing in following patches. Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 70 ++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 49 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 1b0b6099e717..654c2f897497 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2464,8 +2464,8 @@ static inline bool __io_fill_cqe(struct io_ring_ctx *ctx, u64 user_data, return io_cqring_event_overflow(ctx, user_data, res, cflags, 0, 0); } -static inline bool __io_fill_cqe_req_filled(struct io_ring_ctx *ctx, - struct io_kiocb *req) +static inline bool __io_fill_cqe_req(struct io_ring_ctx *ctx, + struct io_kiocb *req) { struct io_uring_cqe *cqe; @@ -2486,8 +2486,8 @@ static inline bool __io_fill_cqe_req_filled(struct io_ring_ctx *ctx, req->cqe.res, req->cqe.flags, 0, 0); } -static inline bool __io_fill_cqe32_req_filled(struct io_ring_ctx *ctx, - struct io_kiocb *req) +static inline bool __io_fill_cqe32_req(struct io_ring_ctx *ctx, + struct io_kiocb *req) { struct io_uring_cqe *cqe; u64 extra1 = req->extra1; @@ -2513,44 +2513,6 @@ static inline bool __io_fill_cqe32_req_filled(struct io_ring_ctx *ctx, req->cqe.flags, extra1, extra2); } -static inline bool __io_fill_cqe_req(struct io_kiocb *req, s32 res, u32 cflags) -{ - trace_io_uring_complete(req->ctx, req, req->cqe.user_data, res, cflags, 0, 0); - return __io_fill_cqe(req->ctx, req->cqe.user_data, res, cflags); -} - -static inline void __io_fill_cqe32_req(struct io_kiocb *req, s32 res, u32 cflags, - u64 extra1, u64 extra2) -{ - struct io_ring_ctx *ctx = req->ctx; - struct io_uring_cqe *cqe; - - if (WARN_ON_ONCE(!(ctx->flags & IORING_SETUP_CQE32))) - return; - if (req->flags & REQ_F_CQE_SKIP) - return; - - trace_io_uring_complete(ctx, req, req->cqe.user_data, res, cflags, - extra1, extra2); - - /* - * If we can't get a cq entry, userspace overflowed the - * submission (by quite a lot). Increment the overflow count in - * the ring. - */ - cqe = io_get_cqe(ctx); - if (likely(cqe)) { - WRITE_ONCE(cqe->user_data, req->cqe.user_data); - WRITE_ONCE(cqe->res, res); - WRITE_ONCE(cqe->flags, cflags); - WRITE_ONCE(cqe->big_cqe[0], extra1); - WRITE_ONCE(cqe->big_cqe[1], extra2); - return; - } - - io_cqring_event_overflow(ctx, req->cqe.user_data, res, cflags, extra1, extra2); -} - static noinline bool io_fill_cqe_aux(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags) { @@ -2593,16 +2555,24 @@ static void __io_req_complete_put(struct io_kiocb *req) static void __io_req_complete_post(struct io_kiocb *req, s32 res, u32 cflags) { - if (!(req->flags & REQ_F_CQE_SKIP)) - __io_fill_cqe_req(req, res, cflags); + if (!(req->flags & REQ_F_CQE_SKIP)) { + req->cqe.res = res; + req->cqe.flags = cflags; + __io_fill_cqe_req(req->ctx, req); + } __io_req_complete_put(req); } static void __io_req_complete_post32(struct io_kiocb *req, s32 res, u32 cflags, u64 extra1, u64 extra2) { - if (!(req->flags & REQ_F_CQE_SKIP)) - __io_fill_cqe32_req(req, res, cflags, extra1, extra2); + if (!(req->flags & REQ_F_CQE_SKIP)) { + req->cqe.res = res; + req->cqe.flags = cflags; + req->extra1 = extra1; + req->extra2 = extra2; + __io_fill_cqe32_req(req->ctx, req); + } __io_req_complete_put(req); } @@ -3207,9 +3177,9 @@ static void __io_submit_flush_completions(struct io_ring_ctx *ctx) if (!(req->flags & REQ_F_CQE_SKIP)) { if (!(ctx->flags & IORING_SETUP_CQE32)) - __io_fill_cqe_req_filled(ctx, req); + __io_fill_cqe_req(ctx, req); else - __io_fill_cqe32_req_filled(ctx, req); + __io_fill_cqe32_req(ctx, req); } } @@ -3329,7 +3299,9 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin) nr_events++; if (unlikely(req->flags & REQ_F_CQE_SKIP)) continue; - __io_fill_cqe_req(req, req->cqe.res, io_put_kbuf(req, 0)); + + req->cqe.flags = io_put_kbuf(req, 0); + __io_fill_cqe_req(req->ctx, req); } if (unlikely(!nr_events)) From patchwork Wed Jun 15 10:23:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12882076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73869CCA47B for ; Wed, 15 Jun 2022 10:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240029AbiFOKXu (ORCPT ); Wed, 15 Jun 2022 06:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348720AbiFOKXg (ORCPT ); Wed, 15 Jun 2022 06:23:36 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363A8167F8 for ; Wed, 15 Jun 2022 03:23:35 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id w17so7213039wrg.7 for ; Wed, 15 Jun 2022 03:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LcX43DmmGMu+lcbKelq5QUR+uzMmfZHUi91+QyPedxs=; b=Ucrylz1Q/6qIvjbTmtNPRi0U7A2gucrJaaJvDccfB0xZP0eCyAtBREGs//lqFgKKuR RoLwRafi65GAhxUzuiFthGErgQ0p/4a/5Wsdbx1fw6sIZ02smf+hEHZ4/K6Awr/CkJfa RvlS/p260TUyQ2mKaQsF67toTLP2A8U4mJEZqqJj4ii03Ozf1ytAEv5T6t9oTmQMxx6S vrEia+Iau8AFwPRpY/qyiznStbNRwZaQ+NvTkS9URKR6UeldI7r+nEjAjzdP16JT/kss +sGBKA39MnCWsvuulbIkzk3LOWx8pAekjZ94KxfBekeI2KO14P0DiilpXlp/CZV5Bn/d 1WHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LcX43DmmGMu+lcbKelq5QUR+uzMmfZHUi91+QyPedxs=; b=W+URFG3PNYLZXIz53qZ5octb5D8Zz1yu7tP4Fubpz9KVyX9i4vUeoQSHNak39M6Dsx NgR225J3I7Hxgpemm5p60WQbw2xMvum+ZgOc2UGke5WwTpuAolwOCu6od0gy1sjpYWTA 2fnDhbF14kA0kBNqh75FaDCD/xMpWtzWxXHw4Njy8Or9Vv1H1djAEtdRuT0UuvfAFFmP vA08qxUFRBSMDZrrNgMS0yS1a331rjT5tcRmRV+Rbl5C1jOuq3Rf93zwMPQl2dkDbFjq hDMMLNKNWEsEeMAjT8Gvrb9SOffLbcoBJeBW3g0+iSrKKRgj4/qSvGqiKSjbkLkuuAa/ DqRw== X-Gm-Message-State: AJIora/VXDJj2wLJuJWfPLFWJoJEnabuwtJqMOa92+WeandNl7KmVco4 fgqpwqFT/nl+F2VYV1LlpWEEG8KIXwdHAA== X-Google-Smtp-Source: AGRyM1t50Op7LLy5ghiHk7hegsC7ZqxuuHo0susR47mO62B91Bvt0+ouc3Kv1HEEOAZMU9UwtRc47w== X-Received: by 2002:adf:d206:0:b0:214:d2b:7141 with SMTP id j6-20020adfd206000000b002140d2b7141mr9079948wrh.706.1655288613368; Wed, 15 Jun 2022 03:23:33 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.125.106.threembb.co.uk. [188.28.125.106]) by smtp.gmail.com with ESMTPSA id p124-20020a1c2982000000b0039c7dbafa7asm1964984wmp.19.2022.06.15.03.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:23:32 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH 5.19 2/6] io_uring: unite fill_cqe and the 32B version Date: Wed, 15 Jun 2022 11:23:03 +0100 Message-Id: <8085c5b2f74141520f60decd45334f87e389b718.1655287457.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org We want just one function that will handle both normal cqes and 32B cqes. Combine __io_fill_cqe_req() and __io_fill_cqe_req32(). It's still not entirely correct yet, but saves us from cases when we fill an CQE of a wrong size. Fixes: 76c68fbf1a1f9 ("io_uring: enable CQE32") Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 61 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 654c2f897497..eb858cf92af9 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2469,21 +2469,48 @@ static inline bool __io_fill_cqe_req(struct io_ring_ctx *ctx, { struct io_uring_cqe *cqe; - trace_io_uring_complete(req->ctx, req, req->cqe.user_data, - req->cqe.res, req->cqe.flags, 0, 0); + if (!(ctx->flags & IORING_SETUP_CQE32)) { + trace_io_uring_complete(req->ctx, req, req->cqe.user_data, + req->cqe.res, req->cqe.flags, 0, 0); - /* - * If we can't get a cq entry, userspace overflowed the - * submission (by quite a lot). Increment the overflow count in - * the ring. - */ - cqe = io_get_cqe(ctx); - if (likely(cqe)) { - memcpy(cqe, &req->cqe, sizeof(*cqe)); - return true; + /* + * If we can't get a cq entry, userspace overflowed the + * submission (by quite a lot). Increment the overflow count in + * the ring. + */ + cqe = io_get_cqe(ctx); + if (likely(cqe)) { + memcpy(cqe, &req->cqe, sizeof(*cqe)); + return true; + } + + return io_cqring_event_overflow(ctx, req->cqe.user_data, + req->cqe.res, req->cqe.flags, + 0, 0); + } else { + u64 extra1 = req->extra1; + u64 extra2 = req->extra2; + + trace_io_uring_complete(req->ctx, req, req->cqe.user_data, + req->cqe.res, req->cqe.flags, extra1, extra2); + + /* + * If we can't get a cq entry, userspace overflowed the + * submission (by quite a lot). Increment the overflow count in + * the ring. + */ + cqe = io_get_cqe(ctx); + if (likely(cqe)) { + memcpy(cqe, &req->cqe, sizeof(struct io_uring_cqe)); + WRITE_ONCE(cqe->big_cqe[0], extra1); + WRITE_ONCE(cqe->big_cqe[1], extra2); + return true; + } + + return io_cqring_event_overflow(ctx, req->cqe.user_data, + req->cqe.res, req->cqe.flags, + extra1, extra2); } - return io_cqring_event_overflow(ctx, req->cqe.user_data, - req->cqe.res, req->cqe.flags, 0, 0); } static inline bool __io_fill_cqe32_req(struct io_ring_ctx *ctx, @@ -3175,12 +3202,8 @@ static void __io_submit_flush_completions(struct io_ring_ctx *ctx) struct io_kiocb *req = container_of(node, struct io_kiocb, comp_list); - if (!(req->flags & REQ_F_CQE_SKIP)) { - if (!(ctx->flags & IORING_SETUP_CQE32)) - __io_fill_cqe_req(ctx, req); - else - __io_fill_cqe32_req(ctx, req); - } + if (!(req->flags & REQ_F_CQE_SKIP)) + __io_fill_cqe_req(ctx, req); } io_commit_cqring(ctx); From patchwork Wed Jun 15 10:23:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12882078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C80D9C433EF for ; Wed, 15 Jun 2022 10:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345138AbiFOKXw (ORCPT ); Wed, 15 Jun 2022 06:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348737AbiFOKXh (ORCPT ); Wed, 15 Jun 2022 06:23:37 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A65F3183B8 for ; Wed, 15 Jun 2022 03:23:36 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id j5-20020a05600c1c0500b0039c5dbbfa48so856440wms.5 for ; Wed, 15 Jun 2022 03:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H+1s9q09mzQGGYXSBRIzOmlSGml7cgvMX4AVEHn5P0c=; b=Ed5OPm5VGw0fXl721sKPgAmyJ8rEVVDwP+akirjONtaXsP09Sc5fngTchXo+2Jx6DI 3pccmZ09wCm0KvD6eP979uk7q99Ik6qcELQkGR9J/pRhVHAjhsXRaGbE+MzEH2P05Ro9 fcVj5yrqbJWx09iwm8HcBLCswh9km6ShM9yWRULN3l/UxGVJSlZrJLq9Y8uwM21ANHiu JZXccQyDQxvoq9nKZBdb1FxUkbLqRJJgyC4jfIqbl9zUs1JiIF9NexVhBHdQ8sR2qi1u jsofk87GHSi/KR5zheau/Xk2viKAENK2CS4e9vsnW5PxDjEAjyxgFXBaIhUhd3F50JUk pe2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H+1s9q09mzQGGYXSBRIzOmlSGml7cgvMX4AVEHn5P0c=; b=q0yxgxLEeVhLe4Sur9aeSF6MV+AV5OYWTkmsIB+nrhHHj7NUnJiMK+HBr8G3GP9TTB n0nDCE2HfgLF8tP1rTdB3FHpodfouSGoyuwc7Wr2D6iPSi4SuLg3IlZ1Hj2hjmSE041v ZAjQ0/PapHrgZ2XIs25dvD/q8vl8ajKzEyUSSTkoqxvWs0xMELZ14Y7NOJbc/A3sJIcj 4vRuEHHHtSH1skYwu06QALM1hdU0sSUfPgKJFHDNI6p64C2m/5T6JzCp7HsYWGLabzqY ByJy+DgCBRIpicbIVuwumNSX7uZGJhtjiPbxWgS+Z2ObzU2C9PCPhZmhfh8T1ATBzxr/ T8mw== X-Gm-Message-State: AOAM530EnpRuZDXVPYqvIEIPVbHai+sPSXz5Avt1/c5meRGMIGHiCHDe b+cDqY/CbWqiKHUS8xhc4hBRNeU4JeeQ0Q== X-Google-Smtp-Source: ABdhPJyzdDYKqQabMWrOSqLkzoYir+z1FQ9K53AhA/bmkHgUOOujnYg+JZilP/y10vurEGgdFKJHyg== X-Received: by 2002:a05:600c:1d8a:b0:39c:69c7:7158 with SMTP id p10-20020a05600c1d8a00b0039c69c77158mr9046989wms.48.1655288614699; Wed, 15 Jun 2022 03:23:34 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.125.106.threembb.co.uk. [188.28.125.106]) by smtp.gmail.com with ESMTPSA id p124-20020a1c2982000000b0039c7dbafa7asm1964984wmp.19.2022.06.15.03.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:23:34 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH 5.19 3/6] io_uring: fill extra big cqe fields from req Date: Wed, 15 Jun 2022 11:23:04 +0100 Message-Id: X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org The only user of io_req_complete32()-like functions is cmd requests. Instead of keeping the whole complete32 family, remove them and provide the extras in already added for inline completions req->extra{1,2}. When fill_cqe_res() finds CQE32 option enabled it'll use those fields to fill a 32B cqe. Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 78 +++++++-------------------------------------------- 1 file changed, 10 insertions(+), 68 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index eb858cf92af9..10901db93f7e 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2513,33 +2513,6 @@ static inline bool __io_fill_cqe_req(struct io_ring_ctx *ctx, } } -static inline bool __io_fill_cqe32_req(struct io_ring_ctx *ctx, - struct io_kiocb *req) -{ - struct io_uring_cqe *cqe; - u64 extra1 = req->extra1; - u64 extra2 = req->extra2; - - trace_io_uring_complete(req->ctx, req, req->cqe.user_data, - req->cqe.res, req->cqe.flags, extra1, extra2); - - /* - * If we can't get a cq entry, userspace overflowed the - * submission (by quite a lot). Increment the overflow count in - * the ring. - */ - cqe = io_get_cqe(ctx); - if (likely(cqe)) { - memcpy(cqe, &req->cqe, sizeof(struct io_uring_cqe)); - cqe->big_cqe[0] = extra1; - cqe->big_cqe[1] = extra2; - return true; - } - - return io_cqring_event_overflow(ctx, req->cqe.user_data, req->cqe.res, - req->cqe.flags, extra1, extra2); -} - static noinline bool io_fill_cqe_aux(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags) { @@ -2590,19 +2563,6 @@ static void __io_req_complete_post(struct io_kiocb *req, s32 res, __io_req_complete_put(req); } -static void __io_req_complete_post32(struct io_kiocb *req, s32 res, - u32 cflags, u64 extra1, u64 extra2) -{ - if (!(req->flags & REQ_F_CQE_SKIP)) { - req->cqe.res = res; - req->cqe.flags = cflags; - req->extra1 = extra1; - req->extra2 = extra2; - __io_fill_cqe32_req(req->ctx, req); - } - __io_req_complete_put(req); -} - static void io_req_complete_post(struct io_kiocb *req, s32 res, u32 cflags) { struct io_ring_ctx *ctx = req->ctx; @@ -2614,18 +2574,6 @@ static void io_req_complete_post(struct io_kiocb *req, s32 res, u32 cflags) io_cqring_ev_posted(ctx); } -static void io_req_complete_post32(struct io_kiocb *req, s32 res, - u32 cflags, u64 extra1, u64 extra2) -{ - struct io_ring_ctx *ctx = req->ctx; - - spin_lock(&ctx->completion_lock); - __io_req_complete_post32(req, res, cflags, extra1, extra2); - io_commit_cqring(ctx); - spin_unlock(&ctx->completion_lock); - io_cqring_ev_posted(ctx); -} - static inline void io_req_complete_state(struct io_kiocb *req, s32 res, u32 cflags) { @@ -2643,19 +2591,6 @@ static inline void __io_req_complete(struct io_kiocb *req, unsigned issue_flags, io_req_complete_post(req, res, cflags); } -static inline void __io_req_complete32(struct io_kiocb *req, - unsigned int issue_flags, s32 res, - u32 cflags, u64 extra1, u64 extra2) -{ - if (issue_flags & IO_URING_F_COMPLETE_DEFER) { - io_req_complete_state(req, res, cflags); - req->extra1 = extra1; - req->extra2 = extra2; - } else { - io_req_complete_post32(req, res, cflags, extra1, extra2); - } -} - static inline void io_req_complete(struct io_kiocb *req, s32 res) { if (res < 0) @@ -5079,6 +5014,13 @@ void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd, } EXPORT_SYMBOL_GPL(io_uring_cmd_complete_in_task); +static inline void io_req_set_cqe32_extra(struct io_kiocb *req, + u64 extra1, u64 extra2) +{ + req->extra1 = extra1; + req->extra2 = extra2; +} + /* * Called by consumers of io_uring_cmd, if they originally returned * -EIOCBQUEUED upon receiving the command. @@ -5089,10 +5031,10 @@ void io_uring_cmd_done(struct io_uring_cmd *ioucmd, ssize_t ret, ssize_t res2) if (ret < 0) req_set_fail(req); + if (req->ctx->flags & IORING_SETUP_CQE32) - __io_req_complete32(req, 0, ret, 0, res2, 0); - else - io_req_complete(req, ret); + io_req_set_cqe32_extra(req, res2, 0); + io_req_complete(req, ret); } EXPORT_SYMBOL_GPL(io_uring_cmd_done); From patchwork Wed Jun 15 10:23:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12882075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DC4FCCA473 for ; Wed, 15 Jun 2022 10:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343555AbiFOKXv (ORCPT ); Wed, 15 Jun 2022 06:23:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348757AbiFOKXi (ORCPT ); Wed, 15 Jun 2022 06:23:38 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCCF2183BC for ; Wed, 15 Jun 2022 03:23:37 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id i17-20020a7bc951000000b0039c4760ec3fso1977758wml.0 for ; Wed, 15 Jun 2022 03:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HiCcQDq1baafO0nWvNgs2fXXD3ti+g1wIEHJP0lTT7Y=; b=ZJRrGqd+5Oq2zcwwKfU4LZsr5ZpxIIS3IrNwJ56kxaetC5EcOHAV+kLBsyyhM+qjQZ fkAbDtE8OZN1TmEmuUUYyMUxWDRbQ45nvorbJmiHGDewZdRE+bwps7fq2agLjHKMfmjS 5QdDeGw8hsBWs7OkcGZpCwAezc00VhnlNWCIo+lfxxHqa2IMQLSuPeMmaVbVOfsKaVVc hhIzopfC8pERy1h3klYr4c1KgcojWpStQFO22Sd/LEyjId2ey9EhGIZ24qt5DBDF+H1t OQoj7tkksjhq4Tn5jGoXyfFSlyh11YubcpA9JmVCRXKtI953eHl1X4wAmQcPfj1rKKUi pfmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HiCcQDq1baafO0nWvNgs2fXXD3ti+g1wIEHJP0lTT7Y=; b=6H6flPCnseRo0iJQbJchcycXL2TOPyYhO4evRbPab9addxB6udsco4KhacLkD0wImt pxQwKCCxCwPhCdzfFR2uPPATqceAk8fM9Or5owniUf2VyF0/XY0x9R+DMkJJgijPk72G TRA9pbcvzIKDVp+D4XNRjUIR+02O0PKA5JXytdob7rGCC4ah7yfhwa1rX/3GeT6rcK7A 3oAtcj4X4mos0Wo/iHktvcCFD6XyKZY6pFmyZg/hF0UlllUxZaziPar6FaMl0tXcvTO7 uDl8F57z6j/zGInAriew+ixyPVuPWfRVPeCZaiOKK4Rf2+jHXOOEOACsOHP1aR9ut7/l zZkQ== X-Gm-Message-State: AOAM5318JgE9KXDk+AuZk1b10K3OXJdZOqh5grRe7UzlHAlG81F6yEXy OfdqvUJZqOGxLA6xfaG8iZALioUnX+HKug== X-Google-Smtp-Source: ABdhPJz0wpXled+Fm61QlwbQ0AXRXK/qEzc6tVZ8hoHsfb2Kp+qUKHW0Kuhd0c7rGlRRC7nO61hBSg== X-Received: by 2002:a7b:cf2a:0:b0:39c:4eef:29e with SMTP id m10-20020a7bcf2a000000b0039c4eef029emr9248259wmg.28.1655288615845; Wed, 15 Jun 2022 03:23:35 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.125.106.threembb.co.uk. [188.28.125.106]) by smtp.gmail.com with ESMTPSA id p124-20020a1c2982000000b0039c7dbafa7asm1964984wmp.19.2022.06.15.03.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:23:35 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH 5.19 4/6] io_uring: fix ->extra{1,2} misuse Date: Wed, 15 Jun 2022 11:23:05 +0100 Message-Id: <4b3e5be512fbf4debec7270fd485b8a3b014d464.1655287457.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org We don't really know the state of req->extra{1,2] fields in __io_fill_cqe_req(), if an opcode handler is not aware of CQE32 option, it never sets them up properly. Track the state of those fields with a request flag. Fixes: 76c68fbf1a1f9 ("io_uring: enable CQE32") Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 10901db93f7e..808b7f4ace0b 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -844,6 +844,7 @@ enum { REQ_F_SINGLE_POLL_BIT, REQ_F_DOUBLE_POLL_BIT, REQ_F_PARTIAL_IO_BIT, + REQ_F_CQE32_INIT_BIT, REQ_F_APOLL_MULTISHOT_BIT, /* keep async read/write and isreg together and in order */ REQ_F_SUPPORT_NOWAIT_BIT, @@ -913,6 +914,8 @@ enum { REQ_F_PARTIAL_IO = BIT(REQ_F_PARTIAL_IO_BIT), /* fast poll multishot mode */ REQ_F_APOLL_MULTISHOT = BIT(REQ_F_APOLL_MULTISHOT_BIT), + /* ->extra1 and ->extra2 are initialised */ + REQ_F_CQE32_INIT = BIT(REQ_F_CQE32_INIT_BIT), }; struct async_poll { @@ -2488,8 +2491,12 @@ static inline bool __io_fill_cqe_req(struct io_ring_ctx *ctx, req->cqe.res, req->cqe.flags, 0, 0); } else { - u64 extra1 = req->extra1; - u64 extra2 = req->extra2; + u64 extra1 = 0, extra2 = 0; + + if (req->flags & REQ_F_CQE32_INIT) { + extra1 = req->extra1; + extra2 = req->extra2; + } trace_io_uring_complete(req->ctx, req, req->cqe.user_data, req->cqe.res, req->cqe.flags, extra1, extra2); @@ -5019,6 +5026,7 @@ static inline void io_req_set_cqe32_extra(struct io_kiocb *req, { req->extra1 = extra1; req->extra2 = extra2; + req->flags |= REQ_F_CQE32_INIT; } /* From patchwork Wed Jun 15 10:23:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12882077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C388CCA480 for ; Wed, 15 Jun 2022 10:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346622AbiFOKXw (ORCPT ); Wed, 15 Jun 2022 06:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348789AbiFOKXk (ORCPT ); Wed, 15 Jun 2022 06:23:40 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C14326B for ; Wed, 15 Jun 2022 03:23:39 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id l126-20020a1c2584000000b0039c1a10507fso862576wml.1 for ; Wed, 15 Jun 2022 03:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d5QWZ1a51qrP2icOZdU3RovoevCor5hzeqJHx4rxttE=; b=K48hYadHwPDSDDHLdU50ea4yuU0QQbe/aYKtAmbSWmQsW1735Pah9ZAXAtpMaQWCU/ Z/NiQ6Y3KWk73zyEvUtnR03GDCWNCysHhgMcck8q/qW4LT4auh2RFQHqJuvgmXmkExya tq/pKeVlw5YK4+zB5hJIBMarljMVrzW07iEXA2xhitU7heiBMfaGYltFVNcMyG9wR96Q XlG/Iv5HMjBycfpwKT7R8U+2EsagAVX+mcyBnIVJ8pL2pHonRQkYJGOrpqXYrowwUYFQ mrKBqLe0ASC8KNnSrTLey2WHe+s78hQ3AuiZv6byxZXShHPuLf7iRtPDVF7CM0ZJzA3G m+Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d5QWZ1a51qrP2icOZdU3RovoevCor5hzeqJHx4rxttE=; b=XIppKCid+JgxZMEXjIfWHei/9IwnARzAMjV6dxC7YQXam9kbH8xBCl1n+/hdgJg6P1 oJd9CmIEMbM/shIslUXtitM+4GhflpCtcPDewJw1rkEohv8cn1BP/Vl+VUD3P+MC/VPN IM0AUuw7jKzdrQHmTMRF58RE43UJtWRrzQlfhBFhfeluotR4k6Kr0WaPClh6ulbrpGSm pOdAJXE9R2qMQ5HzNItcQ5qvo2r1xIumc5+2OA02VCnYWxspe2Hl7K0Am8d6QWF/mSQr AX5LpfwO0//pj82mVGcJxmPJyc+L3sSI3IMzhguE0m7NH8SL0JgCt9wTllqhj7Ydngvi 8mXA== X-Gm-Message-State: AOAM532QAX+Gg6JrJh6Vt2m+dtHrAZL3RnDg0+jXE60/bIuVLsBud8n0 Vatsv/NJLD0h7vjn31pmNjyEG49cBm3Eyw== X-Google-Smtp-Source: ABdhPJzeAZkkdhro/dOpqPbXEcduuGT1pcUKyu6LRli91HjawPBke/HUAl/cvfIRZ+5GbOhSJeZ9Zg== X-Received: by 2002:a05:600c:b51:b0:39d:b58f:67bf with SMTP id k17-20020a05600c0b5100b0039db58f67bfmr6680248wmr.195.1655288617351; Wed, 15 Jun 2022 03:23:37 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.125.106.threembb.co.uk. [188.28.125.106]) by smtp.gmail.com with ESMTPSA id p124-20020a1c2982000000b0039c7dbafa7asm1964984wmp.19.2022.06.15.03.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:23:36 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH 5.19 5/6] io_uring: inline __io_fill_cqe() Date: Wed, 15 Jun 2022 11:23:06 +0100 Message-Id: <71dab9afc3cde3f8b64d26f20d3b60bdc40726ff.1655287457.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org In preparation for the following patch, inline __io_fill_cqe(), there is only one user. Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 808b7f4ace0b..792e9c95d217 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2447,26 +2447,6 @@ static bool io_cqring_event_overflow(struct io_ring_ctx *ctx, u64 user_data, return true; } -static inline bool __io_fill_cqe(struct io_ring_ctx *ctx, u64 user_data, - s32 res, u32 cflags) -{ - struct io_uring_cqe *cqe; - - /* - * If we can't get a cq entry, userspace overflowed the - * submission (by quite a lot). Increment the overflow count in - * the ring. - */ - cqe = io_get_cqe(ctx); - if (likely(cqe)) { - WRITE_ONCE(cqe->user_data, user_data); - WRITE_ONCE(cqe->res, res); - WRITE_ONCE(cqe->flags, cflags); - return true; - } - return io_cqring_event_overflow(ctx, user_data, res, cflags, 0, 0); -} - static inline bool __io_fill_cqe_req(struct io_ring_ctx *ctx, struct io_kiocb *req) { @@ -2523,9 +2503,24 @@ static inline bool __io_fill_cqe_req(struct io_ring_ctx *ctx, static noinline bool io_fill_cqe_aux(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags) { + struct io_uring_cqe *cqe; + ctx->cq_extra++; trace_io_uring_complete(ctx, NULL, user_data, res, cflags, 0, 0); - return __io_fill_cqe(ctx, user_data, res, cflags); + + /* + * If we can't get a cq entry, userspace overflowed the + * submission (by quite a lot). Increment the overflow count in + * the ring. + */ + cqe = io_get_cqe(ctx); + if (likely(cqe)) { + WRITE_ONCE(cqe->user_data, user_data); + WRITE_ONCE(cqe->res, res); + WRITE_ONCE(cqe->flags, cflags); + return true; + } + return io_cqring_event_overflow(ctx, user_data, res, cflags, 0, 0); } static void __io_req_complete_put(struct io_kiocb *req) From patchwork Wed Jun 15 10:23:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12882074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 028FCCCA47F for ; Wed, 15 Jun 2022 10:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244130AbiFOKXv (ORCPT ); Wed, 15 Jun 2022 06:23:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348796AbiFOKXl (ORCPT ); Wed, 15 Jun 2022 06:23:41 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C7E3BC7 for ; Wed, 15 Jun 2022 03:23:40 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id h5so14780168wrb.0 for ; Wed, 15 Jun 2022 03:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n/UhF3usf3aLjzjUsAalj8CixVGntP0n2zgwZ310CQM=; b=Lr+CUAHfnW80Q+uGLcbCjkRipVUCnhpO83nU7jXWgl9bWR7PwZ00icpucqHi7qVsXI l+GNtqN+ztfjW4Yswhi3+1rlt6/6FHldqIqt+H8UhL36EaH7nzSff6c6JpOgGXEgTSPg GPR568eMlV7eYRyGplNhdjckWYuOMzmYLrCqP+1hFO6hPBanuh1VV1wAut62mU0SIITE SZZ83QBNoiqLNt1yXP5uAv5x5Wefgdm4/xUfxYASqCKRZRqolH0m+EfBX5tuyZzFoXS+ WBdguBzvH75TZ4oP2dUgYVkOEPl5X3PV7RoA6UXWACYhlpzvqigLWFy4pIW5DkVRIRqD rd5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n/UhF3usf3aLjzjUsAalj8CixVGntP0n2zgwZ310CQM=; b=Ywqdtj99pXw1xQJapDh8ggOmQRwfEof4bNnEkNcPpji/oWqzXMTxcQX1sRfVUUcWws maRY2cfTCJhLX3oth8Nom8hCUNLAh8ZhqOQcr94GwbuN2hmtJAJlmuiUwHbgzKa9hlNa hZzxJhbwWLFC7j1FRZpwf+PZ2DEKbBVmFncTv0CMJykySFelRNqd3gA9om9jFCabvNec HAj16M5ZpYbFsEF3/U5SHq95ScQ3yMxGXPTbjp6jU5t/cm3STLzBNYAX9Wk7j2ChJZn9 7DCxZnIWT8Yb4ZGQLpXg9g355z9svE6xD8ulsCHAnMgId2IRz+GaRdsTzCtkcFWYCMa2 Uo8Q== X-Gm-Message-State: AJIora8/v9zqHgUBzQknweCr7oj82BcL0liYArXtMpeDDp1dDNOIT/hw 8RUYhN4hdzjQvjJ8jy6/dDxKzcJ79XNlIw== X-Google-Smtp-Source: AGRyM1tNIFUauGBaLmLocmh1EUD2+TDv5Yo4StF4jaJ9q+JKK/JTNwCQGgBtwJmeuw6MPm2w5iLOjw== X-Received: by 2002:a5d:4708:0:b0:215:d1fa:1b9e with SMTP id y8-20020a5d4708000000b00215d1fa1b9emr9378277wrq.202.1655288618592; Wed, 15 Jun 2022 03:23:38 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.125.106.threembb.co.uk. [188.28.125.106]) by smtp.gmail.com with ESMTPSA id p124-20020a1c2982000000b0039c7dbafa7asm1964984wmp.19.2022.06.15.03.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:23:38 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH 5.19 6/6] io_uring: make io_fill_cqe_aux to honour CQE32 Date: Wed, 15 Jun 2022 11:23:07 +0100 Message-Id: <64fae669fae1b7083aa15d0cd807f692b0880b9a.1655287457.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Don't let io_fill_cqe_aux() post 16B cqes for CQE32 rings, neither the kernel nor the userspace expect this to happen. Fixes: 76c68fbf1a1f9 ("io_uring: enable CQE32") Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index 792e9c95d217..5d479428d8e5 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2518,6 +2518,11 @@ static noinline bool io_fill_cqe_aux(struct io_ring_ctx *ctx, u64 user_data, WRITE_ONCE(cqe->user_data, user_data); WRITE_ONCE(cqe->res, res); WRITE_ONCE(cqe->flags, cflags); + + if (ctx->flags & IORING_SETUP_CQE32) { + WRITE_ONCE(cqe->big_cqe[0], 0); + WRITE_ONCE(cqe->big_cqe[1], 0); + } return true; } return io_cqring_event_overflow(ctx, user_data, res, cflags, 0, 0);