From nobody Fri Oct 3 13:32:04 2025 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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 EE57C2652A4 for ; Mon, 1 Sep 2025 06:12:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756707168; cv=none; b=qGz7DGQFSUBOSv6Cl6jVvQzGRmz09o1/1ZpGzV1VSmKucus+Wwql9qf6Ra8a5QBKKU+YyP38X5TbQag4+ZfwP39QCBFB7eAHOwIRbT4ubaV5P7UZhDJXn93CNh1+U07YXIWijnur+EAArDOsElU0rfflvhUSPzWtXkgZOytJ4ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756707168; c=relaxed/simple; bh=CBcT9NVxAck5kwy48ZHHybF8PPGjkQNkdwo1+D4N+d0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=acItsqgQ3+0X0STDFMR85w8hVAo9950tBD1+JUrU/qEGnhKx0oiaA4ygIAhPwdJp6zoUMfOpzYSby8br4ysmUxu1pFDu1YBIAL8TbWhjpzdM3EceD2jD1laqV+rZ6jCJlI7HUyMP0MrcKm7QQQ9mDAr5gjomHAIUo2LnHivWRW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=Ha12Nbx8; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="Ha12Nbx8" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-61d7b2ec241so1156335a12.0 for ; Sun, 31 Aug 2025 23:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1756707164; x=1757311964; 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=DmXy5ybFdCA4kdt6JbWaWujSYRHDeDjbcsjL0sLonTs=; b=Ha12Nbx8oGBVgWyoqaXafI0SBDboq03pY4f/9GyDdmpLWaxPCO1/NSFlq4/geAuziQ KK8BTl7YsKjOnzwN0hchHAE20XZYzhqDfO3KmuKoJCVJSV6veyoTSpL3gO1osMiXTG4K TVPxMc/9haGqse8Na5Oq5yTZlxf44hw6DlVjTo2FJhzUG/FvLHumdx7wPHeIdzDqan8l LEHEIp7UQhLHxQlNjIUz9K1Jn5eImbF651T92IZ1bp9V0orG93lSxBdMjSVKH7ZY6Jn0 +C2LcdksMVmobgauUPfY5Exu67ZzaFJgCvHfaVJxMxaFencePQN5m/wYeYjXhH7SihQh IibQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756707164; x=1757311964; 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=DmXy5ybFdCA4kdt6JbWaWujSYRHDeDjbcsjL0sLonTs=; b=ZAzYi8pdj7XPqnyyMdktAgV6CQosIeOYfky2XbylHdYxGk7tLQFvAD8DbJxny/O3+F 9wQ1Z25auVfjoo3PCf8ngWK4axxGaVNLj7wGUVKuJEiFiyYiV4Esaib56S6yKHh8JDwO lF52vPcC4ukSCPA28CxSwsAnLctPpU8kA3rkdoxW41+rUKvpBc7I+C6U8T++dFhTmtf1 x6RclgIaeUXwCCIiZvr9JkbmNy6fAMGC53x9uYV0jzrKGzT/9H707hAQcx1zxwPV9Kfx nWzWkPU4LPRZ7QVjpxJLUQqVYizkZdr/MtIGyCQyVVQPEAItzIo8xbCCoZEonNrFCsmQ lXlw== X-Forwarded-Encrypted: i=1; AJvYcCUqjByrOUtJjAnCjVLlnIrWhvrvttMnHX7nk6lusdGYu+/PHCoJs9jXTeS/Rdnqfz1LU3ghgdeawj+1w2E=@vger.kernel.org X-Gm-Message-State: AOJu0YxYPYJPnOowdOTCpi0RDuJbOvMwQ+pM0oD8gHD5Q3Xfi68ypIGK 3bTrH5+704S0u64//s1xwfegoxNvAfNauijjJ7PsQG/H1e1XsuBh4Yhjr9NQT4/CZIU= X-Gm-Gg: ASbGncsV5r7DqRFxvnCPiTIUeG/fpcDkvcA5cP/lR4ximfpZVhs5FKuyKUOA7hSG+qs NhsgzMCV42E/DrwPHKKiP7o/nmDWTqpRrrwn5Ns69mEJ5RtPabn/z1599znwPMi4SymnreQEaoT qMbEFDyaWZsRYuGoJgkB8gkOeDTTZPxn26XZiQQn9wDp6QUwbXnlbk+Ox5lupihrEPd4Fr4Vj/q XP/b7MtENqC2xGMzcqGOZ5sEV3Gidqh4N3voip/qRhk2LXOAUuutTvOJM3CIAIJ7RJbl+JDPRAG 7IJLZkZK1pppiAplFCj2fuwU7vXWflbSqOToaetLomrlZFgVUGTCU+1O/CddLiQweGDXD5lzgms pAbuSpNbPtqqspxaPakY31Sm1gcCbtC+qFraRZ9Gkn3H/hWIXBqXjrvz0sUGXQNRRFvKCir5TGF KR/T2vJ5x2bwn0/dZhn9zUa1UKgq/AnDG0 X-Google-Smtp-Source: AGHT+IGOvhlVbeL/X0mM8+8s766YaG9R11kD+4bMjAZdhRbl7MXM+beHrb1Q0MXfkACExbQP++Cszw== X-Received: by 2002:a05:6402:84c:b0:61d:1327:9f7f with SMTP id 4fb4d7f45d1cf-61d26869fc8mr7090613a12.7.1756707164202; Sun, 31 Aug 2025 23:12:44 -0700 (PDT) Received: from raven.intern.cm-ag (p200300dc6f1d0f00023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f1d:f00:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-61cfc231561sm6374533a12.23.2025.08.31.23.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Aug 2025 23:12:43 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, david@redhat.com, axelrasmussen@google.com, yuanchu@google.com, willy@infradead.org, hughd@google.com, mhocko@suse.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, vishal.moola@gmail.com Cc: Max Kellermann Subject: [PATCH v3 12/12] mm/highmem: add `const` to lots of pointer parameters Date: Mon, 1 Sep 2025 08:12:23 +0200 Message-ID: <20250901061223.2939097-13-max.kellermann@ionos.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250901061223.2939097-1-max.kellermann@ionos.com> References: <20250901061223.2939097-1-max.kellermann@ionos.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" For improved const-correctness. Signed-off-by: Max Kellermann --- arch/arm/include/asm/highmem.h | 6 ++--- arch/xtensa/include/asm/highmem.h | 2 +- include/linux/highmem-internal.h | 38 +++++++++++++++++-------------- include/linux/highmem.h | 8 +++---- mm/highmem.c | 10 ++++---- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h index b4b66220952d..023be74298f3 100644 --- a/arch/arm/include/asm/highmem.h +++ b/arch/arm/include/asm/highmem.h @@ -46,9 +46,9 @@ extern pte_t *pkmap_page_table; #endif =20 #ifdef ARCH_NEEDS_KMAP_HIGH_GET -extern void *kmap_high_get(struct page *page); +extern void *kmap_high_get(const struct page *page); =20 -static inline void *arch_kmap_local_high_get(struct page *page) +static inline void *arch_kmap_local_high_get(const struct page *page) { if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM) && !cache_is_vivt()) return NULL; @@ -57,7 +57,7 @@ static inline void *arch_kmap_local_high_get(struct page = *page) #define arch_kmap_local_high_get arch_kmap_local_high_get =20 #else /* ARCH_NEEDS_KMAP_HIGH_GET */ -static inline void *kmap_high_get(struct page *page) +static inline void *kmap_high_get(const struct page *const page) { return NULL; } diff --git a/arch/xtensa/include/asm/highmem.h b/arch/xtensa/include/asm/hi= ghmem.h index 34b8b620e7f1..473b622b863b 100644 --- a/arch/xtensa/include/asm/highmem.h +++ b/arch/xtensa/include/asm/highmem.h @@ -29,7 +29,7 @@ =20 #if DCACHE_WAY_SIZE > PAGE_SIZE #define get_pkmap_color get_pkmap_color -static inline int get_pkmap_color(struct page *page) +static inline int get_pkmap_color(const struct page *const page) { return DCACHE_ALIAS(page_to_phys(page)); } diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-inter= nal.h index 36053c3d6d64..ca2ba47c14e0 100644 --- a/include/linux/highmem-internal.h +++ b/include/linux/highmem-internal.h @@ -7,7 +7,7 @@ */ #ifdef CONFIG_KMAP_LOCAL void *__kmap_local_pfn_prot(unsigned long pfn, pgprot_t prot); -void *__kmap_local_page_prot(struct page *page, pgprot_t prot); +void *__kmap_local_page_prot(const struct page *page, pgprot_t prot); void kunmap_local_indexed(const void *vaddr); void kmap_local_fork(struct task_struct *tsk); void __kmap_local_sched_out(void); @@ -33,7 +33,7 @@ static inline void kmap_flush_tlb(unsigned long addr) { } #endif =20 void *kmap_high(struct page *page); -void kunmap_high(struct page *page); +void kunmap_high(const struct page *page); void __kmap_flush_unused(void); struct page *__kmap_to_page(void *addr); =20 @@ -50,7 +50,7 @@ static inline void *kmap(struct page *page) return addr; } =20 -static inline void kunmap(struct page *page) +static inline void kunmap(const struct page *const page) { might_sleep(); if (!PageHighMem(page)) @@ -68,12 +68,12 @@ static inline void kmap_flush_unused(void) __kmap_flush_unused(); } =20 -static inline void *kmap_local_page(struct page *page) +static inline void *kmap_local_page(const struct page *const page) { return __kmap_local_page_prot(page, kmap_prot); } =20 -static inline void *kmap_local_page_try_from_panic(struct page *page) +static inline void *kmap_local_page_try_from_panic(const struct page *cons= t page) { if (!PageHighMem(page)) return page_address(page); @@ -81,13 +81,15 @@ static inline void *kmap_local_page_try_from_panic(stru= ct page *page) return NULL; } =20 -static inline void *kmap_local_folio(struct folio *folio, size_t offset) +static inline void *kmap_local_folio(const struct folio *const folio, + const size_t offset) { - struct page *page =3D folio_page(folio, offset / PAGE_SIZE); + const struct page *page =3D folio_page(folio, offset / PAGE_SIZE); return __kmap_local_page_prot(page, kmap_prot) + offset % PAGE_SIZE; } =20 -static inline void *kmap_local_page_prot(struct page *page, pgprot_t prot) +static inline void *kmap_local_page_prot(const struct page *const page, + const pgprot_t prot) { return __kmap_local_page_prot(page, prot); } @@ -102,7 +104,7 @@ static inline void __kunmap_local(const void *vaddr) kunmap_local_indexed(vaddr); } =20 -static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot) +static inline void *kmap_atomic_prot(const struct page *const page, const = pgprot_t prot) { if (IS_ENABLED(CONFIG_PREEMPT_RT)) migrate_disable(); @@ -113,7 +115,7 @@ static inline void *kmap_atomic_prot(struct page *page,= pgprot_t prot) return __kmap_local_page_prot(page, prot); } =20 -static inline void *kmap_atomic(struct page *page) +static inline void *kmap_atomic(const struct page *const page) { return kmap_atomic_prot(page, kmap_prot); } @@ -173,17 +175,17 @@ static inline void *kmap(struct page *page) return page_address(page); } =20 -static inline void kunmap_high(struct page *page) { } +static inline void kunmap_high(const struct page *const page) { } static inline void kmap_flush_unused(void) { } =20 -static inline void kunmap(struct page *page) +static inline void kunmap(const struct page *const page) { #ifdef ARCH_HAS_FLUSH_ON_KUNMAP kunmap_flush_on_unmap(page_address(page)); #endif } =20 -static inline void *kmap_local_page(struct page *page) +static inline void *kmap_local_page(const struct page *const page) { return page_address(page); } @@ -193,12 +195,14 @@ static inline void *kmap_local_page_try_from_panic(st= ruct page *page) return page_address(page); } =20 -static inline void *kmap_local_folio(struct folio *folio, size_t offset) +static inline void *kmap_local_folio(const struct folio *const folio, + const size_t offset) { return folio_address(folio) + offset; } =20 -static inline void *kmap_local_page_prot(struct page *page, pgprot_t prot) +static inline void *kmap_local_page_prot(const struct page *const page, + const pgprot_t prot) { return kmap_local_page(page); } @@ -215,7 +219,7 @@ static inline void __kunmap_local(const void *addr) #endif } =20 -static inline void *kmap_atomic(struct page *page) +static inline void *kmap_atomic(const struct page *const page) { if (IS_ENABLED(CONFIG_PREEMPT_RT)) migrate_disable(); @@ -225,7 +229,7 @@ static inline void *kmap_atomic(struct page *page) return page_address(page); } =20 -static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot) +static inline void *kmap_atomic_prot(const struct page *const page, const = pgprot_t prot) { return kmap_atomic(page); } diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 6234f316468c..105cc4c00cc3 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -43,7 +43,7 @@ static inline void *kmap(struct page *page); * Counterpart to kmap(). A NOOP for CONFIG_HIGHMEM=3Dn and for mappings of * pages in the low memory area. */ -static inline void kunmap(struct page *page); +static inline void kunmap(const struct page *page); =20 /** * kmap_to_page - Get the page for a kmap'ed address @@ -93,7 +93,7 @@ static inline void kmap_flush_unused(void); * disabling migration in order to keep the virtual address stable across * preemption. No caller of kmap_local_page() can rely on this side effect. */ -static inline void *kmap_local_page(struct page *page); +static inline void *kmap_local_page(const struct page *page); =20 /** * kmap_local_folio - Map a page in this folio for temporary usage @@ -129,7 +129,7 @@ static inline void *kmap_local_page(struct page *page); * Context: Can be invoked from any context. * Return: The virtual address of @offset. */ -static inline void *kmap_local_folio(struct folio *folio, size_t offset); +static inline void *kmap_local_folio(const struct folio *folio, size_t off= set); =20 /** * kmap_atomic - Atomically map a page for temporary usage - Deprecated! @@ -176,7 +176,7 @@ static inline void *kmap_local_folio(struct folio *foli= o, size_t offset); * kunmap_atomic(vaddr2); * kunmap_atomic(vaddr1); */ -static inline void *kmap_atomic(struct page *page); +static inline void *kmap_atomic(const struct page *page); =20 /* Highmem related interfaces for management code */ static inline unsigned long nr_free_highpages(void); diff --git a/mm/highmem.c b/mm/highmem.c index ef3189b36cad..93fa505fcb98 100644 --- a/mm/highmem.c +++ b/mm/highmem.c @@ -61,7 +61,7 @@ static inline int kmap_local_calc_idx(int idx) /* * Determine color of virtual address where the page should be mapped. */ -static inline unsigned int get_pkmap_color(struct page *page) +static inline unsigned int get_pkmap_color(const struct page *const page) { return 0; } @@ -334,7 +334,7 @@ EXPORT_SYMBOL(kmap_high); * * This can be called from any context. */ -void *kmap_high_get(struct page *page) +void *kmap_high_get(const struct page *const page) { unsigned long vaddr, flags; =20 @@ -356,7 +356,7 @@ void *kmap_high_get(struct page *page) * If ARCH_NEEDS_KMAP_HIGH_GET is not defined then this may be called * only from user context. */ -void kunmap_high(struct page *page) +void kunmap_high(const struct page *const page) { unsigned long vaddr; unsigned long nr; @@ -508,7 +508,7 @@ static inline void kmap_local_idx_pop(void) #endif =20 #ifndef arch_kmap_local_high_get -static inline void *arch_kmap_local_high_get(struct page *page) +static inline void *arch_kmap_local_high_get(const struct page *const page) { return NULL; } @@ -572,7 +572,7 @@ void *__kmap_local_pfn_prot(unsigned long pfn, pgprot_t= prot) } EXPORT_SYMBOL_GPL(__kmap_local_pfn_prot); =20 -void *__kmap_local_page_prot(struct page *page, pgprot_t prot) +void *__kmap_local_page_prot(const struct page *const page, const pgprot_t= prot) { void *kmap; =20 --=20 2.47.2