aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Certner <olce@FreeBSD.org>2024-05-21 12:55:43 +0000
committerOlivier Certner <olce@FreeBSD.org>2025-06-18 02:09:39 +0000
commiteebc148f25c3012b943083b48fbfc13494e9c77f (patch)
treeb4c852bd257de5c5bf23f393f9dcf34439cd3eb7
parent51a4ae05abe6e170de0ff82641d8fce19043eea9 (diff)
sched_4bsd: ESTCPULIM(): Allow any value in the timeshare range
The current formula wastes queues and degrades usage estimation precision, since any increase of ticks that goes over 40 priorities (so, 8 * 40) is clamped to the last of these 40 levels (the nice value is subsequently added to that number to get the final priority level). Allow 'ts_estcpu' to grow up to a value corresponding to the greatest (i.e., lowest) priority of the timeshare range. MFC after: 1 month Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45392
-rw-r--r--sys/kern/sched_4bsd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index e7f61eb6ed63..753494983416 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -80,7 +80,9 @@ dtrace_vtime_switch_func_t dtrace_vtime_switch_func;
#endif
#define NICE_WEIGHT 1 /* Priorities per nice level. */
#define ESTCPULIM(e) \
- min((e), INVERSE_ESTCPU_WEIGHT * (NICE_WEIGHT * (PRIO_MAX - PRIO_MIN)) \
+ min((e), INVERSE_ESTCPU_WEIGHT * \
+ (NICE_WEIGHT * (PRIO_MAX - PRIO_MIN) + \
+ PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE) \
+ INVERSE_ESTCPU_WEIGHT - 1)
#define TS_NAME_LEN (MAXCOMLEN + sizeof(" td ") + sizeof(__XSTRING(UINT_MAX)))