From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EA1B1AC248; Wed, 5 Jun 2024 12:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589158; cv=none; b=RhXcGXUEgoJ1pllzTPTlzhlF81Zo5+r5bAnky6ufqyBQy2zC6rRYTLIiD6rtley19JFcgC9FbVYZ9diSY35N9OGGBzQz7AQjE1ASHEvyRgMqNFFShPcLV0+rJyaHiLzAIcLtiPadGnYv3gi9i3/4bEaq4CbMDA/amonGQERstf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589158; c=relaxed/simple; bh=B/Kutg+Sc8171faSQp8DlnnumHtFGil0wSZIzhksY/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tY8szvgrgWFOsSxE0bJLmkEWs67TKAjmxzfVzPyox5MCor5Kyj0UMiDIhqY2Yldp7fRWp2GIIL3O37NJq9rlwjNbB3eBSmrM27QwzP0KWbLUk5CjjcRjGe5QSmRpI1Bvug29YuZPBlKUnBSe+mGDbgzXlIwJJeUWWsy+7fcFwNQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bzsJ5gRF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bzsJ5gRF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03E37C32786; Wed, 5 Jun 2024 12:05:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717589157; bh=B/Kutg+Sc8171faSQp8DlnnumHtFGil0wSZIzhksY/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bzsJ5gRF3/BqLhFw6iq1HjSzqbVUOIKnmU3d1I+guxmDl4nIhv3Zw7otHJMXVWmOp 1Yr3SZHyThZzxV9Ci9ayoLhenkWplqd8jupWRM59pQpkIdNStJSi5gHQmfZO5YrygC FHkIqO6iri2L+CNwon62tXEI/CoHyR2UTtJtf+e4L+4GsC7byz0aTdKgsME3URoNKK k8ScYI/EqxKDDNXvjDfS8U3Qs2nSaG8AFgcxQQPVlus+41kABGXqSMzZqQ6dE35buE Bf4Nn2/lVx5O+LKJU/mRUsGPc1k0dWHsrmECua+n8sK5e+lOp0DG48BtQtXVQW+oIo vV+wMM6/TZGeQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kundan Kumar , Christoph Hellwig , Sagi Grimberg , Keith Busch , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 2/8] nvme: adjust multiples of NVME_CTRL_PAGE_SIZE in offset Date: Wed, 5 Jun 2024 08:05:45 -0400 Message-ID: <20240605120554.2968012-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120554.2968012-1-sashal@kernel.org> References: <20240605120554.2968012-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.218 Content-Transfer-Encoding: 8bit From: Kundan Kumar [ Upstream commit 1bd293fcf3af84674e82ed022c049491f3768840 ] bio_vec start offset may be relatively large particularly when large folio gets added to the bio. A bigger offset will result in avoiding the single-segment mapping optimization and end up using expensive mempool_alloc further. Rather than using absolute value, adjust bv_offset by NVME_CTRL_PAGE_SIZE while checking if segment can be fitted into one/two PRP entries. Suggested-by: Christoph Hellwig Signed-off-by: Kundan Kumar Reviewed-by: Sagi Grimberg Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 5242feda5471a..a7131f4752e28 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -844,7 +844,8 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req, struct bio_vec bv = req_bvec(req); if (!is_pci_p2pdma_page(bv.bv_page)) { - if (bv.bv_offset + bv.bv_len <= NVME_CTRL_PAGE_SIZE * 2) + if ((bv.bv_offset & (NVME_CTRL_PAGE_SIZE - 1)) + + bv.bv_len <= NVME_CTRL_PAGE_SIZE * 2) return nvme_setup_prp_simple(dev, req, &cmnd->rw, &bv); -- 2.43.0