From nobody Wed Dec 17 15:34:38 2025 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.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 05DD324168D for ; Mon, 17 Mar 2025 13:57:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742219881; cv=none; b=BDqxoFwLki2ClWpcApL615OCBHO606CcKYEmQRZ3KdmD9DX1ucEZnrE/4Gv4+TBNO4Ttykf9MNPfzb3EvWZV0lPzdqaLx2OARyAZiPeq6eCLjbtbGPL2vvu3xbAB8qzd99k8pzxkaM/3QS+44sOC/aYf1dFgas62Jx0njVlijBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742219881; c=relaxed/simple; bh=MUln8dzk96jrS8N7WaQSszZ2y7lpJFghuGsy5mJDX7w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bi8YXoFE3Dhc8San2SN28UmrSSVfkTXBXZ/TBpsAnBzrfCTkm4UYBSaw+CV/0uz3gCWPj5hTHIax9dvYFCCnFMQlkGN6pXZIETFU52X/8r54vIbnybc7nxqR8355Ljup0Oir26/hrT4NvAtJLRQ/D4Ew4GmTEqKm/I4GII/eVNI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=furiosa.ai; spf=none smtp.mailfrom=furiosa.ai; dkim=pass (1024-bit key) header.d=furiosa.ai header.i=@furiosa.ai header.b=dKUQoHMD; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=furiosa.ai header.i=@furiosa.ai header.b="dKUQoHMD" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2ff797f8f1bso2870650a91.3 for ; Mon, 17 Mar 2025 06:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=furiosa.ai; s=google; t=1742219879; x=1742824679; 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=YQa2yXoRrARN2BUDV+ngN+TPs4QoczcMbvd+w0pXTw8=; b=dKUQoHMD1mdhkIi4cVWcT90C8UdRh3hl4zoLdBuAW3lkrBY+EdQuAr4rKTFTpzWply Bwi0v+u2F+MQwPBHe/KkDp9XKb/AAO4CIh4tctu1O9hG0Ssz4ds3/1hnX+VaJo7Y8Fdq B4amqLcAVfk/fOx/4ItI6C8MAuEKkbxCIrcPQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742219879; x=1742824679; 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=YQa2yXoRrARN2BUDV+ngN+TPs4QoczcMbvd+w0pXTw8=; b=u5RsST32iHt28qFW9rvNjzBO3x3e+wvnV/XHcKs2Y8hINJpxd9+ItiqJDX7CU7suZr I7S/+Pc/7SzD55NfKNWvKOzWq7UL4wQGMf1TK1nQgI5XWu4KEldQiEm0A1YgZ4XlUhoT cy7VNmJNNUdWM89KoTyjiKfbaEGOHmqFfVem8ET99CMh08TJTkSSXM73ecN/QMiHS64k f2d/uJHzUjNz/i8ugWrtbwrwa/0n/4qqyGxcS8DeYpY5FhMlY9Kvs/Oxb6n07x3HonH9 fYwnYSscgXcobz82PMSPlDinAgob4Zfo5tm8v00lsGQv+p1Pdogqyw5rxyyOKZmv+Hli u6LQ== X-Forwarded-Encrypted: i=1; AJvYcCUdRRXinsDKW2i68Dt/Vke38AgExLQ0dkM/3O8xKyxeq0ai0V0m6XBRBJLQp/FWTkW4OKTvLeD+gR+5P0I=@vger.kernel.org X-Gm-Message-State: AOJu0YwDTvDKbNfyXqpiweHgQtNuG+qh+K3607juVfbbUmj8SYixLvyP 3R/r2NvCBsM4dWrouiChIdp+Rh+5IqDHqEC8tpFFDyoTevxGMWXsFuo6syv9vyM= X-Gm-Gg: ASbGncsDdnyygycrZNXeD1VRCGcS1eKjhDZvmb9GW93DVZjlkQe42jT1nVyL7Yl1sHE Anmwzxbuctn89EqMGPkadJXOKHPhqFGb+4G+dKI+8RjmU2uDrQBVW4au+Gvj7iHG6FfKUClwP10 hzfB6lo6ndhNvDTQQpUeesr5E5TZxQx0509X295INYwVbuMsV5KM2dz42LgG4ttMTJkCviXFBU/ xnNpzHqN0qzROmqdkwU+hiIP/ts6kSEH/PmhTA93F1juMpTKQHpAnbMtHPkSwibwYyhGPPw6dk6 Gx+Ef9NLYLMDr7PV2VN0GQeqPcw6A3kVVE04cdZI42HCDOKDDlaLoywwbdemrvrmbojIOojZTLK 3Yfma5PZ6K8tOzrU= X-Google-Smtp-Source: AGHT+IE1Y7pp7Us6sxXqWDZ6744BRQUSCXKFnFGSNVTBGDp4dsbg+5u3su0ELJH3VSZUrZsckswABQ== X-Received: by 2002:a17:90b:3145:b0:2fe:a336:fe65 with SMTP id 98e67ed59e1d1-30151cd2dc5mr16694880a91.10.1742219879425; Mon, 17 Mar 2025 06:57:59 -0700 (PDT) Received: from sidong.sidong.yang.office.furiosa.vpn ([61.83.209.48]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-30153b99508sm5993742a91.39.2025.03.17.06.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 06:57:59 -0700 (PDT) From: Sidong Yang To: Josef Bacik , David Sterba , Jens Axboe , Pavel Begunkov Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Sidong Yang Subject: [RFC PATCH v4 2/5] io-uring/cmd: add iou_vec field for io_uring_cmd Date: Mon, 17 Mar 2025 13:57:39 +0000 Message-ID: <20250317135742.4331-3-sidong.yang@furiosa.ai> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250317135742.4331-1-sidong.yang@furiosa.ai> References: <20250317135742.4331-1-sidong.yang@furiosa.ai> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch adds iou_vec field for io_uring_cmd. Also it needs to be cleanup for cache. It could be used in uring cmd api that imports multiple fixed buffers. Signed-off-by: Sidong Yang --- io_uring/io_uring.c | 2 +- io_uring/opdef.c | 1 + io_uring/uring_cmd.c | 20 ++++++++++++++++++++ io_uring/uring_cmd.h | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 513f036bccbb..08506d1224c5 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -289,7 +289,7 @@ static void io_free_alloc_caches(struct io_ring_ctx *ct= x) io_alloc_cache_free(&ctx->apoll_cache, kfree); io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free); io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free); - io_alloc_cache_free(&ctx->uring_cache, kfree); + io_alloc_cache_free(&ctx->uring_cache, io_cmd_cache_free); io_alloc_cache_free(&ctx->msg_cache, kfree); io_futex_cache_free(ctx); io_rsrc_cache_free(ctx); diff --git a/io_uring/opdef.c b/io_uring/opdef.c index e4aa61a414fb..489384c0438b 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -755,6 +755,7 @@ const struct io_cold_def io_cold_defs[] =3D { }, [IORING_OP_URING_CMD] =3D { .name =3D "URING_CMD", + .cleanup =3D io_uring_cmd_cleanup, }, [IORING_OP_SEND_ZC] =3D { .name =3D "SEND_ZC", diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index e4cd6fe9fd47..bf4002e93ec5 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -29,6 +29,13 @@ static void io_req_uring_cleanup(struct io_kiocb *req, u= nsigned int issue_flags) =20 if (issue_flags & IO_URING_F_UNLOCKED) return; + + req->flags &=3D ~REQ_F_NEED_CLEANUP; + + io_alloc_cache_vec_kasan(&ac->iou_vec); + if (ac->iou_vec.nr > IO_VEC_CACHE_SOFT_CAP) + io_vec_free(&ac->iou_vec); + if (io_alloc_cache_put(&req->ctx->uring_cache, cache)) { ioucmd->sqe =3D NULL; req->async_data =3D NULL; @@ -36,6 +43,11 @@ static void io_req_uring_cleanup(struct io_kiocb *req, u= nsigned int issue_flags) } } =20 +void io_uring_cmd_cleanup(struct io_kiocb *req) +{ + io_req_uring_cleanup(req, 0); +} + bool io_uring_try_cancel_uring_cmd(struct io_ring_ctx *ctx, struct io_uring_task *tctx, bool cancel_all) { @@ -346,3 +358,11 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsign= ed int issue_flags) } EXPORT_SYMBOL_GPL(io_uring_cmd_sock); #endif + +void io_cmd_cache_free(const void *entry) +{ + struct io_async_cmd *ac =3D (struct io_async_cmd *)entry; + + io_vec_free(&ac->iou_vec); + kfree(ac); +} diff --git a/io_uring/uring_cmd.h b/io_uring/uring_cmd.h index f3593012658c..8986224e0c57 100644 --- a/io_uring/uring_cmd.h +++ b/io_uring/uring_cmd.h @@ -1,13 +1,17 @@ // SPDX-License-Identifier: GPL-2.0 +#include =20 #include =20 struct io_async_cmd { struct io_uring_cmd_data data; + struct iou_vec iou_vec; }; =20 int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags); int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe= ); +void io_uring_cmd_cleanup(struct io_kiocb *req); =20 bool io_uring_try_cancel_uring_cmd(struct io_ring_ctx *ctx, struct io_uring_task *tctx, bool cancel_all); +void io_cmd_cache_free(const void *entry); --=20 2.43.0