From: Qasim Ijaz <qasdev00@gmail.com>
To: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: gerald.schaefer@linux.ibm.com, hca@linux.ibm.com,
gor@linux.ibm.com, borntraeger@linux.ibm.com,
svens@linux.ibm.com, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] s390/mm: Simplify gap clamping in mmap_base() using clamp()
Date: Sat, 15 Feb 2025 12:31:45 +0000 [thread overview]
Message-ID: <Z7CJMfywZ8HoqbnL@qasdev.system> (raw)
On Fri, Feb 14, 2025 at 11:58:24AM +0100, Alexander Gordeev wrote:
> On Tue, Feb 04, 2025 at 04:25:08PM +0000, Qasim Ijaz wrote:
> > 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>
> > ---
> > arch/s390/mm/mmap.c | 6 +-----
> > 1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
> > index 76f376876e0d..a3d3e09a2828 100644
> > --- a/arch/s390/mm/mmap.c
> > +++ b/arch/s390/mm/mmap.c
> > @@ -63,11 +63,7 @@ static inline unsigned long mmap_base(unsigned long rnd,
> > */
> > 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, gap_min, gap_max);
> >
> > return PAGE_ALIGN(STACK_TOP - gap - rnd);
> > }
>
> Whenever possible I personally prefer branches over ternary operators.
> But if one wants to clump it in one line, then gap_min and gap_max
> are also redundant.
Thank you for the feedback Alexander, would you like me to send a v2
patch without the gap_min and gap_max variables as you suggested?
>
> Thanks!
next reply other threads:[~2025-02-15 12:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-15 12:31 Qasim Ijaz [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-02-04 16:25 [PATCH] s390/mm: Simplify gap clamping in mmap_base() using clamp() Qasim Ijaz
2025-02-14 10:58 ` Alexander Gordeev
2025-02-21 23:55 ` Vasily Gorbik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z7CJMfywZ8HoqbnL@qasdev.system \
--to=qasdev00@gmail.com \
--cc=Z68h0B6vFdfCbNpb@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=svens@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.