int __init_srcu_struct(struct srcu_struct *ssp, constchar *name, struct lock_class_key *key)
{ /* Don't re-initialize a lock while it is held. */
debug_check_no_locks_freed((void *)ssp, sizeof(*ssp));
lockdep_init_map(&ssp->dep_map, name, key, 0); return init_srcu_struct_fields(ssp);
}
EXPORT_SYMBOL_GPL(__init_srcu_struct);
#else/* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
/* * init_srcu_struct - initialize a sleep-RCU structure * @ssp: structure to initialize. * * Must invoke this on a given srcu_struct before passing that srcu_struct * to any other function. Each srcu_struct represents a separate domain * of SRCU protection.
*/ int init_srcu_struct(struct srcu_struct *ssp)
{ return init_srcu_struct_fields(ssp);
}
EXPORT_SYMBOL_GPL(init_srcu_struct);
#endif/* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
/* * cleanup_srcu_struct - deconstruct a sleep-RCU structure * @ssp: structure to clean up. * * Must invoke this after you are finished using a given srcu_struct that * was initialized via init_srcu_struct(), else you leak memory.
*/ void cleanup_srcu_struct(struct srcu_struct *ssp)
{
WARN_ON(ssp->srcu_lock_nesting[0] || ssp->srcu_lock_nesting[1]);
flush_work(&ssp->srcu_work);
WARN_ON(ssp->srcu_gp_running);
WARN_ON(ssp->srcu_gp_waiting);
WARN_ON(ssp->srcu_cb_head);
WARN_ON(&ssp->srcu_cb_head != ssp->srcu_cb_tail);
WARN_ON(ssp->srcu_idx != ssp->srcu_idx_max);
WARN_ON(ssp->srcu_idx & 0x1);
}
EXPORT_SYMBOL_GPL(cleanup_srcu_struct);
/* * Removes the count for the old reader from the appropriate element of * the srcu_struct.
*/ void __srcu_read_unlock(struct srcu_struct *ssp, int idx)
{ int newval;
/* * Workqueue handler to drive one grace period and invoke any callbacks * that become ready as a result. Single-CPU and !PREEMPTION operation * means that we get away with murder on synchronization. ;-)
*/ void srcu_drive_gp(struct work_struct *wp)
{ int idx; struct rcu_head *lh; struct rcu_head *rhp; struct srcu_struct *ssp;
ssp = container_of(wp, struct srcu_struct, srcu_work);
preempt_disable(); // Needed for PREEMPT_LAZY if (ssp->srcu_gp_running || ULONG_CMP_GE(ssp->srcu_idx, READ_ONCE(ssp->srcu_idx_max))) {
preempt_enable(); return; /* Already running or nothing to do. */
}
/* Invoke the callbacks we removed above. */ while (lh) {
rhp = lh;
lh = lh->next;
debug_rcu_head_callback(rhp);
local_bh_disable();
rhp->func(rhp);
local_bh_enable();
}
/* * Enable rescheduling, and if there are more callbacks, * reschedule ourselves. This can race with a call_srcu() * at interrupt level, but the ->srcu_gp_running checks will * straighten that out.
*/
preempt_disable(); // Needed for PREEMPT_LAZY
WRITE_ONCE(ssp->srcu_gp_running, false);
idx = ULONG_CMP_LT(ssp->srcu_idx, READ_ONCE(ssp->srcu_idx_max));
preempt_enable(); if (idx)
schedule_work(&ssp->srcu_work);
}
EXPORT_SYMBOL_GPL(srcu_drive_gp);
lockdep_assert_preemption_disabled(); // Needed for PREEMPT_LAZY
cookie = get_state_synchronize_srcu(ssp); if (ULONG_CMP_GE(READ_ONCE(ssp->srcu_idx_max), cookie)) { return;
}
WRITE_ONCE(ssp->srcu_idx_max, cookie); if (!READ_ONCE(ssp->srcu_gp_running)) { if (likely(srcu_init_done))
schedule_work(&ssp->srcu_work); elseif (list_empty(&ssp->srcu_work.entry))
list_add(&ssp->srcu_work.entry, &srcu_boot_list);
}
}
/* * Enqueue an SRCU callback on the specified srcu_struct structure, * initiating grace-period processing if it is not already running.
*/ void call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp,
rcu_callback_t func)
{ unsignedlong flags;
/* * start_poll_synchronize_srcu - Provide cookie and start grace period * * The difference between this and get_state_synchronize_srcu() is that * this function ensures that the poll_state_synchronize_srcu() will * eventually return the value true.
*/ unsignedlong start_poll_synchronize_srcu(struct srcu_struct *ssp)
{ unsignedlong ret;
preempt_disable(); // Needed for PREEMPT_LAZY
ret = get_state_synchronize_srcu(ssp);
srcu_gp_start_if_needed(ssp);
preempt_enable(); return ret;
}
EXPORT_SYMBOL_GPL(start_poll_synchronize_srcu);
/* * Queue work for srcu_struct structures with early boot callbacks. * The work won't actually execute until the workqueue initialization * phase that takes place after the scheduler starts.
*/ void __init srcu_init(void)
{ struct srcu_struct *ssp;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.