[email protected] (YAMAMOTO Takashi) wrote: > >> which spends (on x86) a small but not immeasurable amount of time in > >> splx(s), so I was tempted to rewrite it like this: > >> > >> void > >> mbstat_type_add(int type, int diff) > >> { > >> struct mbstat_cpu *mb; > >> > >> mb = percpu_getref(mbstat_percpu); > >> atomic_add_uint_ni(&mb->m_mtypes[type], diff); > >> percpu_putref(mbstat_percpu); > >> } > >> > >> There is no such routine as atomic_add_uint_ni(), though, and I don't > >> know if every NetBSD architecture can supply that routine. > > > > Right, spl*()/splx() have a cost. However, code like this (networking) > > should not be in the hard-interrupt handler. As we move towards a wider > > use of software interrupts, SPL calls will disappear and kernel > > preemption provides the necessary protection (although software > > interrupts are not yet preemptable). > > iirc kpreempt_disable() doesn't provide a protection from a softint. >
You are right, sorry. I was thinking of soft-interrupt internals, where more or less the same mechanism as for kernel preemption is used.. > YAMAMOTO Takashi > -- Mindaugas
