From patchwork Fri Oct 18 18:38:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13842201 Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (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 713C22038D8 for ; Fri, 18 Oct 2024 18:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729276796; cv=none; b=h8H+yx5xOh1mxRLBlTMAGw7V6tW+WquJ8VzyKN7AulpJeR0l88E7klcWjV+UmxRkuPiJa+yorXKNuv7G8sRond5jTORIQOKWyqvx/EHSVul6wBY2KQ9ujL53PhwfznSY47RPv+4J/mq+ooaZ9F+lKwDu1d/uj5wTSYwWIhLy0O4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729276796; c=relaxed/simple; bh=3zAf6cZsUKDjd0U7E/gViTKnNsdT3j6Sf7fwClyu8E0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j2HGyLLMWBPJC8dNnpCQ+Zm5YBqUmg8OgFXfUam6iiNeKANq/Eh6Dsm3T3ANdQTGnuAMELI3X2NdJMIi/o7Iusqf9aemmRZTQM0IaUyFq48vv6SnXAxDc6BbFTTqMuzvwwDhIg6/VtCuedwlCbaA6coF+1wwAC97VCdW6Xti20s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=OPh1lluy; arc=none smtp.client-ip=209.85.166.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="OPh1lluy" Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-3a394418442so8122535ab.0 for ; Fri, 18 Oct 2024 11:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1729276793; x=1729881593; 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=GWz3IDfZkv8mUSaTED6HeCh+NfgGbCeSvdWGpFVpBBA=; b=OPh1lluyQQuLDMH1jDYUKhXoljruN/nxKPmfeuGSbMFzefuv6n4E1azCERMnpPvsm3 jGwiK7JNkhcDyQUiE32Spc/R2FGDuwxPUC4bUQ/JJsQ8Z06q+s31pWrH+GQmo44b6/T/ Vv7zY9UCk1OWISNXeTmCNryv8OsaGzcemvFBeEjW0socHprMMgsF2TgYQeAwhkSJ7rmC phAGWkWxpcglWdbWJHEFtNKcnB35M5cudBzPQKm70CqbH0BIVp0bBkBXIpv52R0PBH0z 9SvZPcXzH8a1wxP3ChS828NM7K8s7sX/oNo5r319+mgKXKMU1Y/nbvjDyxA5ZedIEeGx vb+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729276793; x=1729881593; 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=GWz3IDfZkv8mUSaTED6HeCh+NfgGbCeSvdWGpFVpBBA=; b=Q2QH+zwK0yWvJ43i5HOKBNpITJQpPQLDrjas5AOZ9cSpW4kLVv8Dz/V2Wr9mVzsc2f 2O9p+883kJM7+HWYfwp2EB8HqqegMw+NpR3OLJjX0jIJeHzM5Pcf5Md7WdMQrvJdI0/M pBwvizK3gmFrDaRJ17+8x9FJAXItM7etY+NlI6QAOhkzc6LFZD8TTMYBo4MIyOkRPgCg dbr1KkSxPTkGH7p8Z49irVlzipEanKUB28nSSjlUax8DDzy5P2uaR+4Nj5JX2wLIIxbr IJSjqcMKc8jv0ZgnGa3F0HB0z/OcaG0CNgj2uZOa7XAoefqNF4EsDg5Fh0Qnv8k39tWx iD6g== X-Gm-Message-State: AOJu0YxCRH4HVvlDUhhXGHpTDSUyi5XB3SIWs6SSB9TJIvBw72qov5we AKBuBnhLlFOm09M6GWGKoCwh/lYoBUJB1CtDWExkxXeKG5RrqyxlWX06Ue5k1LbWoZi0BtkTS60 t X-Google-Smtp-Source: AGHT+IGFbNnE4RlllvoK21FrFJpJZSsqLWpCtuwcWrJVqcgo6/5wygdbYNhkH0wb5KJdeTOrKQPWbQ== X-Received: by 2002:a05:6e02:1b0d:b0:3a3:94c5:e178 with SMTP id e9e14a558f8ab-3a3f40c2b8dmr27385035ab.26.1729276792881; Fri, 18 Oct 2024 11:39:52 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dc10c2b424sm534387173.98.2024.10.18.11.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 11:39:51 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 1/4] io_uring/uring_cmd: get rid of using req->imu Date: Fri, 18 Oct 2024 12:38:23 -0600 Message-ID: <20241018183948.464779-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018183948.464779-1-axboe@kernel.dk> References: <20241018183948.464779-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's pretty pointless to use io_kiocb as intermediate storage for this, so split the validity check and the actual usage. Signed-off-by: Jens Axboe --- io_uring/uring_cmd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 39c3c816ec78..cc8bb5550ff5 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -211,11 +211,10 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) struct io_ring_ctx *ctx = req->ctx; u16 index; - req->buf_index = READ_ONCE(sqe->buf_index); + index = READ_ONCE(sqe->buf_index); + req->buf_index = array_index_nospec(index, ctx->nr_user_bufs); if (unlikely(req->buf_index >= ctx->nr_user_bufs)) return -EFAULT; - index = array_index_nospec(req->buf_index, ctx->nr_user_bufs); - req->imu = ctx->user_bufs[index]; io_req_set_rsrc_node(req, ctx, 0); } ioucmd->cmd_op = READ_ONCE(sqe->cmd_op); @@ -272,8 +271,10 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, struct iov_iter *iter, void *ioucmd) { struct io_kiocb *req = cmd_to_io_kiocb(ioucmd); + struct io_mapped_ubuf *imu; - return io_import_fixed(rw, iter, req->imu, ubuf, len); + imu = req->ctx->user_bufs[req->buf_index]; + return io_import_fixed(rw, iter, imu, ubuf, len); } EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); From patchwork Fri Oct 18 18:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13842202 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) (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 19EDA20010F for ; Fri, 18 Oct 2024 18:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729276797; cv=none; b=maf0BnHdhEuXidEPhLf6Mj69iAvA7zmCf1lCMc6K5W8q0CLzMLnMUSJB3jE8x6/qyXTiYMEtXO8uIagtpn/hKncBxIFFwD3gcOfNjN/efPuN5Uj5VvqqBKC6xLOwiHkT7OmeliPItq7zosTtLy2qomcmTIdgCx3HhmPdhHN7Hcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729276797; c=relaxed/simple; bh=oDiF+iJtDAqOQFD3zFbOwHq1eNByLNSUH9pNke+Mbqg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ptsesDQqWc9UZjroMXqnKJATXTKXR5VittMk63RyAdchYot8w+WqnUyhKmUT0vhVdQ9Tc1G11iVnLIvZOes2fbLNgo9QhDerxqebwNDCcSi9ym5HnHe0LK/ot50Beo2vX6ICtuW27C+2JgJfWpQGHxAtNUnmcrXHco0UHNktsaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=aymWDjLB; arc=none smtp.client-ip=209.85.166.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="aymWDjLB" Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-83abcfb9f39so29311639f.1 for ; Fri, 18 Oct 2024 11:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1729276795; x=1729881595; 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=q7q/V2BhkWsb+BFpGXBB0cov0CmL9fUYlsdRBSuHeDA=; b=aymWDjLBY9xbynZRL44UFHOivgzw/WcbA9KKxiVzt1qwf40lL5HMR1W2bXjNx4M75g cMyyCCJ5QfaPi+4eng9ksN0vzAY72jsrUbtrNqV6v1eX5dTjrnTL2GMROsmg7uORk04v UFjlYNqVDFOf8JFS/ZNfyfVktCEa0lbBzJT77jDtQXZpS7kBdvRfwSzGqrV6IYsL+2jc aV5OwD79wp9mdvpg4BnnI/A3EbKNBsgwUABLgWCfd0W99zTvR0dfcNia/ocY8EVsUej3 epRPz5DZ0TcCkPCCn9o7zVxcqne8+jrswmYc4f+gHSl1/gGUtxmkTZRMaKD5nGw7LqPA 1HTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729276795; x=1729881595; 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=q7q/V2BhkWsb+BFpGXBB0cov0CmL9fUYlsdRBSuHeDA=; b=AQZQgFw4/7SVadV0fb/KCeqLWLpESintReiSP/Hx0EbkYNl7toV0IjhYMab7BcLc6Z T8nuEzGKcrt8oZakG9kmxpNp/N3SfbX3kk4on4lwliJaQiOO+5v3UGd0zhmR/Na3ZaPi fG86Gd6TAsEIgAAt1W7n1LXqMpUdjlr9RQSKXm+LAgXUm6OS9xtWsN+j9GWTU9cB893/ L2Eg/qBLfPaf5ZZm1+lF9D8BHf0ZtLa4tSU1Heq8gkpqvJWa/FKoMw01YIwSyblFOE7C gsNiffFVNy0inWGY3RN4LfBzKi1HO02QMzaLNdKdN55h5lSO9AQwVa4JBMFmWNGv2LAo /J/Q== X-Gm-Message-State: AOJu0Yyswul4NDo2pszW9MJlojy9G4p8ATDUs4QDGjdIzZjzimZOYb8s cnR7nEBpcEAFkav854oIQmAlhKPUyxxnVSjNsmIBo8rTc3/Lr63aK+Azu91f54XMl87A0kmq4mz t X-Google-Smtp-Source: AGHT+IG1qDIBH5L8exVsDybEl+2Z2uvKYa/R1rK8kP9CHuO2B2iM7dZP2AffdUaieMvE8GZ+ClzMHA== X-Received: by 2002:a05:6602:164c:b0:83a:b83a:bfa8 with SMTP id ca18e2360f4ac-83aba992f83mr211872739f.6.1729276794765; Fri, 18 Oct 2024 11:39:54 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dc10c2b424sm534387173.98.2024.10.18.11.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 11:39:53 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 2/4] io_uring/rw: get rid of using req->imu Date: Fri, 18 Oct 2024 12:38:24 -0600 Message-ID: <20241018183948.464779-3-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018183948.464779-1-axboe@kernel.dk> References: <20241018183948.464779-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's assigned in the same function that it's being used, get rid of it. A local variable will do just fine. Signed-off-by: Jens Axboe --- io_uring/rw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/io_uring/rw.c b/io_uring/rw.c index 80ae3c2ebb70..c633365aa37d 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -330,6 +330,7 @@ static int io_prep_rw_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe { struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw); struct io_ring_ctx *ctx = req->ctx; + struct io_mapped_ubuf *imu; struct io_async_rw *io; u16 index; int ret; @@ -341,11 +342,11 @@ static int io_prep_rw_fixed(struct io_kiocb *req, const struct io_uring_sqe *sqe if (unlikely(req->buf_index >= ctx->nr_user_bufs)) return -EFAULT; index = array_index_nospec(req->buf_index, ctx->nr_user_bufs); - req->imu = ctx->user_bufs[index]; + imu = ctx->user_bufs[index]; io_req_set_rsrc_node(req, ctx, 0); io = req->async_data; - ret = io_import_fixed(ddir, &io->iter, req->imu, rw->addr, rw->len); + ret = io_import_fixed(ddir, &io->iter, imu, rw->addr, rw->len); iov_iter_save_state(&io->iter, &io->iter_state); return ret; } From patchwork Fri Oct 18 18:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13842203 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (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 C88DA2038D8 for ; Fri, 18 Oct 2024 18:39:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729276799; cv=none; b=Zu7yjqD9h8AwH2wXpnD3GFxRK+szvgjwvBkV4LAFU+eUgxIxkitTDz+Fw58QnZon1B+JBpVSI1O9xXA9TXwdfHZaeT3GAH5X0OYuTiRaGDXRzet/3CxPYOrbujQUOqOp8X9EqcGpSQdYOF/RFwZnrkKbb7U/wDZPc+jnMw/JyQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729276799; c=relaxed/simple; bh=3kYq0C5TWd8rkmdhoT6VK1j4LEkRJ2s4Y0vBsL4z25o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OYmLk9IdnzaOIAIrflIHgsTTrz3JGYSCWC6mDVP6iJHg+ivYAOF1JkvWIBhcAufe70ugYFlrTrXOcZ3VzGO/lRZBJDAwFj0bJg57ULP/11Zf9DcuN6T6QT1dopppEUBSjK0n3Upw3rjsF+kDOGaShDBfmeKJ4v1Ukh6uOjCw3zM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=gq1h6AbA; arc=none smtp.client-ip=209.85.166.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="gq1h6AbA" Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-3a3938e73d3so9696855ab.1 for ; Fri, 18 Oct 2024 11:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1729276796; x=1729881596; 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=fPVCm1Xor1/HRTQ9izeciEoHtF5Hj038MRohwzPQcik=; b=gq1h6AbAMEzgJZlsOaafOZH671wMowke70uS8hefy8mXCfHRCg7kLbhFGlit8Jm7it XbcBIwWl2ZKy+NmkUEaWysTiwObBepnDqU7j7fD8f5jxieLdmTOSV40+lCdpCq7j4XZz rn4RXMun1k1o+x4BlFh4d43LlNNQ88Dj87ynk9Zs1f9/ayZRNR0bizRRLCqZzqtL/66B yLn41IUX7NAWMGpSLbDnUcJJVd3t39C//4rMeH/6YHu1OxHkpQe331Kh4HWsbc62qtNi GB2f+oenD3QcLcYgPVI5ptMkhfZz/hvOB+EOTp0UW3WLNbSyTgVr4YiwevGp6N/DD8AL UMKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729276796; x=1729881596; 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=fPVCm1Xor1/HRTQ9izeciEoHtF5Hj038MRohwzPQcik=; b=EhzSWK7goS7lNEUBgiZlJkScZABBghYfA525GHek3DLb/XBxfVCfJzYaGff1snq47M f6TRyqhad/QFS/lVF07ypZ3vnDRmcDsaTl9z7CIyLkEoXR783tOVQOWpn+NNMJNDp2Ml ymI65RXgWaZU6ROp8rdxL9gsACmil6Y+VxiVfmS4piyddyR8WFsTjNII0i0TOYODbDML kwn4HUZZjfAnIhdE4rEnV48INIbnqE3IpqIgCL+i0FL38lmM4QgTCKEvRtT0zaN1xtm8 nNcLJ/jkIZ/5LWRetb4iNvaTJArzxcMlsGoH58RklKjS49h+xuSJ2ULZ/YW/zTY2zDZi YXQg== X-Gm-Message-State: AOJu0YwtVB33l95HF7Bd0GmPQ1sZ7hAU1XNwMNfBTzOy9EVdCnOkpzvd pxGRQRP/igSeVy+LUloVPcHL6D/BX2ncVmQy1XT7kwVHIr30zvHW9pbUQqpf8z6Wq1OllDNl3p5 X X-Google-Smtp-Source: AGHT+IHoicl9s8LUSowgRtGN9Vey7K9X1wQzlYyjqJXBM910/DOBRrC16dNryWAz9d+Cx0dYE929Hw== X-Received: by 2002:a05:6e02:20cc:b0:3a0:bd91:3842 with SMTP id e9e14a558f8ab-3a3f40b1184mr35295875ab.24.1729276796354; Fri, 18 Oct 2024 11:39:56 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dc10c2b424sm534387173.98.2024.10.18.11.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 11:39:55 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 3/4] io_uring/net: move send zc fixed buffer import to issue path Date: Fri, 18 Oct 2024 12:38:25 -0600 Message-ID: <20241018183948.464779-4-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018183948.464779-1-axboe@kernel.dk> References: <20241018183948.464779-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Let's keep it close with the actual import, there's no reason to do this on the prep side. With that, we can drop one of the branches checking for whether or not IORING_RECVSEND_FIXED_BUF is set. As a side-effect, get rid of req->imu usage. Signed-off-by: Jens Axboe --- io_uring/net.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/io_uring/net.c b/io_uring/net.c index 18507658a921..a5b875a40bbf 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -76,6 +76,7 @@ struct io_sr_msg { /* initialised and used only by !msg send variants */ u16 addr_len; u16 buf_group; + u16 buf_index; void __user *addr; void __user *msg_control; /* used only for send zerocopy */ @@ -1254,16 +1255,6 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) } } - if (zc->flags & IORING_RECVSEND_FIXED_BUF) { - unsigned idx = READ_ONCE(sqe->buf_index); - - if (unlikely(idx >= ctx->nr_user_bufs)) - return -EFAULT; - idx = array_index_nospec(idx, ctx->nr_user_bufs); - req->imu = READ_ONCE(ctx->user_bufs[idx]); - io_req_set_rsrc_node(notif, ctx, 0); - } - if (req->opcode == IORING_OP_SEND_ZC) { if (READ_ONCE(sqe->__pad3[0])) return -EINVAL; @@ -1279,6 +1270,7 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) zc->buf = u64_to_user_ptr(READ_ONCE(sqe->addr)); zc->len = READ_ONCE(sqe->len); zc->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL | MSG_ZEROCOPY; + zc->buf_index = READ_ONCE(sqe->buf_index); if (zc->msg_flags & MSG_DONTWAIT) req->flags |= REQ_F_NOWAIT; @@ -1339,13 +1331,24 @@ static int io_sg_from_iter(struct sk_buff *skb, return ret; } -static int io_send_zc_import(struct io_kiocb *req, struct io_async_msghdr *kmsg) +static int io_send_zc_import(struct io_kiocb *req, unsigned int issue_flags) { struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg); + struct io_async_msghdr *kmsg = req->async_data; int ret; if (sr->flags & IORING_RECVSEND_FIXED_BUF) { - ret = io_import_fixed(ITER_SOURCE, &kmsg->msg.msg_iter, req->imu, + struct io_ring_ctx *ctx = req->ctx; + struct io_mapped_ubuf *imu; + int idx; + + if (unlikely(sr->buf_index >= ctx->nr_user_bufs)) + return -EFAULT; + idx = array_index_nospec(sr->buf_index, ctx->nr_user_bufs); + imu = READ_ONCE(ctx->user_bufs[idx]); + io_req_set_rsrc_node(sr->notif, ctx, issue_flags); + + ret = io_import_fixed(ITER_SOURCE, &kmsg->msg.msg_iter, imu, (u64)(uintptr_t)sr->buf, sr->len); if (unlikely(ret)) return ret; @@ -1382,7 +1385,7 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags) return -EAGAIN; if (!zc->done_io) { - ret = io_send_zc_import(req, kmsg); + ret = io_send_zc_import(req, issue_flags); if (unlikely(ret)) return ret; } From patchwork Fri Oct 18 18:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13842204 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 8A12320010F for ; Fri, 18 Oct 2024 18:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729276801; cv=none; b=TyP0+NdacmyOhDSqtdwbzk7YaqabKvYkjqM0CNGQQ1Onw06d44Y/TYpco1vN3LrJ688EE7rRKHnzCTKzW0a24RuuMSJNKbmEsmxC8SxEODVuVD5qPxmuVGcu1lPYc2xjWCLqkjxQ8uYN6wPLSc1OAgPGiWhw42NwOWo+u0Qo6gI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729276801; c=relaxed/simple; bh=gAOYuzdKVb6Mk7SD8XmfAHuM3EAk/c+NAqW/Rv2R8Lg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UYz6uNbzp1KJZcX/lIwt0BIEO4Du3o60llfxdQcrvq0xKFJJfcSg533UlcFXryAuvi0UCl/h2fWQ0+IY3WB1ks+TLOR2KGUaQGKmoaf0QLU9U13xTMWoJDhxJKAoqFhhND8+l+6Bq0Iru2veZUzDBAdu3a2K/CXjHNZxoDTltwY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=pv0stGs8; arc=none smtp.client-ip=209.85.160.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="pv0stGs8" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-288d74b3a91so1471062fac.0 for ; Fri, 18 Oct 2024 11:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1729276798; x=1729881598; 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=DKm19nf0wk6JSqYXMnkKhRXK7xTl4qYDr26LOfOqa+4=; b=pv0stGs8ySRBM2far5k5xk6Mv3IMTX6wdTov73tXVtfWjTmS/XiOn4ErU+kuRwGaXt gSccB+wtnVSULxCr9yZzOayeTdj8cMsFuKTqRga9wikO7zwewDHU5808Yz9Y7maPS0Ia ljtlD1iurf59J5DahPjrNpB0/W0FFEJvc/4+4NJaLTCxdNJuyvZSdlnxrYejfepywC/e 3H5Q1JSWBBFUos7ReMkgMukwfQID2WDrjtPAksxikJWZOW3eT6NZJh6WmHXSsWRBvVOK ExEbU75gD3uGGAhdQ7u/0791sTARPRHyD1HpGRvty2pi5Is5OVM4Fhd8tiAjeMe8RIVB xa/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729276798; x=1729881598; 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=DKm19nf0wk6JSqYXMnkKhRXK7xTl4qYDr26LOfOqa+4=; b=RkPXtg2imsVsn6IxAI24BslfFOMn4Ow4962zD9Q9N8s3jceZeeY2GFjXYvzWd+gEA0 ENsQOd1FCm+dGCRPMfxiOk65NDcaQigtx2ipZrjED+SgDo1oZ/iKy1yTlmdOugnzV2VK fbJ47MHi/egQKxqM7cHL2TCRO5bfn/alz8NsHXHzuPTWCbEVdUttna1XdIqPTXBF0+gs YQNO+XMTLibk2qbvyuf4LcPfrVFaFiBd4+31BOZC89nEnw/uVcZaMggybe96HQ4leCeY FOxxnMJ01KhZHivjzPP8P2fAkJ9uYJJ7/hWqf/GCDGhWyjJYPoT8Lvyu3QBqxvXVoi/N IJLQ== X-Gm-Message-State: AOJu0YxgvE7kU8iVlOkBjWvikmRyz5fPNWich8s2CzQW5TUyGipQeav0 TlVWTL2+AMYutGgSyvIdpW7zyUjjlbWdncLp0IUE0+YDN+HZAid7cDixjt5IgKOIANcfA8jYDWz 2 X-Google-Smtp-Source: AGHT+IEigix2KgJ0ZA4NssLWW2DQY5CahrFtylwPNlPJ8Qap0Y3CBlFjxWxAofyEE71Xjgv0HLp2Lw== X-Received: by 2002:a05:6870:9689:b0:277:bf1c:da4a with SMTP id 586e51a60fabf-2892c546dbfmr3277405fac.45.1729276798166; Fri, 18 Oct 2024 11:39:58 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dc10c2b424sm534387173.98.2024.10.18.11.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 11:39:56 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 4/4] io_uring: kill 'imu' from struct io_kiocb Date: Fri, 18 Oct 2024 12:38:26 -0600 Message-ID: <20241018183948.464779-5-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018183948.464779-1-axboe@kernel.dk> References: <20241018183948.464779-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's no longer being used, remove it. Signed-off-by: Jens Axboe --- include/linux/io_uring_types.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h index 9c7e1d3f06e5..ae42f819c287 100644 --- a/include/linux/io_uring_types.h +++ b/include/linux/io_uring_types.h @@ -613,9 +613,6 @@ struct io_kiocb { struct task_struct *task; union { - /* store used ubuf, so we can prevent reloading */ - struct io_mapped_ubuf *imu; - /* stores selected buf, valid IFF REQ_F_BUFFER_SELECTED is set */ struct io_buffer *kbuf;