From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 D1CC737E8F7 for ; Thu, 21 Aug 2025 20:08:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755806922; cv=none; b=bIicJiUDxX9cHYWoXB1iDZpVzn9+Q9EQKNniO7trFforPaac7Bmv3DtDk8lPXAILTBPfzpGhMTBbSqOtNApNC25V7YZBuSqC7+qPlSvEdTc9bIf4xO+znaKCh/QIpvkg9yA8/dfPSRnFZIChXzTncVGCmLw5uQ6gamncimkEsE8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755806922; c=relaxed/simple; bh=I4BkP0poqeOVnf4Ccw0GJyYkhfaxRMDSlYagPRdC1UE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=adcWcRo+NWxQRpX0hM39TOojemg6TlTltIlp+ySpkSdAzpIYQNNSfupVX08uYFObAgkAFap6jSapf/vqdNO3CKD2DVWbQAesMrVvlMmO9JFjb/x07ZirtmtLiNZx4+RuMcbWrbQmMRQaf3ToGKpHbetrTmai23klhOMQzPVwnRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZPTZ1a7y; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZPTZ1a7y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1755806918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3CqHI+s+zbpAzQhGC/xWDVPQsQNUZt86Ikrf9EwImgM=; b=ZPTZ1a7yBN7KvuzGfvzjt4ms5jvmv7IqzrkeqD7qIbQchOr5sViG0dxt5Bgy8+T7fuNLpu 30OKGZioliSDOiRpRsLP3J4V6OrJgVUscGgB9x8PCCutwuNXueQXhL915WHJh97EWdN/V3 +aK5J8gx+BYPrFfNfady8GCHJGkkCH4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-364-4skufD65MxSdW4ceJtYGxw-1; Thu, 21 Aug 2025 16:08:36 -0400 X-MC-Unique: 4skufD65MxSdW4ceJtYGxw-1 X-Mimecast-MFC-AGG-ID: 4skufD65MxSdW4ceJtYGxw_1755806915 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45a1b0cb0aaso10745075e9.3 for ; Thu, 21 Aug 2025 13:08:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755806915; x=1756411715; 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=3CqHI+s+zbpAzQhGC/xWDVPQsQNUZt86Ikrf9EwImgM=; b=ZDqXtgcacuAnb8Ek4FZv4R+QmwIEc8Xn3hucFsZLLqAX4kJrQoxqyrl2u7uYiWO6TE ymiU4q9VQFB/kEEx2HORaQr4jAViObK6To0EPEXR5xpINkh8aWTaaUsXPmovFPF/qmmG fnhelErTs5arNOvI54ddRCU0ZOuyzs0sqOLjYS38GkA8UTY6T9qHonpf9Np9MRWDXUC5 EHZu2RJsoaNAmCncT8Yal0/kVDhVR+t7R2w9NACZpvFvw6yARs6in338t4XURQ2LO3yJ bZogIPUXe+JlQsZn0MHGFoC4OAgf0XdcX9LIXm+AYaRN99fhe/ELHAip3p9Y4xe4kE4h MR2w== X-Forwarded-Encrypted: i=1; AJvYcCXfWGDiDop/UQlETFdxKGiWsqP7f9unrqUeoiB+CDdgfxPbO1cbbTcVGLMoEsSjLQupI+gEE38cbg==@vger.kernel.org X-Gm-Message-State: AOJu0Yw74p97RV9LlnPhI6FTGXyntjozYkMow/OTrs0dKFqnQkrn0VKO rkQ4rvFa1Z+hIWpfazgx4ANojaJoth3O7ofTV7b50lrkHMG3RMh0N+GiNP1wvPsmF6WkWWE8AZp jXjPwpMzxn1KkEAbMAe0uqgHHvH2TmBrxeppyz07zsoKkNV/x+94MoNuEsmE6 X-Gm-Gg: ASbGncuDAJZN0ohha1sdJ/gJ6Wuv7f4uEN2d1L6EWtNV3qWhWCeg7ykr1RYE+qSt+T3 /3ZQfRQEHnCAfek/TEKwVw1N6YwA976LO+6rJIWRl61MES+8vn5z++uGEa5ggqsqhRg0W6RwDNr WIB3w08KqjUPz2MFRwUQWQrQ+2Fk+V/BRP51STdQoA2zXdC5u0K1fU821Qni3QqO6YcWVHwwHfm 9NJjL6F8TYP18fIDsViBGDwkaYB3a58MNHrzYcfdNkTCJuhvbMxrXJ5r01kwrO2TyISikcUXKdY q3qbbSwgzkvg5XkAX4Ha25Q7xF7XG7uW7RAE0PWPwK/xlqQvjTK8xMa7XewH8IpCU3Ejh4ipnwy KPtnqh7QuFVOISsrHLOlb1Q== X-Received: by 2002:a05:600c:1e85:b0:456:1006:5418 with SMTP id 5b1f17b1804b1-45b5179f0d8mr2711105e9.13.1755806915077; Thu, 21 Aug 2025 13:08:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNGUbCcltH4em232KOd7NJpwM5baGf2Rerwczj+dvqvR7jiogPR9NbFTOrLGPDkQDJL8nGzQ== X-Received: by 2002:a05:600c:1e85:b0:456:1006:5418 with SMTP id 5b1f17b1804b1-45b5179f0d8mr2710565e9.13.1755806914568; Thu, 21 Aug 2025 13:08:34 -0700 (PDT) Received: from localhost (p200300d82f26ba0008036ec5991806fd.dip0.t-ipconnect.de. [2003:d8:2f26:ba00:803:6ec5:9918:6fd]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3c074d43b9asm12707153f8f.24.2025.08.21.13.08.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Aug 2025 13:08:34 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: David Hildenbrand , Herbert Xu , "David S. Miller" , Alexander Potapenko , Andrew Morton , Brendan Jackman , Christoph Lameter , Dennis Zhou , Dmitry Vyukov , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, iommu@lists.linux.dev, io-uring@vger.kernel.org, Jason Gunthorpe , Jens Axboe , Johannes Weiner , John Hubbard , kasan-dev@googlegroups.com, kvm@vger.kernel.org, "Liam R. Howlett" , Linus Torvalds , linux-arm-kernel@axis.com, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-ide@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mips@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, Lorenzo Stoakes , Marco Elver , Marek Szyprowski , Michal Hocko , Mike Rapoport , Muchun Song , netdev@vger.kernel.org, Oscar Salvador , Peter Xu , Robin Murphy , Suren Baghdasaryan , Tejun Heo , virtualization@lists.linux.dev, Vlastimil Babka , wireguard@lists.zx2c4.com, x86@kernel.org, Zi Yan Subject: [PATCH RFC 31/35] crypto: remove nth_page() usage within SG entry Date: Thu, 21 Aug 2025 22:06:57 +0200 Message-ID: <20250821200701.1329277-32-david@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250821200701.1329277-1-david@redhat.com> References: <20250821200701.1329277-1-david@redhat.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It's no longer required to use nth_page() when iterating pages within a single SG entry, so let's drop the nth_page() usage. Cc: Herbert Xu Cc: "David S. Miller" Signed-off-by: David Hildenbrand --- crypto/ahash.c | 4 ++-- crypto/scompress.c | 8 ++++---- include/crypto/scatterwalk.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crypto/ahash.c b/crypto/ahash.c index a227793d2c5b5..a9f757224a223 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -88,7 +88,7 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk) sg = walk->sg; walk->offset = sg->offset; - walk->pg = nth_page(sg_page(walk->sg), (walk->offset >> PAGE_SHIFT)); + walk->pg = sg_page(walk->sg) + walk->offset / PAGE_SIZE; walk->offset = offset_in_page(walk->offset); walk->entrylen = sg->length; @@ -226,7 +226,7 @@ int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc) if (!IS_ENABLED(CONFIG_HIGHMEM)) return crypto_shash_digest(desc, data, nbytes, req->result); - page = nth_page(page, offset >> PAGE_SHIFT); + page += offset / PAGE_SIZE; offset = offset_in_page(offset); if (nbytes > (unsigned int)PAGE_SIZE - offset) diff --git a/crypto/scompress.c b/crypto/scompress.c index c651e7f2197a9..1a7ed8ae65b07 100644 --- a/crypto/scompress.c +++ b/crypto/scompress.c @@ -198,7 +198,7 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir) } else return -ENOSYS; - dpage = nth_page(dpage, doff / PAGE_SIZE); + dpage += doff / PAGE_SIZE; doff = offset_in_page(doff); n = (dlen - 1) / PAGE_SIZE; @@ -220,12 +220,12 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir) } else break; - spage = nth_page(spage, soff / PAGE_SIZE); + spage = spage + soff / PAGE_SIZE; soff = offset_in_page(soff); n = (slen - 1) / PAGE_SIZE; n += (offset_in_page(slen - 1) + soff) / PAGE_SIZE; - if (PageHighMem(nth_page(spage, n)) && + if (PageHighMem(spage + n) && size_add(soff, slen) > PAGE_SIZE) break; src = kmap_local_page(spage) + soff; @@ -270,7 +270,7 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir) if (dlen <= PAGE_SIZE) break; dlen -= PAGE_SIZE; - dpage = nth_page(dpage, 1); + dpage++; } } diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 15ab743f68c8f..cdf8497d19d27 100644 --- a/include/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h @@ -159,7 +159,7 @@ static inline void scatterwalk_map(struct scatter_walk *walk) if (IS_ENABLED(CONFIG_HIGHMEM)) { struct page *page; - page = nth_page(base_page, offset >> PAGE_SHIFT); + page = base_page + offset / PAGE_SIZE; offset = offset_in_page(offset); addr = kmap_local_page(page) + offset; } else { @@ -259,7 +259,7 @@ static inline void scatterwalk_done_dst(struct scatter_walk *walk, end += (offset_in_page(offset) + offset_in_page(nbytes) + PAGE_SIZE - 1) >> PAGE_SHIFT; for (i = start; i < end; i++) - flush_dcache_page(nth_page(base_page, i)); + flush_dcache_page(base_page + i); } scatterwalk_advance(walk, nbytes); } -- 2.50.1