From patchwork Tue Apr 30 15:42:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13649554 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F154173322 for ; Tue, 30 Apr 2024 15:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714491743; cv=none; b=sWucxSYqJns4e5Dqt1XoInthEPTJNBM1fvAlL2bHJGS9+ccMkRYeTALALtVGcQNnvizQ0lAZCz1+z6t3JZiCczjtclGWmOiLZy0JImGb4sPqFsBnWZ4qELH5EjKkBi5yAJm4M8ZEomq6p4RNp/sdVwk8MZCOpK/m3A2tbqfCbLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714491743; c=relaxed/simple; bh=Uf+YzQnxRQiBzc6SWP15OqG3Xu/BoGG2ZK2FkO2kLrM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jsZY8+mPCKsGdOu4wwEm77jeD5S2by3dHEYCvQJK4PvrveBWgnT9ZVUiuL+GCfc95lyJflbDzyhloAyZN7XnIgZVseja1hSSsHx/DqbWcgIsdx2Q6hJTP1ZBYSg1bs+ZzhBRfYoFV3ySPhoq4LyeocCZ96E3LdSP7p8yqiJ0Fp8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EYXXZOoY; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EYXXZOoY" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-56c5d05128dso5311784a12.0 for ; Tue, 30 Apr 2024 08:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714491739; x=1715096539; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M9xDfjdYIHN2uBhWU3bX363wFy33L9fUZ53OUgymdnU=; b=EYXXZOoYVpyBLUAe18PnZCWKwx4Iy63sMAFjNuaDdDWLZmOkk9PIjbz2nE+gaRl2E/ vMlbfbsIE4TW4dPag+iOKBpyYq2s07lzGZH3V/BrR7OU7CdL0SLgd/CSEOVxBeBQ+2b+ x+tHWlcD1zEiXg08f98BpgqGMGIRGJrXqmIu2Fl1j1QRJx8B/wzbTNecxCFrXRcUDPIF +RdpufqwsfOPTRVeNj9m9oe/lQEwHl27qd93XHLItODs7Ty8jMzJpavpBB9EIKJW7oAE Ilc4Jm0P/JOOGDa2qIjIZ1GX82v7XRKvX9kyM0vT7QNebTubLctoFMzXaXKvM2q13sPm bXKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714491739; x=1715096539; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M9xDfjdYIHN2uBhWU3bX363wFy33L9fUZ53OUgymdnU=; b=AI/SfCaTRYXN88nuTDjdv78VhpuQtOIaxB1OGx2xphqt4/8LGDUYg1fkDNZe89OPSJ X8JXuqRkp0jg6quZLprfQq0mzp3IFkjALUbhhxKauCgok4P/XoMuxKq/RlPhG9R4T31o zfkwKZTrMr1jWv6R5O4/NUKvYnxpLXThgaFzOIqCg4sgtYbIvN1hsUbGpOSUw0reuL5j feOIhEDNzyBjSwXratkoyJvVuZSkuicUT6ERBjyCEuxRzJkwlRSRYp0RmxKbvpTwpeYE 9nKEBsb/fzzrpPLIt/LxcL6msU96qekFf4FcAMQii3t5K0Yc1TFwzwa0h01G+gEO27D4 WCKQ== X-Gm-Message-State: AOJu0YwYxKCRDq/XwcN+Iuag+82jpcEU1H4B1fGQDd8DXx+xB3AF+GNx BuxlDGagQO8OlGkPTBoIvA5vlhYIymM4m5c7h7zIH9WRp408vponxEPhe0DF X-Google-Smtp-Source: AGHT+IEQ1cR3acCcI/aqwuE+fM5LF1BRkbAtLXS+zX1zx0p6CaafpQbQSv21m6NSIVTRW7ODRnGZ2g== X-Received: by 2002:a17:906:f214:b0:a55:63d3:7499 with SMTP id gt20-20020a170906f21400b00a5563d37499mr55825ejb.59.1714491738946; Tue, 30 Apr 2024 08:42:18 -0700 (PDT) Received: from 127.0.0.1localhost ([163.114.131.193]) by smtp.gmail.com with ESMTPSA id p8-20020a17090653c800b00a51a259fa60sm15201465ejo.118.2024.04.30.08.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 08:42:18 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH 1/2] io_uring/net: fix sendzc lazy wake polling Date: Tue, 30 Apr 2024 16:42:30 +0100 Message-ID: <5b360fb352d91e3aec751d75c87dfb4753a084ee.1714488419.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 SEND[MSG]_ZC produces multiple CQEs via notifications, LAZY_WAKE doesn't handle it and so disable LAZY_WAKE for sendzc polling. It should be fine, sends are not likely to be polled in the first place. Fixes: 6ce4a93dbb5b ("io_uring/poll: use IOU_F_TWQ_LAZY_WAKE for wakeups") Signed-off-by: Pavel Begunkov --- io_uring/net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/io_uring/net.c b/io_uring/net.c index 51c41d771c50..503debecad32 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1198,6 +1198,7 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) struct io_kiocb *notif; zc->done_io = 0; + req->flags |= REQ_F_POLL_NO_LAZY; if (unlikely(READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3))) return -EINVAL; From patchwork Tue Apr 30 15:42:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13649555 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF47E172BCB for ; Tue, 30 Apr 2024 15:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714491744; cv=none; b=V9jp1JSBRFeJzoglVHFzv7U9RTNi2LukiBml+a++5ZffTpZFMs7AJjYUS2/A4zD+Cn0Ypb25XnNTJzP5JFlTM0UusmpPDVQ/kYT7ECIee89vqYOvj3GtovMi+g0WN6/edRF0vMOhg/c2IUpQ2eaQI7RwA5bLDcb+GN2/tKprmWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714491744; c=relaxed/simple; bh=ZttkBGki6C1Q+1L6cVzTyiOuJ3gTmtwinljrHov8e68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dZE83LYdTyQdHr62o0ncGE2logsb+BxVOzQvy9z57bBEz4rUQnu5LbCsazpS67oHsitWQGNK4/+n2xFWrKWvd/lr1ESSZQz/0EE+S8Co3y9jjRkvbXIxTcjdEj+6tjDs7vTZllAa6REFUSafh33kjeidUn2407TCpPQ6bRpOSgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Z9AKRESS; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z9AKRESS" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a5557e3ebcaso960003766b.1 for ; Tue, 30 Apr 2024 08:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714491740; x=1715096540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1E9ZQrnTua7PupSaGNnoA+t7rPGTpUcCkl5h0oAn1eU=; b=Z9AKRESSaDIOlmcHmA0gJe9zGJ2EFZcmz16G0ih/KzBIwpbfpJuHKZWbcaksk79OvV yR0U8WXI9A/PfeaGRKkK3EzvlLjgexen4FqWEzAWgeU6xG9vuXXykN9O1P/XG1UupA4W avCugx9QFyM6a1UAlbRnLODWvx2heGqVtSNf+88Yk9Xq1F7cBhXijZgfAXlbdzMRVZTj FE2dIB5j08OoKtzqoxTZfY3md6HS7ZGo0+aeMS4Fsm7Dt+tIWzViUz+Le/op1CdKmk2H boA8qdBKb3PDtlXH6wy66EdmTy+hhsGse8tPqanYpLq99pqx0W22lrrg9gjRApMX2q3l RN+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714491740; x=1715096540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1E9ZQrnTua7PupSaGNnoA+t7rPGTpUcCkl5h0oAn1eU=; b=XJL54vI2knp1gf9sa8cfQrcfPm+zR/rM31ZJIQHAwKD7qPbqunp7RSWMMPvk9EjvlO LPgPis+CEWYziLTf95vN6yeiBS2UHJbOroub+DhJz0OBoJYXUL++ZDmXKnh8tExtIq6f peh1GiM6uryAn5Q9BKLSMsDqBSP3QQ3ROp+0YLfDJHpFtjh2OnZ5iFD/a4bbQCW8dR9v J5UDxj3TsFoTAtu6cM6E766WCWPXo/27LmXG25P1pBLpKweGUiNhfz2S9KnFrDIx7Tno cve++hMQr+Xb59pTpFKTeoE54w7xPjJlsYKDRx/9UfgP4ZYo321EzkTpQRzpTjezehvS L5Cg== X-Gm-Message-State: AOJu0YxNQ9emCR5Z8uMafVxCkDjN87kLRWuFa2LHSyXOypxMr+rcJ1Oy AUaWzixzHqNsvVwVUvJTg+yAAJbb+3JpgJlxhSWNq1hBzOYNe7wnUfDSr+OA X-Google-Smtp-Source: AGHT+IFYExnPhK0l1XtmfE3sIaXNy9ttIwAvFDwmsF4/B5i8/EjcE7rjaf89Wi/53QNYw8HGGlErmA== X-Received: by 2002:a17:906:af94:b0:a52:71d6:d605 with SMTP id mj20-20020a170906af9400b00a5271d6d605mr94723ejb.23.1714491740181; Tue, 30 Apr 2024 08:42:20 -0700 (PDT) Received: from 127.0.0.1localhost ([163.114.131.193]) by smtp.gmail.com with ESMTPSA id p8-20020a17090653c800b00a51a259fa60sm15201465ejo.118.2024.04.30.08.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 08:42:19 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH 2/2] io_uring/notif: disable LAZY_WAKE for linked notifs Date: Tue, 30 Apr 2024 16:42:31 +0100 Message-ID: <0a5accdb7d2d0d27ebec14f8106e14e0192fae17.1714488419.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Notifications may now be linked and thus a single tw can post multiple CQEs, it's not safe to use LAZY_WAKE with them. Disable LAZY_WAKE for now, if that'd prove to be a problem we can count them and pass the expected number of CQEs into __io_req_task_work_add(). Fixes: 6fe4220912d19 ("io_uring/notif: implement notification stacking") Signed-off-by: Pavel Begunkov --- io_uring/notif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/io_uring/notif.c b/io_uring/notif.c index d58cdc01e691..28859ae3ee6e 100644 --- a/io_uring/notif.c +++ b/io_uring/notif.c @@ -38,6 +38,7 @@ void io_tx_ubuf_complete(struct sk_buff *skb, struct ubuf_info *uarg, { struct io_notif_data *nd = container_of(uarg, struct io_notif_data, uarg); struct io_kiocb *notif = cmd_to_io_kiocb(nd); + unsigned tw_flags; if (nd->zc_report) { if (success && !nd->zc_used && skb) @@ -53,8 +54,10 @@ void io_tx_ubuf_complete(struct sk_buff *skb, struct ubuf_info *uarg, io_tx_ubuf_complete(skb, &nd->head->uarg, success); return; } + + tw_flags = nd->next ? 0 : IOU_F_TWQ_LAZY_WAKE; notif->io_task_work.func = io_notif_tw_complete; - __io_req_task_work_add(notif, IOU_F_TWQ_LAZY_WAKE); + __io_req_task_work_add(notif, tw_flags); } static int io_link_skb(struct sk_buff *skb, struct ubuf_info *uarg)