Skip to contentSkip to conversation

sched/mmcid: Use clamp to simplify mm_cid_calc_pcpu_thrs

PATCH Superseded Thorsten Blum 1 participant 1 message Feb 24 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/mmcid: Use clamp to simplify mm_cid_calc_pcpu_thrs

Replace nested max(min()) with clamp() to simplify mm_cid_calc_pcpu_thrs(). No functional changes.

---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
index 759777694c78..8c3920918596 100644
@@ -10473,7 +10473,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)
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4