mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
RCU pull request for v7.2
-----BEGIN PGP SIGNATURE-----
iQGzBAABCgAdFiEEu6QRe/mAUYNn5U0PBYqkjnKWLM8FAmofGTIACgkQBYqkjnKW
LM9Glgv/cb27AeuChYy+nTJdsMX6V28mvacJP0nTDl4V//OvWYyehk1IKaQIvicY
aNB0+zFQzMknnDvXL3eK4eyYKsxKhjbBiWSizrLxRLTXD37sgN9nZm+SdHklZ338
f2V5yZjON0+zX1OA5pYyJ15Wc0QtIMd173fYaZdfRHSJwtat0s3J2Ceshltq8qCH
egHWvpCXtI8RlqC93zsU89+aU43A+yb1H306VlCvdPsfTl/An/zQW39NfQttS0qe
9qBD/3o0g2iA4A91qGda+NKlcVHenglbds7muuoCdCUR15n4u9ijVaAXsqLDFJhW
mxLyQr77r6xBwOD9yiPD0pEWsWDByBkJQybW6gWQ2tBnEFPrDlYp65GBCLqvdU31
NSH+jNSgoxNNtNdmxQNUc+LwomPH4tJ33CiQCdwmoErGyfeDOcfNKokydEtKwzjO
3b06vWW5Ae9r/yA/PqgkCg9FckpOGC9nVtFWauWGBjhXkwSUigalgOATFb/rw0wi
0uypCILs
=Hsv1
-----END PGP SIGNATURE-----
Merge tag 'rcu.release.v7.2' of gitolite.kernel.org:pub/scm/linux/kernel/git/rcu/linux
Pull RCU updates from Uladzislau Rezki:
"Torture test updates:
- Improve kvm-series.sh script by adding examples in its header
comment
- Lazy RCU is more fully tested now by replacing call_rcu_hurry()
with call_rcu() and doing rcu_barrier() to motivate lazy callbacks
during a stutter pause
- Add more synonyms for the "--do-normal" group of torture.sh
command-line arguments
Misc changes:
- Reduce stack usage of nocb_gp_wait() to address frame size warning
when built with CONFIG_UBSAN_ALIGNMENT
- The synchronize_rcu() call can detect the flood and latches a
normal/default path temporary switching to wait_rcu_gp() path
- Document using rcu_access_pointer() to fetch the old pointer for
lockless cmpxchg() updates
- Simplify some RCU code using clamp_val()
- Fix a kerneldoc header comment typo in srcu_down_read_fast()"
* tag 'rcu.release.v7.2' of gitolite.kernel.org:pub/scm/linux/kernel/git/rcu/linux:
rcu/nocb: reduce stack usage in nocb_gp_wait()
rcu-tasks: Fix possible boot-time tests failed for the call_rcu_tasks()
rcu: Latch normal synchronize_rcu() path on flood
rcu: Document rcu_access_pointer() feeding into cmpxchg()
rcu: Simplify param_set_next_fqs_jiffies() by applying clamp_val()
rcu: Simplify rcu_do_batch() by applying clamp()
checkpatch: Undeprecate rcu_read_lock_trace() and rcu_read_unlock_trace()
srcu: Fix kerneldoc header comment typo in srcu_down_read_fast()
torture: Allow "norm" abbreviation for "normal"
torture: Improve kvm-series.sh header comment
torture: Add torture_sched_set_normal() for user-specified nice values
rcutorture: Fully test lazy RCU
This commit is contained in:
commit
b8b674748f
|
|
@ -5844,13 +5844,13 @@ Kernel parameters
|
|||
use a call_rcu[_hurry]() path. Please note, this is for a
|
||||
normal grace period.
|
||||
|
||||
How to enable it:
|
||||
How to disable it:
|
||||
|
||||
echo 1 > /sys/module/rcutree/parameters/rcu_normal_wake_from_gp
|
||||
or pass a boot parameter "rcutree.rcu_normal_wake_from_gp=1"
|
||||
echo 0 > /sys/module/rcutree/parameters/rcu_normal_wake_from_gp
|
||||
or pass a boot parameter "rcutree.rcu_normal_wake_from_gp=0"
|
||||
|
||||
Default is 1 if num_possible_cpus() <= 16 and it is not explicitly
|
||||
disabled by the boot parameter passing 0.
|
||||
Default is 1 if it is not explicitly disabled by the boot parameter
|
||||
passing 0.
|
||||
|
||||
rcuscale.gp_async= [KNL]
|
||||
Measure performance of asynchronous
|
||||
|
|
|
|||
|
|
@ -592,11 +592,13 @@ context_unsafe( \
|
|||
* lockdep checks for being in an RCU read-side critical section. This is
|
||||
* useful when the value of this pointer is accessed, but the pointer is
|
||||
* not dereferenced, for example, when testing an RCU-protected pointer
|
||||
* against NULL. Although rcu_access_pointer() may also be used in cases
|
||||
* where update-side locks prevent the value of the pointer from changing,
|
||||
* you should instead use rcu_dereference_protected() for this use case.
|
||||
* Within an RCU read-side critical section, there is little reason to
|
||||
* use rcu_access_pointer().
|
||||
* against NULL. Within an RCU read-side critical section, there is little
|
||||
* reason to use rcu_access_pointer(). Although rcu_access_pointer() may
|
||||
* also be used in cases where update-side locks prevent the value of the
|
||||
* pointer from changing, you should instead use rcu_dereference_protected()
|
||||
* for this use case. It is also permissible to use rcu_access_pointer()
|
||||
* within lockless updaters to obtain the old value for an atomic operation,
|
||||
* for example, for cmpxchg().
|
||||
*
|
||||
* It is usually best to test the rcu_access_pointer() return value
|
||||
* directly in order to avoid accidental dereferences being introduced
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_fast_notrace(struct srcu_
|
|||
*
|
||||
* The same srcu_struct may be used concurrently by srcu_down_read_fast()
|
||||
* and srcu_read_lock_fast(). However, the same definition/initialization
|
||||
* requirements called out for srcu_read_lock_safe() apply.
|
||||
* requirements called out for srcu_read_lock_fast_updown() apply.
|
||||
*/
|
||||
static inline struct srcu_ctr __percpu *srcu_down_read_fast(struct srcu_struct *ssp) __acquires_shared(ssp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ void _torture_stop_kthread(char *m, struct task_struct **tp);
|
|||
#else
|
||||
#define torture_preempt_schedule() do { } while (0)
|
||||
#endif
|
||||
void torture_sched_set_normal(struct task_struct *t, int nice);
|
||||
|
||||
#if IS_ENABLED(CONFIG_RCU_TORTURE_TEST) || IS_MODULE(CONFIG_RCU_TORTURE_TEST) || IS_ENABLED(CONFIG_LOCK_TORTURE_TEST) || IS_MODULE(CONFIG_LOCK_TORTURE_TEST)
|
||||
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask, bool dowarn);
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ static unsigned long rcu_no_completed(void)
|
|||
|
||||
static void rcu_torture_deferred_free(struct rcu_torture *p)
|
||||
{
|
||||
call_rcu_hurry(&p->rtort_rcu, rcu_torture_cb);
|
||||
call_rcu(&p->rtort_rcu, rcu_torture_cb);
|
||||
}
|
||||
|
||||
static void rcu_sync_torture_init(void)
|
||||
|
|
@ -619,7 +619,7 @@ static struct rcu_torture_ops rcu_ops = {
|
|||
.poll_gp_state_exp = poll_state_synchronize_rcu,
|
||||
.cond_sync_exp = cond_synchronize_rcu_expedited,
|
||||
.cond_sync_exp_full = cond_synchronize_rcu_expedited_full,
|
||||
.call = call_rcu_hurry,
|
||||
.call = call_rcu,
|
||||
.cb_barrier = rcu_barrier,
|
||||
.fqs = rcu_force_quiescent_state,
|
||||
.gp_kthread_dbg = show_rcu_gp_kthreads,
|
||||
|
|
@ -1145,7 +1145,7 @@ static void rcu_tasks_torture_deferred_free(struct rcu_torture *p)
|
|||
|
||||
static void synchronize_rcu_mult_test(void)
|
||||
{
|
||||
synchronize_rcu_mult(call_rcu_tasks, call_rcu_hurry);
|
||||
synchronize_rcu_mult(call_rcu_tasks, call_rcu);
|
||||
}
|
||||
|
||||
static struct rcu_torture_ops tasks_ops = {
|
||||
|
|
@ -1631,6 +1631,17 @@ static void do_rtws_sync(struct torture_random_state *trsp, void (*sync)(void))
|
|||
cpus_read_unlock();
|
||||
}
|
||||
|
||||
/*
|
||||
* Do an rcu_barrier() to motivate lazy callbacks during a stutter
|
||||
* pause. Without this, we can get false-positives rtort_pipe_count
|
||||
* splats.
|
||||
*/
|
||||
static void rcu_torture_writer_work(struct work_struct *work)
|
||||
{
|
||||
if (cur_ops->cb_barrier)
|
||||
cur_ops->cb_barrier();
|
||||
}
|
||||
|
||||
/*
|
||||
* RCU torture writer kthread. Repeatedly substitutes a new structure
|
||||
* for that pointed to by rcu_torture_current, freeing the old structure
|
||||
|
|
@ -1651,6 +1662,7 @@ rcu_torture_writer(void *arg)
|
|||
int i;
|
||||
int idx;
|
||||
unsigned long j;
|
||||
struct work_struct lazy_work;
|
||||
int oldnice = task_nice(current);
|
||||
struct rcu_gp_oldstate *rgo = NULL;
|
||||
int rgo_size = 0;
|
||||
|
|
@ -1703,6 +1715,9 @@ rcu_torture_writer(void *arg)
|
|||
pr_alert("%s" TORTURE_FLAG " Waited %lu jiffies for boot to complete.\n",
|
||||
torture_type, jiffies - j);
|
||||
|
||||
if (IS_ENABLED(CONFIG_RCU_LAZY))
|
||||
INIT_WORK_ONSTACK(&lazy_work, rcu_torture_writer_work);
|
||||
|
||||
do {
|
||||
rcu_torture_writer_state = RTWS_FIXED_DELAY;
|
||||
torture_hrtimeout_us(500, 1000, &rand);
|
||||
|
|
@ -1895,6 +1910,8 @@ rcu_torture_writer(void *arg)
|
|||
!rcu_gp_is_normal();
|
||||
}
|
||||
rcu_torture_writer_state = RTWS_STUTTER;
|
||||
if (IS_ENABLED(CONFIG_RCU_LAZY))
|
||||
queue_work(system_percpu_wq, &lazy_work);
|
||||
stutter_waited = stutter_wait("rcu_torture_writer");
|
||||
if (stutter_waited &&
|
||||
!atomic_read(&rcu_fwd_cb_nodelay) &&
|
||||
|
|
@ -1925,6 +1942,12 @@ rcu_torture_writer(void *arg)
|
|||
pr_alert("%s" TORTURE_FLAG
|
||||
" Dynamic grace-period expediting was disabled.\n",
|
||||
torture_type);
|
||||
|
||||
if (IS_ENABLED(CONFIG_RCU_LAZY)) {
|
||||
cancel_work_sync(&lazy_work);
|
||||
destroy_work_on_stack(&lazy_work);
|
||||
}
|
||||
|
||||
kfree(ulo);
|
||||
kfree(rgo);
|
||||
rcu_torture_writer_state = RTWS_STOPPING;
|
||||
|
|
|
|||
|
|
@ -373,7 +373,8 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
|
|||
// Queuing callbacks before initialization not yet supported.
|
||||
if (WARN_ON_ONCE(!rcu_segcblist_is_enabled(&rtpcp->cblist)))
|
||||
rcu_segcblist_init(&rtpcp->cblist);
|
||||
needwake = (func == wakeme_after_rcu) ||
|
||||
needwake = (!havekthread && rcu_segcblist_empty(&rtpcp->cblist)) ||
|
||||
(func == wakeme_after_rcu) ||
|
||||
(rcu_segcblist_n_cbs(&rtpcp->cblist) == rcu_task_lazy_lim);
|
||||
if (havekthread && !needwake && !timer_pending(&rtpcp->lazy_timer)) {
|
||||
if (rtp->lazy_jiffies)
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ static int param_set_next_fqs_jiffies(const char *val, const struct kernel_param
|
|||
int ret = kstrtoul(val, 0, &j);
|
||||
|
||||
if (!ret) {
|
||||
WRITE_ONCE(*(ulong *)kp->arg, (j > HZ) ? HZ : (j ?: 1));
|
||||
WRITE_ONCE(*(ulong *)kp->arg, clamp_val(j, 1, HZ));
|
||||
adjust_jiffies_till_sched_qs();
|
||||
}
|
||||
return ret;
|
||||
|
|
@ -1632,17 +1632,21 @@ static void rcu_sr_put_wait_head(struct llist_node *node)
|
|||
atomic_set_release(&sr_wn->inuse, 0);
|
||||
}
|
||||
|
||||
/* Enable rcu_normal_wake_from_gp automatically on small systems. */
|
||||
#define WAKE_FROM_GP_CPU_THRESHOLD 16
|
||||
|
||||
static int rcu_normal_wake_from_gp = -1;
|
||||
static int rcu_normal_wake_from_gp = 1;
|
||||
module_param(rcu_normal_wake_from_gp, int, 0644);
|
||||
static struct workqueue_struct *sync_wq;
|
||||
|
||||
#define RCU_SR_NORMAL_LATCH_THR 64
|
||||
|
||||
/* Number of in-flight synchronize_rcu() calls queued on srs_next. */
|
||||
static atomic_long_t rcu_sr_normal_count;
|
||||
static int rcu_sr_normal_latched; /* 0/1 */
|
||||
|
||||
static void rcu_sr_normal_complete(struct llist_node *node)
|
||||
{
|
||||
struct rcu_synchronize *rs = container_of(
|
||||
(struct rcu_head *) node, struct rcu_synchronize, head);
|
||||
long nr;
|
||||
|
||||
WARN_ONCE(IS_ENABLED(CONFIG_PROVE_RCU) &&
|
||||
!poll_state_synchronize_rcu_full(&rs->oldstate),
|
||||
|
|
@ -1650,6 +1654,15 @@ static void rcu_sr_normal_complete(struct llist_node *node)
|
|||
|
||||
/* Finally. */
|
||||
complete(&rs->completion);
|
||||
nr = atomic_long_dec_return(&rcu_sr_normal_count);
|
||||
WARN_ON_ONCE(nr < 0);
|
||||
|
||||
/*
|
||||
* Unlatch: switch back to normal path when fully
|
||||
* drained and if it has been latched.
|
||||
*/
|
||||
if (nr == 0)
|
||||
(void)cmpxchg_relaxed(&rcu_sr_normal_latched, 1, 0);
|
||||
}
|
||||
|
||||
static void rcu_sr_normal_gp_cleanup_work(struct work_struct *work)
|
||||
|
|
@ -1795,6 +1808,24 @@ static bool rcu_sr_normal_gp_init(void)
|
|||
|
||||
static void rcu_sr_normal_add_req(struct rcu_synchronize *rs)
|
||||
{
|
||||
/*
|
||||
* Increment before publish to avoid a complete
|
||||
* vs enqueue race on latch.
|
||||
*/
|
||||
long nr = atomic_long_inc_return(&rcu_sr_normal_count);
|
||||
|
||||
/*
|
||||
* Latch when threshold is reached. Checking for an exact match
|
||||
* restricts cmpxchg() to a single context.
|
||||
*
|
||||
* This latch is intentionally relaxed and best-effort. Concurrent
|
||||
* set/clear can race and temporarily lose the latch, which is OK
|
||||
* because it only selects between the fast and fallback paths.
|
||||
*/
|
||||
if (nr == RCU_SR_NORMAL_LATCH_THR)
|
||||
(void)cmpxchg_relaxed(&rcu_sr_normal_latched, 0, 1);
|
||||
|
||||
/* Publish for the GP kthread/worker. */
|
||||
llist_add((struct llist_node *) &rs->head, &rcu_state.srs_next);
|
||||
}
|
||||
|
||||
|
|
@ -2584,7 +2615,7 @@ static void rcu_do_batch(struct rcu_data *rdp)
|
|||
const long npj = NSEC_PER_SEC / HZ;
|
||||
long rrn = READ_ONCE(rcu_resched_ns);
|
||||
|
||||
rrn = rrn < NSEC_PER_MSEC ? NSEC_PER_MSEC : rrn > NSEC_PER_SEC ? NSEC_PER_SEC : rrn;
|
||||
rrn = clamp(rrn, NSEC_PER_MSEC, NSEC_PER_SEC);
|
||||
tlimit = local_clock() + rrn;
|
||||
jlimit = jiffies + (rrn + npj + 1) / npj;
|
||||
jlimit_check = true;
|
||||
|
|
@ -3278,14 +3309,15 @@ static void synchronize_rcu_normal(void)
|
|||
{
|
||||
struct rcu_synchronize rs;
|
||||
|
||||
init_rcu_head_on_stack(&rs.head);
|
||||
trace_rcu_sr_normal(rcu_state.name, &rs.head, TPS("request"));
|
||||
|
||||
if (READ_ONCE(rcu_normal_wake_from_gp) < 1) {
|
||||
if (READ_ONCE(rcu_normal_wake_from_gp) < 1 ||
|
||||
READ_ONCE(rcu_sr_normal_latched)) {
|
||||
wait_rcu_gp(call_rcu_hurry);
|
||||
goto trace_complete_out;
|
||||
}
|
||||
|
||||
init_rcu_head_on_stack(&rs.head);
|
||||
init_completion(&rs.completion);
|
||||
|
||||
/*
|
||||
|
|
@ -3302,10 +3334,10 @@ static void synchronize_rcu_normal(void)
|
|||
|
||||
/* Now we can wait. */
|
||||
wait_for_completion(&rs.completion);
|
||||
destroy_rcu_head_on_stack(&rs.head);
|
||||
|
||||
trace_complete_out:
|
||||
trace_rcu_sr_normal(rcu_state.name, &rs.head, TPS("complete"));
|
||||
destroy_rcu_head_on_stack(&rs.head);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -4904,12 +4936,6 @@ void __init rcu_init(void)
|
|||
sync_wq = alloc_workqueue("sync_wq", WQ_MEM_RECLAIM | WQ_UNBOUND, 0);
|
||||
WARN_ON(!sync_wq);
|
||||
|
||||
/* Respect if explicitly disabled via a boot parameter. */
|
||||
if (rcu_normal_wake_from_gp < 0) {
|
||||
if (num_possible_cpus() <= WAKE_FROM_GP_CPU_THRESHOLD)
|
||||
rcu_normal_wake_from_gp = 1;
|
||||
}
|
||||
|
||||
/* Fill in default value for rcutree.qovld boot parameter. */
|
||||
/* -After- the rcu_node ->lock fields are initialized! */
|
||||
if (qovld < 0)
|
||||
|
|
|
|||
|
|
@ -655,7 +655,7 @@ static void nocb_gp_sleep(struct rcu_data *my_rdp, int cpu)
|
|||
* No-CBs GP kthreads come here to wait for additional callbacks to show up
|
||||
* or for grace periods to end.
|
||||
*/
|
||||
static void nocb_gp_wait(struct rcu_data *my_rdp)
|
||||
static noinline_for_stack void nocb_gp_wait(struct rcu_data *my_rdp)
|
||||
{
|
||||
bool bypass = false;
|
||||
int __maybe_unused cpu = my_rdp->cpu;
|
||||
|
|
|
|||
|
|
@ -972,3 +972,19 @@ void _torture_stop_kthread(char *m, struct task_struct **tp)
|
|||
*tp = NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(_torture_stop_kthread);
|
||||
|
||||
/*
|
||||
* Set the specified task's niceness value, saturating at limits.
|
||||
* Saturating noisily, but saturating.
|
||||
*/
|
||||
void torture_sched_set_normal(struct task_struct *t, int nice)
|
||||
{
|
||||
int realnice = nice;
|
||||
|
||||
if (WARN_ON_ONCE(realnice > MAX_NICE))
|
||||
realnice = MAX_NICE;
|
||||
if (WARN_ON_ONCE(realnice < MIN_NICE))
|
||||
realnice = MIN_NICE;
|
||||
sched_set_normal(t, realnice);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(torture_sched_set_normal);
|
||||
|
|
|
|||
|
|
@ -865,8 +865,6 @@ our %deprecated_apis = (
|
|||
"DEFINE_IDR" => "DEFINE_XARRAY",
|
||||
"idr_init" => "xa_init",
|
||||
"idr_init_base" => "xa_init_flags",
|
||||
"rcu_read_lock_trace" => "rcu_read_lock_tasks_trace",
|
||||
"rcu_read_unlock_trace" => "rcu_read_unlock_tasks_trace",
|
||||
);
|
||||
|
||||
#Create a search pattern for all these strings to speed up a loop below
|
||||
|
|
@ -7596,12 +7594,15 @@ sub process {
|
|||
|
||||
# Complain about RCU Tasks Trace used outside of BPF (and of course, RCU).
|
||||
our $rcu_trace_funcs = qr{(?x:
|
||||
rcu_read_lock_tasks_trace |
|
||||
rcu_read_lock_trace |
|
||||
rcu_read_lock_trace_held |
|
||||
rcu_read_unlock_trace |
|
||||
rcu_read_unlock_tasks_trace |
|
||||
call_rcu_tasks_trace |
|
||||
synchronize_rcu_tasks_trace |
|
||||
rcu_barrier_tasks_trace |
|
||||
rcu_tasks_trace_expedite_current |
|
||||
rcu_request_urgent_qs_task
|
||||
)};
|
||||
our $rcu_trace_paths = qr{(?x:
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Usage: kvm-series.sh config-list commit-id-list [ kvm.sh parameters ]
|
||||
# Usage: kvm-series.sh config-list commit-id-range [ kvm.sh parameters ]
|
||||
#
|
||||
# Tests the specified list of unadorned configs ("TREE01 SRCU-P" but not
|
||||
# "CFLIST" or "3*TRACE01") and an indication of a set of commits to test,
|
||||
# then runs each commit through the specified list of commits using kvm.sh.
|
||||
# The runs are grouped into a -series/config/commit directory tree.
|
||||
# Tests the specified list of unadorned configs ("TREE01 SRCU-P" but
|
||||
# not "CFLIST" or "3*TRACE01") and an indication of a range of commits
|
||||
# ("v7.0-rc1..rcu/dev", but not "cd0ce7bab0408 ff74db28df623 17c52d7b31a1f")
|
||||
# to test, then runs each commit through the specified list of commits using
|
||||
# kvm.sh. The runs are grouped into a -series/config/commit directory tree.
|
||||
# Each run defaults to a duration of one minute.
|
||||
#
|
||||
# Run in top-level Linux source directory. Please note that this is in
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ do
|
|||
do_clocksourcewd=no
|
||||
do_srcu_lockdep=no
|
||||
;;
|
||||
--do-normal|--do-no-normal|--no-normal)
|
||||
--do-normal|--do-norm|--do-no-normal|--do-no-norm|--no-normal|--no-norm)
|
||||
do_normal=`doyesno "$1" --do-normal`
|
||||
explicit_normal=yes
|
||||
;;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user