From nobody Sat Oct 4 01:39:03 2025 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 9EC5937E906 for ; Thu, 21 Aug 2025 20:08:40 +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=1755806923; cv=none; b=intKEHNB9Op2jR8PBV6mXDUz+WEAWXqS7NDpulV63TiN/4aR5hns2B170t16H/cKhe5ESVIiLxnFq71p/z2UkOvK9ybtiNVK51cbYnfDX5x11KYYpGKdtIu4W98O/Qjn6mfqvqVKkdurjAyqnpoW8rBtCXqePW2kHQDn5rRflZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755806923; c=relaxed/simple; bh=I4BkP0poqeOVnf4Ccw0GJyYkhfaxRMDSlYagPRdC1UE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LxuW5NlFU9uLzmAjYNRLgUbG2HiWrRXgSfXz6tF7IHTmQURrS12qQEfX8raSFjhQoDaj5xdJgJijw9NiXRHH7+kT/8vVoxqdCqvK0r2OgEVqK0dtm80nfFsPf8KncjcNWoLCnyjk0Z12VV0R2Zm+S1Y6BGG2TrlKkEQhqY8LwyU= 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=YZgwUtvu; 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="YZgwUtvu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1755806919; 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=YZgwUtvu7B8hcKdOyzJ3aFCXvS5VJsSg/0RXF4TDsYMsYa4HYsgMepNtcONST1jI2MeC5s UcQg4FltPxWNIpHg9egMR2dA6RxlLQzCKsx/Opm3TzmZmXIgm/QIlym21cgFO4lpndyEsj zyhvEHgi4LSlLBH1IFxCwRFfrc0M2lM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-hch9CSuSMdqXECaVZ7JRQw-1; Thu, 21 Aug 2025 16:08:38 -0400 X-MC-Unique: hch9CSuSMdqXECaVZ7JRQw-1 X-Mimecast-MFC-AGG-ID: hch9CSuSMdqXECaVZ7JRQw_1755806915 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-45a1b05b15eso10525535e9.1 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=cRct0fJVgMoJtFZzf0uIC0gCZZ/2Dtf9+foOS35NjPusbtqFHb1y3sUy5faRkOel/1 NnIlW6jv/xIBDd68kgqjZ1LYzcT8rD7VpUCiqNyuP1Dxc+XqMFOPL4dRe6XWGjiuRZNH EXjVVMzu000yYHuYpjOERcZADX/KX3h5tl9MjDJN7cJWtckuY0hqBwwOEHpeqgUk/ord I2oEACi8sBkdZBP7IHpfTjdyXu4nAG2TyRKQG23IbiaCV2SczvyXnZE6OeD4RTR7TA74 gsozpBDYQvLmQkt+Ou7xO80qQRu+pjw0WXJTZmXCyG3q7LHkyVrY24zpf4PnIuMRSPJw VpRA== X-Gm-Message-State: AOJu0YyHzTOOu4iZQ+KicDQ6o4rYONax2c7ft0PG1kHuQ7rFz2/gmzx2 uuRwtg/eixCeptthzBmdqMrsF7ZdVu75//IHTa0tUOXxcFN/w7TdKjDn6uagG19FopEWmRaB7MU K3PgZj/pTiJdCVQP4lKAvcAihKbcoJ1mrVQ5kRGlGz/oA7kNlBZNgPyc3etc+C0aUm/BIShcN25 fJG1nSc+EEamlNhn5yMQdIO9xEAt1Rql7G28RnmANHkG6ai4Dp X-Gm-Gg: ASbGncv6bbpYr/6maLUh1mze99c9/Hto+S/sNpe4a3Wp1HBL4EY5Cj0LpSesbqKW1wH aDwop5uHGgq68LJoh4nWsj8HkY4Qj1Ja4qMXS9pmsC3vecaRFSP6ffpEVdxLb+2SXVsUTjm8GY+ FusedTYTGtQLfHMngca5Np/86liOv48Iqptg7BCtsZTL6l87k0BCPZ/vE3egva4HVBDOmjhsNBL gRQN5XD1zKRXTk6NygdRKEtHHcxJRQAJiqgFIXXtJCK1iPreS38AsS3oej9YUz0RcAJR3Hdmgen iNCugVKMgQF8XwZ0YhUl8i2yv4pdpzJm22qHlDkLPXVP3H+NYifjBo8+EvCU5Mv6u+pgkFWi2wH pvjYsJmdXcsrO78KbOaT+Eg== X-Received: by 2002:a05:600c:1e85:b0:456:1006:5418 with SMTP id 5b1f17b1804b1-45b5179f0d8mr2711215e9.13.1755806915174; 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: 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" 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 *w= alk) =20 sg =3D walk->sg; walk->offset =3D sg->offset; - walk->pg =3D nth_page(sg_page(walk->sg), (walk->offset >> PAGE_SHIFT)); + walk->pg =3D sg_page(walk->sg) + walk->offset / PAGE_SIZE; walk->offset =3D offset_in_page(walk->offset); walk->entrylen =3D sg->length; =20 @@ -226,7 +226,7 @@ int shash_ahash_digest(struct ahash_request *req, struc= t shash_desc *desc) if (!IS_ENABLED(CONFIG_HIGHMEM)) return crypto_shash_digest(desc, data, nbytes, req->result); =20 - page =3D nth_page(page, offset >> PAGE_SHIFT); + page +=3D offset / PAGE_SIZE; offset =3D offset_in_page(offset); =20 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 *re= q, int dir) } else return -ENOSYS; =20 - dpage =3D nth_page(dpage, doff / PAGE_SIZE); + dpage +=3D doff / PAGE_SIZE; doff =3D offset_in_page(doff); =20 n =3D (dlen - 1) / PAGE_SIZE; @@ -220,12 +220,12 @@ static int scomp_acomp_comp_decomp(struct acomp_req *= req, int dir) } else break; =20 - spage =3D nth_page(spage, soff / PAGE_SIZE); + spage =3D spage + soff / PAGE_SIZE; soff =3D offset_in_page(soff); =20 n =3D (slen - 1) / PAGE_SIZE; n +=3D (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 =3D kmap_local_page(spage) + soff; @@ -270,7 +270,7 @@ static int scomp_acomp_comp_decomp(struct acomp_req *re= q, int dir) if (dlen <=3D PAGE_SIZE) break; dlen -=3D PAGE_SIZE; - dpage =3D nth_page(dpage, 1); + dpage++; } } =20 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; =20 - page =3D nth_page(base_page, offset >> PAGE_SHIFT); + page =3D base_page + offset / PAGE_SIZE; offset =3D offset_in_page(offset); addr =3D kmap_local_page(page) + offset; } else { @@ -259,7 +259,7 @@ static inline void scatterwalk_done_dst(struct scatter_= walk *walk, end +=3D (offset_in_page(offset) + offset_in_page(nbytes) + PAGE_SIZE - 1) >> PAGE_SHIFT; for (i =3D start; i < end; i++) - flush_dcache_page(nth_page(base_page, i)); + flush_dcache_page(base_page + i); } scatterwalk_advance(walk, nbytes); } --=20 2.50.1