/* One element of the srcu_data srcu_ctrs array. */ struct srcu_ctr {
atomic_long_t srcu_locks; /* Locks per CPU. */
atomic_long_t srcu_unlocks; /* Unlocks per CPU. */
};
/* *Per-CPUstructurefeedingintoleafsrcu_node,similarinfunction *torcu_node.
*/ struct srcu_data { /* Read-side state. */ struct srcu_ctr srcu_ctrs[2]; /* Locks and unlocks per CPU. */ int srcu_reader_flavor; /* Reader flavor for srcu_struct structure? */ /* Values: SRCU_READ_FLAVOR_.* */
/* Update-side state. */
spinlock_t __private lock ____cacheline_internodealigned_in_smp; struct rcu_segcblist srcu_cblist; /* List of callbacks.*/ unsignedlong srcu_gp_seq_needed; /* Furthest future GP needed. */ unsignedlong srcu_gp_seq_needed_exp; /* Furthest future exp GP. */ bool srcu_cblist_invoking; /* Invoking these CBs? */ struct timer_list delay_work; /* Delay for CB invoking */ struct work_struct work; /* Context for CB invoking. */ struct rcu_head srcu_barrier_head; /* For srcu_barrier() use. */ struct srcu_node *mynode; /* Leaf srcu_node. */ unsignedlong grpmask; /* Mask for leaf srcu_node */ /* ->srcu_data_have_cbs[]. */ int cpu; struct srcu_struct *ssp;
};
/* *NodeinSRCUcombiningtree,similarinfunctiontorcu_data.
*/ struct srcu_node {
spinlock_t __private lock; unsignedlong srcu_have_cbs[4]; /* GP seq for children having CBs, but only */ /* if greater than ->srcu_gp_seq. */ unsignedlong srcu_data_have_cbs[4]; /* Which srcu_data structs have CBs for given GP? */ unsignedlong srcu_gp_seq_needed_exp; /* Furthest future exp GP. */ struct srcu_node *srcu_parent; /* Next up in tree. */ int grplo; /* Least CPU for node. */ int grphi; /* Biggest CPU for node. */
};
/* *Per-SRCU-domainstructure,update-sidedatalinkedfromsrcu_struct.
*/ struct srcu_usage { struct srcu_node *node; /* Combining tree. */ struct srcu_node *level[RCU_NUM_LVLS + 1]; /* First node at each level. */ int srcu_size_state; /* Small-to-big transition state. */ struct mutex srcu_cb_mutex; /* Serialize CB preparation. */
spinlock_t __private lock; /* Protect counters and size state. */ struct mutex srcu_gp_mutex; /* Serialize GP work. */ unsignedlong srcu_gp_seq; /* Grace-period seq #. */ unsignedlong srcu_gp_seq_needed; /* Latest gp_seq needed. */ unsignedlong srcu_gp_seq_needed_exp; /* Furthest future exp GP. */ unsignedlong srcu_gp_start; /* Last GP start timestamp (jiffies) */ unsignedlong srcu_last_gp_end; /* Last GP end timestamp (ns) */ unsignedlong srcu_size_jiffies; /* Current contention-measurement interval. */ unsignedlong srcu_n_lock_retries; /* Contention events in current interval. */ unsignedlong srcu_n_exp_nodelay; /* # expedited no-delays in current GP phase. */ bool sda_is_static; /* May ->sda be passed to free_percpu()? */ unsignedlong srcu_barrier_seq; /* srcu_barrier seq #. */ struct mutex srcu_barrier_mutex; /* Serialize barrier ops. */ struct completion srcu_barrier_completion; /* Awaken barrier rq at end. */
atomic_t srcu_barrier_cpu_cnt; /* # CPUs not yet posting a */ /* callback for the barrier */ /* operation. */ unsignedlong reschedule_jiffies; unsignedlong reschedule_count; struct delayed_work work; struct srcu_struct *srcu_ssp;
};
// Values for size state variable (->srcu_size_state). Once the state // has been set to SRCU_SIZE_ALLOC, the grace-period code advances through // this state machine one step per grace period until the SRCU_SIZE_BIG state // is reached. Otherwise, the state machine remains in the SRCU_SIZE_SMALL // state indefinitely. #define SRCU_SIZE_SMALL 0// No srcu_node combining tree, ->node == NULL #define SRCU_SIZE_ALLOC 1// An srcu_node tree is being allocated, initialized, // and then referenced by ->node. It will not be used. #define SRCU_SIZE_WAIT_BARRIER 2// The srcu_node tree starts being used by everything // except call_srcu(), especially by srcu_barrier(). // By the end of this state, all CPUs and threads // are aware of this tree's existence. #define SRCU_SIZE_WAIT_CALL 3// The srcu_node tree starts being used by call_srcu(). // By the end of this state, all of the call_srcu() // invocations that were running on a non-boot CPU // and using the boot CPU's callback queue will have // completed. #define SRCU_SIZE_WAIT_CBS1 4// Don't trust the ->srcu_have_cbs[] grace-period #define SRCU_SIZE_WAIT_CBS2 5// sequence elements or the ->srcu_data_have_cbs[] #define SRCU_SIZE_WAIT_CBS3 6// CPU-bitmask elements until all four elements of #define SRCU_SIZE_WAIT_CBS4 7// each array have been initialized. #define SRCU_SIZE_BIG 8// The srcu_node combining tree is fully initialized // and all aspects of it are being put to use.
/* Values for state variable (bottom bits of ->srcu_gp_seq). */ #define SRCU_STATE_IDLE 0 #define SRCU_STATE_SCAN1 1 #define SRCU_STATE_SCAN2 2
// Converts a per-CPU pointer to an ->srcu_ctrs[] array element to that // element's index. staticinlinebool __srcu_ptr_to_ctr(struct srcu_struct *ssp, struct srcu_ctr __percpu *scpp)
{ return scpp - &ssp->sda->srcu_ctrs[0];
}
// Converts an integer to a per-CPU pointer to the corresponding // ->srcu_ctrs[] array element. staticinlinestruct srcu_ctr __percpu *__srcu_ctr_to_ptr(struct srcu_struct *ssp, int idx)
{ return &ssp->sda->srcu_ctrs[idx];
}
RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_lock_fast()."); if (!IS_ENABLED(CONFIG_NEED_SRCU_NMI_SAFE))
this_cpu_inc(scp->srcu_locks.counter); /* Y */ else
atomic_long_inc(raw_cpu_ptr(&scp->srcu_locks)); /* Z */
barrier(); /* Avoid leaking the critical section. */ return scp;
}
/* *Removesthecountfortheoldreaderfromtheappropriate *per-CPUelementofthesrcu_struct.Notethatthismaywellbea *differentCPUthanthatwhichwasincrementedbythecorresponding *srcu_read_lock_fast(),butitmustbewithinthesametask. * *Notethatboththis_cpu_inc()andatomic_long_inc()areRCUread-side *criticalsectionseitherbecausetheydisablesinterrupts,becausethey *areasingleinstruction,orbecausetheyarearead-modify-writeatomic *operation,dependingonthewhimsofthearchitecture. * *Thismeansthat__srcu_read_unlock_fast()isnotallthatfast *onarchitecturesthatsupportNMIsbutdonotsupplyNMI-safe *implementationsofthis_cpu_inc().
*/ staticinlinevoid __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ctr __percpu *scp)
{
barrier(); /* Avoid leaking the critical section. */ if (!IS_ENABLED(CONFIG_NEED_SRCU_NMI_SAFE))
this_cpu_inc(scp->srcu_unlocks.counter); /* Z */ else
atomic_long_inc(raw_cpu_ptr(&scp->srcu_unlocks)); /* Z */
RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_fast().");
}
void __srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor);
// Record reader usage even for CONFIG_PROVE_RCU=n kernels. This is // needed only for flavors that require grace-period smp_mb() calls to be // promoted to synchronize_rcu(). staticinlinevoid srcu_check_read_flavor_force(struct srcu_struct *ssp, int read_flavor)
{ struct srcu_data *sdp = raw_cpu_ptr(ssp->sda);
if (likely(READ_ONCE(sdp->srcu_reader_flavor) & read_flavor)) return;
// Note that the cmpxchg() in __srcu_check_read_flavor() is fully ordered.
__srcu_check_read_flavor(ssp, read_flavor);
}
// Record non-_lite() usage only for CONFIG_PROVE_RCU=y kernels. staticinlinevoid srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor)
{ if (IS_ENABLED(CONFIG_PROVE_RCU))
__srcu_check_read_flavor(ssp, read_flavor);
}
#endif
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.31 Sekunden
(vorverarbeitet am 2026-09-29)
¤
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.