mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
s390/mm: Simplify gap clamping in mmap_base() using clamp()
mmap_base() has logic to ensure that the variable "gap" stays within the range defined by "gap_min" and "gap_max". Replace this with the clamp() macro to shorten and simplify code. Signed-off-by: Qasim Ijaz <qasdev00@gmail.com> Link: https://lore.kernel.org/r/20250204162508.12335-1-qasdev00@gmail.com Reviewed-by: Vasily Gorbik <gor@linux.ibm.com> [gor@linux.ibm.com: also remove the gap_min and gap_max variables] Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
This commit is contained in:
parent
ad9bb8f049
commit
a702b633c0
|
|
@ -51,7 +51,6 @@ static inline unsigned long mmap_base(unsigned long rnd,
|
|||
{
|
||||
unsigned long gap = rlim_stack->rlim_cur;
|
||||
unsigned long pad = stack_maxrandom_size() + stack_guard_gap;
|
||||
unsigned long gap_min, gap_max;
|
||||
|
||||
/* Values close to RLIM_INFINITY can overflow. */
|
||||
if (gap + pad > gap)
|
||||
|
|
@ -61,13 +60,7 @@ static inline unsigned long mmap_base(unsigned long rnd,
|
|||
* Top of mmap area (just below the process stack).
|
||||
* Leave at least a ~128 MB hole.
|
||||
*/
|
||||
gap_min = SZ_128M;
|
||||
gap_max = (STACK_TOP / 6) * 5;
|
||||
|
||||
if (gap < gap_min)
|
||||
gap = gap_min;
|
||||
else if (gap > gap_max)
|
||||
gap = gap_max;
|
||||
gap = clamp(gap, SZ_128M, (STACK_TOP / 6) * 5);
|
||||
|
||||
return PAGE_ALIGN(STACK_TOP - gap - rnd);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user