Skip to content

Commit a702b63

Browse files
qasim-ijazVasily Gorbik
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Vasily Gorbik <[email protected]> [[email protected]: also remove the gap_min and gap_max variables] Signed-off-by: Vasily Gorbik <[email protected]>
1 parent ad9bb8f commit a702b63

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

arch/s390/mm/mmap.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ static inline unsigned long mmap_base(unsigned long rnd,
5151
{
5252
unsigned long gap = rlim_stack->rlim_cur;
5353
unsigned long pad = stack_maxrandom_size() + stack_guard_gap;
54-
unsigned long gap_min, gap_max;
5554

5655
/* Values close to RLIM_INFINITY can overflow. */
5756
if (gap + pad > gap)
@@ -61,13 +60,7 @@ static inline unsigned long mmap_base(unsigned long rnd,
6160
* Top of mmap area (just below the process stack).
6261
* Leave at least a ~128 MB hole.
6362
*/
64-
gap_min = SZ_128M;
65-
gap_max = (STACK_TOP / 6) * 5;
66-
67-
if (gap < gap_min)
68-
gap = gap_min;
69-
else if (gap > gap_max)
70-
gap = gap_max;
63+
gap = clamp(gap, SZ_128M, (STACK_TOP / 6) * 5);
7164

7265
return PAGE_ALIGN(STACK_TOP - gap - rnd);
7366
}

0 commit comments

Comments
 (0)