[PATCH RESEND] sched/mmcid: Use clamp() to simplify mm_cid_calc_pcpu_thrs()

From: Thorsten Blum

Date: Sun Jul 05 2026 - 13:21:15 EST


Use clamp() to simplify the code and improve its readability.

Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
---
kernel/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8b791e9e9f67..31739bd43176 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10785,7 +10785,7 @@ static inline unsigned int mm_cid_calc_pcpu_thrs(struct mm_mm_cid *mc)

opt_cids = min(mc->nr_cpus_allowed, mc->users);
/* Has to be at least 1 because 0 indicates PCPU mode off */
- return max(min(opt_cids - opt_cids / 4, num_possible_cpus() / 2), 1);
+ return clamp(opt_cids - opt_cids / 4, 1, num_possible_cpus() / 2);
}

static bool mm_update_max_cids(struct mm_struct *mm)