Skip to content

Commit 72d0ad7

Browse files
odinugePeter Zijlstra
authored andcommitted
sched/fair: Fix CFS bandwidth hrtimer expiry type
The time remaining until expiry of the refresh_timer can be negative. Casting the type to an unsigned 64-bit value will cause integer underflow, making the runtime_refresh_within return false instead of true. These situations are rare, but they do happen. This does not cause user-facing issues or errors; other than possibly unthrottling cfs_rq's using runtime from the previous period(s), making the CFS bandwidth enforcement less strict in those (special) situations. Signed-off-by: Odin Ugedal <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Ben Segall <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ceb6ba4 commit 72d0ad7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/sched/fair.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5054,15 +5054,15 @@ static const u64 cfs_bandwidth_slack_period = 5 * NSEC_PER_MSEC;
50545054
static int runtime_refresh_within(struct cfs_bandwidth *cfs_b, u64 min_expire)
50555055
{
50565056
struct hrtimer *refresh_timer = &cfs_b->period_timer;
5057-
u64 remaining;
5057+
s64 remaining;
50585058

50595059
/* if the call-back is running a quota refresh is already occurring */
50605060
if (hrtimer_callback_running(refresh_timer))
50615061
return 1;
50625062

50635063
/* is a quota refresh about to occur? */
50645064
remaining = ktime_to_ns(hrtimer_expires_remaining(refresh_timer));
5065-
if (remaining < min_expire)
5065+
if (remaining < (s64)min_expire)
50665066
return 1;
50675067

50685068
return 0;

0 commit comments

Comments
 (0)