]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched: Change nr_uninterruptible type to unsigned long
authorAruna Ramakrishna <aruna.ramakrishna@oracle.com>
Wed, 9 Jul 2025 17:33:28 +0000 (17:33 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 14 Jul 2025 08:59:31 +0000 (10:59 +0200)
The commit e6fe3f422be1 ("sched: Make multiple runqueue task counters
32-bit") changed nr_uninterruptible to an unsigned int. But the
nr_uninterruptible values for each of the CPU runqueues can grow to
large numbers, sometimes exceeding INT_MAX. This is valid, if, over
time, a large number of tasks are migrated off of one CPU after going
into an uninterruptible state. Only the sum of all nr_interruptible
values across all CPUs yields the correct result, as explained in a
comment in kernel/sched/loadavg.c.

Change the type of nr_uninterruptible back to unsigned long to prevent
overflows, and thus the miscalculation of load average.

Fixes: e6fe3f422be1 ("sched: Make multiple runqueue task counters 32-bit")
Signed-off-by: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250709173328.606794-1-aruna.ramakrishna@oracle.com
kernel/sched/loadavg.c
kernel/sched/sched.h

index c48900b856a2aa3f969803dc9a752bbba1faf3ab..52ca8e268cfc56e59048eadd38f4dfc077c0e66d 100644 (file)
@@ -80,7 +80,7 @@ long calc_load_fold_active(struct rq *this_rq, long adjust)
        long nr_active, delta = 0;
 
        nr_active = this_rq->nr_running - adjust;
-       nr_active += (int)this_rq->nr_uninterruptible;
+       nr_active += (long)this_rq->nr_uninterruptible;
 
        if (nr_active != this_rq->calc_load_active) {
                delta = nr_active - this_rq->calc_load_active;
index 475bb5998295e38a0a4a093ec10295928f204b23..83e3aa91714299f6e74aee930c6b42705c64a1e4 100644 (file)
@@ -1149,7 +1149,7 @@ struct rq {
         * one CPU and if it got migrated afterwards it may decrease
         * it on another CPU. Always updated under the runqueue lock:
         */
-       unsigned int            nr_uninterruptible;
+       unsigned long           nr_uninterruptible;
 
        union {
                struct task_struct __rcu *donor; /* Scheduler context */