mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-07 06:52:07 +00:00
rcutorture: Give the scheduler a chance on PREEMPT && NO_HZ_FULL kernels
In !PREEMPT kernels, cond_resched() is a no-op. In NO_HZ_FULL kernels, in-kernel execution (such as that of rcutorture's kthreads) might extend indefinitely without the scheduler gaining the aid of a scheduling-clock interrupt. This combination can make the interaction of an rcutorture forward-progress test and a CPU-hotplug stop_machine operation make less forward progress than one might like. Additionally, Sebastian Siewior notes that NO_HZ_FULL kernels have a scheduler check upon return to userspace execution, which suggests that in-kernel emulation of tight userspace loops containing system calls doing call_rcu() might also need explicit checks in the PREEMPT && NO_HZ_FULL case. This commit therefore introduces a rcu_torture_fwd_prog_cond_resched() function that explicitly invokes schedule() in such kernels whenever need_resched() returns true, while retaining use of cond_resched() for kernels that are either !PREEMPT or !NO_HZ_FULL. Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
This commit is contained in:
parent
52b23be7ee
commit
ab21f6081f
1 changed files with 14 additions and 3 deletions
|
@ -1667,6 +1667,17 @@ static void rcu_torture_fwd_cb_cr(struct rcu_head *rhp)
|
||||||
spin_unlock_irqrestore(&rcu_fwd_lock, flags);
|
spin_unlock_irqrestore(&rcu_fwd_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Give the scheduler a chance, even on nohz_full CPUs.
|
||||||
|
static void rcu_torture_fwd_prog_cond_resched(void)
|
||||||
|
{
|
||||||
|
if (IS_ENABLED(CONFIG_PREEMPT) && IS_ENABLED(CONFIG_NO_HZ_FULL)) {
|
||||||
|
if (need_resched())
|
||||||
|
schedule();
|
||||||
|
} else {
|
||||||
|
cond_resched();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free all callbacks on the rcu_fwd_cb_head list, either because the
|
* Free all callbacks on the rcu_fwd_cb_head list, either because the
|
||||||
* test is over or because we hit an OOM event.
|
* test is over or because we hit an OOM event.
|
||||||
|
@ -1690,7 +1701,7 @@ static unsigned long rcu_torture_fwd_prog_cbfree(void)
|
||||||
spin_unlock_irqrestore(&rcu_fwd_lock, flags);
|
spin_unlock_irqrestore(&rcu_fwd_lock, flags);
|
||||||
kfree(rfcp);
|
kfree(rfcp);
|
||||||
freed++;
|
freed++;
|
||||||
cond_resched();
|
rcu_torture_fwd_prog_cond_resched();
|
||||||
}
|
}
|
||||||
return freed;
|
return freed;
|
||||||
}
|
}
|
||||||
|
@ -1734,7 +1745,7 @@ static void rcu_torture_fwd_prog_nr(int *tested, int *tested_tries)
|
||||||
udelay(10);
|
udelay(10);
|
||||||
cur_ops->readunlock(idx);
|
cur_ops->readunlock(idx);
|
||||||
if (!fwd_progress_need_resched || need_resched())
|
if (!fwd_progress_need_resched || need_resched())
|
||||||
cond_resched();
|
rcu_torture_fwd_prog_cond_resched();
|
||||||
}
|
}
|
||||||
(*tested_tries)++;
|
(*tested_tries)++;
|
||||||
if (!time_before(jiffies, stopat) &&
|
if (!time_before(jiffies, stopat) &&
|
||||||
|
@ -1817,7 +1828,7 @@ static void rcu_torture_fwd_prog_cr(void)
|
||||||
rfcp->rfc_gps = 0;
|
rfcp->rfc_gps = 0;
|
||||||
}
|
}
|
||||||
cur_ops->call(&rfcp->rh, rcu_torture_fwd_cb_cr);
|
cur_ops->call(&rfcp->rh, rcu_torture_fwd_cb_cr);
|
||||||
cond_resched();
|
rcu_torture_fwd_prog_cond_resched();
|
||||||
}
|
}
|
||||||
stoppedat = jiffies;
|
stoppedat = jiffies;
|
||||||
n_launders_cb_snap = READ_ONCE(n_launders_cb);
|
n_launders_cb_snap = READ_ONCE(n_launders_cb);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue