From nobody Sun Dec 14 11:42:55 2025 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 4159B3451CC for ; Mon, 1 Sep 2025 12:30:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756729852; cv=none; b=tKyOOmMwq2KYuPORDrVhGvqPvX9PxmNCfFQXQjM8zUNIDQcB8Nrm9tzus04OLmuXOLHsgTY74BNwZMXWq9Xn6WD9o5RvmQi16bAgqcOHAamWzKFIqDnV6lnIsFEEU8v+ILXH7Y4MVXWDiELk0Xr5qxDhgo5zQ3g199exw0uBmdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756729852; c=relaxed/simple; bh=EPJbyRWxHnT9AgTmdS6KO9CuajUKQ+wmYGiqrI3ZBAk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QhYxov95/NGVfG7Oh5Nq2yteMvhgUfxK98Qhd8x2i8Yy6YWDlvns2ZDBtWSHmHGJGzua0c7jDrWfe9JH+EcciPCoeFMjYHc2eoDIJvGbH0bSHd5Bim/dSxTVeJylIjmXKubj6rhWBTNr10oQwkPhmj/VjbAXJhBArdJx5ivCLaI= 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=aHgTrVy+; arc=none smtp.client-ip=209.85.208.51 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="aHgTrVy+" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-6188b5ad681so5237648a12.0 for ; Mon, 01 Sep 2025 05:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1756729849; x=1757334649; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wDGNHui84WsHVpXgfTg7/ZQpp3R8ARaLofrymMcz4P4=; b=aHgTrVy+UXwL9vMATMLTBzYygvkvl1PXOOkgjbsIQG3AtnAibegqVurFbnCgst5vw3 Tdn6BM6pdncPEzEN9ifHpCA8P6Pi4hRjnYSm2XHIsHhjBoa2yZ23NHuGkS26Mta2ynDG hHyJrdulDtB0BpZ5BnpS002ShEm4bThnIuHBA36CXsVQXZQl8TLN9ouFxkOu79st1Lun n/4mA3ksechY3UCwBukK3jOeMXCtdgFo4nnd+QD7ghAwOcthXOafw9+qg7Ty7/sIIJGA Xon6LXD5Nx/5nBd1kfpFV4EZRE0nIo8tJwVUDxwZbsqTwpnlVC8IN3f1JRwVMOGUYrZL 3tqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756729849; x=1757334649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wDGNHui84WsHVpXgfTg7/ZQpp3R8ARaLofrymMcz4P4=; b=FcCasaqlYhxpX9eVpv9tMezNPssf/9xZCLSTx1MsX5q5cVgwkeJXXXvWaw+R6TDiVa LbK9trRZPJx5b8RfZBUQPc8RsEOiRQix+/xhfFPGGCOHthkx4b96K/ajm5jmshs/N4zx IWxePwKxRR/SL4d0pQBbHc+d/BI4DhkelLKDO4C8whr55SIjaFYSoD6XIF/fOZ1mCN9M F+9c6CY8JkILzEbHzD2mt3WUuek3ihVX3PUOv+auD7Rtyw7rGvSu1N0tsa7bpwQBHO8P FvSWO6BRWvaIK/KFXnP4d07p4Ptj9jF3sq1qVXvn33GPXsjhEnTELKw34/D1EHsRBSTH 1q/g== X-Forwarded-Encrypted: i=1; AJvYcCWuvJRLw4cVnRYJTMNGdFnWBGqU8jQrRZbova/Z331pTx7nbfOEUMJyG7ij+5vYaqUPimx5yEeUcCYW7QU=@vger.kernel.org X-Gm-Message-State: AOJu0Yyin4ZLck36n9VHfoUMaCovtuVkXcBeaOsAKLYBRP7xr9+/BuUI BwGl4w0q2DcrfuiwOaeNXLbyBb+y7LO23y4swW0MY6O98MMFBePDUkK4alv1MWoZnfM= X-Gm-Gg: ASbGncszioT3Sf/InCakoV2EaqVuExnGMScd2i3TpU8RwXI7xRe9/iifXzv1uY+V0ZD l0UFF5bAjShzPJax1LT3Zb4Ebjs55qOhFyfbQG/c9auf7E+P3/dCDHu8GxsuQ1kQUBquuIz7uok mM4qnc75k0XZVLezqMU7pDpQFy9Q+WQC0PB87VwlIM+3c37y9VqoXhtipFKP3XtvHfcpkyIt0oh 8HQ+WCaRjKKv59PPFIe2ABdoISBwwgRaezSKQY4228/ZtXicOldnDY7GOUqvbdP+ALNMhBnjw4+ jnnI6RBSiqzJNjMnSsZBHjlfCp1s0b948UzA0AymNU4xhhVCFq2At9fORcjQslqUi4xCedy26sh /GoRWD2/ZbSVsvY04MGgaRa+BgjQO27gIE3cvU35D1+QGyek4zi49/Be/vOh7e7aV+fapuuBcb8 p/7pcN9JseiSYmhVZ9kqfoKJzYRU1oG2zd X-Google-Smtp-Source: AGHT+IFKdIH/XV8PMBLWofBOVQFCiNzD1MryqiWSI9A5CR0R39RCWddVIJNZ79UXnDKy/e8yeVnjDw== X-Received: by 2002:a05:6402:2549:b0:618:afa:70b1 with SMTP id 4fb4d7f45d1cf-61d26c32e70mr6177153a12.20.1756729848021; Mon, 01 Sep 2025 05:30:48 -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-61eaf5883b6sm255566a12.20.2025.09.01.05.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 05:30:47 -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, linux@armlinux.org.uk, James.Bottomley@HansenPartnership.com, deller@gmx.de, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, davem@davemloft.net, andreas@gaisler.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, chris@zankel.net, jcmvbkbc@gmail.com, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, weixugc@google.com, baolin.wang@linux.alibaba.com, rientjes@google.com, shakeel.butt@linux.dev, max.kellermann@ionos.com, thuth@redhat.com, broonie@kernel.org, osalvador@suse.de, jfalempe@redhat.com, mpe@ellerman.id.au, nysal@linux.ibm.com, linux-arm-kernel@lists.infradead.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v5 08/12] mm: constify arch_pick_mmap_layout() for improved const-correctness Date: Mon, 1 Sep 2025 14:30:24 +0200 Message-ID: <20250901123028.3383461-9-max.kellermann@ionos.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250901123028.3383461-1-max.kellermann@ionos.com> References: <20250901123028.3383461-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" This function only reads from the rlimit pointer (but writes to the mm_struct pointer which is kept without `const`). All callees are already const-ified or (internal functions) are being constified by this patch. Signed-off-by: Max Kellermann Reviewed-by: Vishal Moola (Oracle) --- arch/s390/mm/mmap.c | 5 +++-- arch/sparc/kernel/sys_sparc_64.c | 3 ++- arch/x86/mm/mmap.c | 7 ++++--- include/linux/sched/mm.h | 4 ++-- mm/util.c | 9 ++++++--- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index c0f619fb9ab3..a47c7133d82a 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -47,7 +47,7 @@ static unsigned long mmap_base_legacy(unsigned long rnd) } =20 static inline unsigned long mmap_base(unsigned long rnd, - struct rlimit *rlim_stack) + const struct rlimit *const rlim_stack) { unsigned long gap =3D rlim_stack->rlim_cur; unsigned long pad =3D stack_maxrandom_size() + stack_guard_gap; @@ -169,7 +169,8 @@ unsigned long arch_get_unmapped_area_topdown(struct fil= e *filp, unsigned long ad * This function, called very early during the creation of a new * process VM image, sets up which VM layout function to use: */ -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) +void arch_pick_mmap_layout(struct mm_struct *const mm, + const struct rlimit *const rlim_stack) { unsigned long random_factor =3D 0UL; =20 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc= _64.c index 785e9909340f..1c243bb461b2 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c @@ -294,7 +294,8 @@ static unsigned long mmap_rnd(void) return rnd << PAGE_SHIFT; } =20 -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) +void arch_pick_mmap_layout(struct mm_struct *const mm, + const struct rlimit *const rlim_stack) { unsigned long random_factor =3D mmap_rnd(); unsigned long gap; diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c index 708f85dc9380..13bde4ba2f24 100644 --- a/arch/x86/mm/mmap.c +++ b/arch/x86/mm/mmap.c @@ -80,7 +80,7 @@ unsigned long arch_mmap_rnd(void) } =20 static unsigned long mmap_base(unsigned long rnd, unsigned long task_size, - struct rlimit *rlim_stack) + const struct rlimit *const rlim_stack) { unsigned long gap =3D rlim_stack->rlim_cur; unsigned long pad =3D stack_maxrandom_size(task_size) + stack_guard_gap; @@ -110,7 +110,7 @@ static unsigned long mmap_legacy_base(unsigned long rnd, */ static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy= _base, unsigned long random_factor, unsigned long task_size, - struct rlimit *rlim_stack) + const struct rlimit *const rlim_stack) { *legacy_base =3D mmap_legacy_base(random_factor, task_size); if (mmap_is_legacy()) @@ -119,7 +119,8 @@ static void arch_pick_mmap_base(unsigned long *base, un= signed long *legacy_base, *base =3D mmap_base(random_factor, task_size, rlim_stack); } =20 -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) +void arch_pick_mmap_layout(struct mm_struct *const mm, + const struct rlimit *const rlim_stack) { if (mmap_is_legacy()) mm_flags_clear(MMF_TOPDOWN, mm); diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 2201da0afecc..0232d983b715 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -178,7 +178,7 @@ static inline void mm_update_next_owner(struct mm_struc= t *mm) #endif =20 extern void arch_pick_mmap_layout(struct mm_struct *mm, - struct rlimit *rlim_stack); + const struct rlimit *rlim_stack); =20 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, @@ -211,7 +211,7 @@ generic_get_unmapped_area_topdown(struct file *filp, un= signed long addr, unsigned long flags, vm_flags_t vm_flags); #else static inline void arch_pick_mmap_layout(struct mm_struct *mm, - struct rlimit *rlim_stack) {} + const struct rlimit *rlim_stack) {} #endif =20 static inline bool in_vfork(struct task_struct *tsk) diff --git a/mm/util.c b/mm/util.c index f5a35efba7bf..24f08217cd95 100644 --- a/mm/util.c +++ b/mm/util.c @@ -431,7 +431,8 @@ static int mmap_is_legacy(const struct rlimit *const rl= im_stack) #define MIN_GAP (SZ_128M) #define MAX_GAP (STACK_TOP / 6 * 5) =20 -static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stac= k) +static unsigned long mmap_base(const unsigned long rnd, + const struct rlimit *const rlim_stack) { #ifdef CONFIG_STACK_GROWSUP /* @@ -462,7 +463,8 @@ static unsigned long mmap_base(unsigned long rnd, struc= t rlimit *rlim_stack) #endif } =20 -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) +void arch_pick_mmap_layout(struct mm_struct *const mm, + const struct rlimit *const rlim_stack) { unsigned long random_factor =3D 0UL; =20 @@ -478,7 +480,8 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct= rlimit *rlim_stack) } } #elif defined(CONFIG_MMU) && !defined(HAVE_ARCH_PICK_MMAP_LAYOUT) -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) +void arch_pick_mmap_layout(struct mm_struct *const mm, + const struct rlimit *const rlim_stack) { mm->mmap_base =3D TASK_UNMAPPED_BASE; mm_flags_clear(MMF_TOPDOWN, mm); --=20 2.47.2