Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp271287lqr; Wed, 5 Jun 2024 05:51:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBOHasnsJvg2O6OlPvpk/9RGIt7pEgwWKhFheD+7rIKSEageas9TjyfjBoCSkcykRVDkm1MaMCckcQ4oVWlQRWCasPPx2dMuhOdy8Cag== X-Google-Smtp-Source: AGHT+IH1w4IgbwRjB/286KOiolzGEjyqkhK5X4OEsfsRHwCSla5AWwzdYisHUkEHGbzRmF4q2OR9 X-Received: by 2002:a05:6a20:4315:b0:1b1:ec17:ad81 with SMTP id adf61e73a8af0-1b2b6f95729mr3151510637.29.1717591911046; Wed, 05 Jun 2024 05:51:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717591911; cv=pass; d=google.com; s=arc-20160816; b=SqjYY7+Buhg7DKpLufdj87Vrbnodzp5XlbPrd4JynozCpOpCm+o3LfJ0eK37/KGlQk cT6VGGfiARved9ZWvSBwE4sQi4244BjYYXj1peZ3eJezZBS6Io/Mj849pJJa5fr85GmD tby9Jf8w8yNipXI8ZsRDK2inlLb7r/gHyn5Aq5YPA4Hhum9Oj3NWMUvBc7gA936a2zK/ jYY7lCjFKW2lSfHINfSfPl48IchIUZr7k8NKFS9AP1uMXymS++TEHPdzWe2vM44UjiUA umkHAhwvGS22oFH1shlyiDkUSMLWOazP6v4w4uWCYHsEqmbZwZZLcrIDFBW7TmQPhgB2 AOdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iK1QR9QRNu7essXbpC7l6LN0JKBlZFz0AM4HitaxnOw=; fh=0xlhWeNsbpDajxhlANqJWsffL60tt8YhkJggqZ/rlFo=; b=c+Nu3rBwJ1oFroG3//EaspCXFyINNsHuY/j5C7v7FHhS+2q1RpwXc/TiJXr7z4NooI ZFmRGoJYzxIl01MRs/k1UHlVMHfXPRvK8x+kwr1hgNfnCQLntit/zxqkciXevVtpcqJ3 IqYouyPaDgCzpGbq6JJ9Z0J7oUapzmqjpDlFxO+wWgUYmgNYhcthHYTRFHGGeYirkuQc 6cor94iM6srYTg5H/eMMXdJPtlXB7JIECI0DSey6H5l1HEPzWTGzCoWhQnos3LGVffu0 DPCzJCF2MDsU8wd0l5T8M13w5/3VR27ir60EEgHpHqgY0W8hUyP5JVUHfU1yG37ILsTP S21g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xjphsm3u; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202457-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c359e09775si4030624a12.268.2024.06.05.05.51.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:51:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202457-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xjphsm3u; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202457-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 221B5B2396E for ; Wed, 5 Jun 2024 12:29:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E121919D075; Wed, 5 Jun 2024 12:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xjphsm3u" 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 1185D19D060; Wed, 5 Jun 2024 12:02:32 +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=1717588953; cv=none; b=e9lQxS8lwVj/86/Le5uxU1k7QsMOnLCDc6ZACtmlv+RKjiq+dRbAXenGDqb4DUhBhWLWQS9bOjv+FaDJHBiGuqckvaWA7WuDWVrjEiPLrlUDjZEd8xpGNvm8SYEw4fRSYawtb0fy1XbdEgKid5N+jmMVwnTJpijO5pXfMFlK1Mg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588953; c=relaxed/simple; bh=EpcOa/PoeA1uayk+/SDygq1AbB+riunm58LMI5D8cdI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O+gX4w/MGEh84QMZ5rsSk9/VYs/m4SOElCwXjLSGDeYQiAQ5TonKTviPDmqe9LlzCojTYvN9e3WeIi+qb6a5hWuGDTrULQYbQIWwYmuZ8Dox+6mkoR0objx9zoPpdi+L4ksmi9qf3+3DOUbhg4Uo6aNN4Z6cylC3e7eb0H9FE14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xjphsm3u; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA7B1C3277B; Wed, 5 Jun 2024 12:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717588952; bh=EpcOa/PoeA1uayk+/SDygq1AbB+riunm58LMI5D8cdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xjphsm3uG44XfvsRvRIhwDFEbL3pWL8vUD+YuuwaOy2QCxoYYcGeE9oyImw/5+0C/ 5B1x1mrzd3dT1PjpBEa2+aYWS3Z3YLvt/OU3IwVA3eQDRE12Tv4Oxnicgt5sFmQMrc sS7kBxCucoCwERMYv4QnrNqB6Y6XbK8vr3a3OZTu4Wfh+olnO+6lMIGcGpi5XpdQJ0 M4EW2QC3qNtxH5vAPLLVw8OSCWwOJoCp/1NVPgsb8HkqB6cHV+13gukus3RiQHhU5F BUESO8dsKIjxGmC5Cbs883Nun33msBuvDDO1DWQhwbcNDmhMSHfSeF0uxKQ6cGszzO LgMiyXWT83b7g== 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 6.9 06/23] nvme: adjust multiples of NVME_CTRL_PAGE_SIZE in offset Date: Wed, 5 Jun 2024 08:01:49 -0400 Message-ID: <20240605120220.2966127-6-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120220.2966127-1-sashal@kernel.org> References: <20240605120220.2966127-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.9.3 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 710043086dffa..102a9fb0c65ff 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -778,7 +778,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