diff options
| author | Qasim Ijaz <qasdev00@gmail.com> | 2025-02-04 16:25:08 +0000 |
|---|---|---|
| committer | Vasily Gorbik <gor@linux.ibm.com> | 2025-03-04 17:18:08 +0100 |
| commit | a702b633c0649eef5249e0355ecfb60567e4dbf2 (patch) | |
| tree | 04181c54b709bf9bb38dd72691d75a1e65965257 | |
| parent | ad9bb8f049717d64c5e62b2a44954be9f681c65b (diff) | |
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>
| -rw-r--r-- | arch/s390/mm/mmap.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 76f376876e0d..40a526d28184 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -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); } |
