Rather than use "if" to check and clamp values to allowed minmum or maxmum,
this patch use macros clamp() and max() to clean it up.

Signed-off-by: Dongsheng Yang <[email protected]>
---
 kernel/sched/fair.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7570dd9..939a7ab 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2041,10 +2041,7 @@ static long calc_cfs_shares(struct cfs_rq *cfs_rq, 
struct task_group *tg)
        if (tg_weight)
                shares /= tg_weight;
 
-       if (shares < MIN_SHARES)
-               shares = MIN_SHARES;
-       if (shares > tg->shares)
-               shares = tg->shares;
+       shares = clamp(shares, MIN_SHARES, tg->shares);
 
        return shares;
 }
@@ -4133,8 +4130,7 @@ static long effective_load(struct task_group *tg, int 
cpu, long wl, long wg)
                 * those are clipped to [MIN_SHARES, ...) do so now. See
                 * calc_cfs_shares().
                 */
-               if (wl < MIN_SHARES)
-                       wl = MIN_SHARES;
+               wl = max(wl, MIN_SHARES);
 
                /*
                 * wl = dw_i = S * (s'_i - s_i); see (3)
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to