summaryrefslogtreecommitdiff
path: root/lib/rcu.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-01-19 10:49:47 +0100
committerMaria Matejka <mq@ucw.cz>2023-01-19 11:13:50 +0100
commit84c298465f6360a8694d4837f3420961ea321fa5 (patch)
tree273455bf0e6f1b7a1be8956692feacbf6b3484a3 /lib/rcu.h
parent4d8d81f144e72fe2e182d7569087f2a8c8c5b938 (diff)
Decoupling loops from threads to allow fixed thread count
On large configurations, too many threads would spawn with one thread per loop. Therefore, threads may now run multiple loops at once. The thread count is configurable and may be changed during run. All threads are spawned on startup. This change helps with memory bloating. BIRD filters need large temporary memory blocks to store their stack and also memory management keeps its hot page storage per-thread. Known bugs: * Thread autobalancing is not yet implemented. * Low latency loops are executed together with standard loops.
Diffstat (limited to 'lib/rcu.h')
-rw-r--r--lib/rcu.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/rcu.h b/lib/rcu.h
index c537a1ef..30eacc5b 100644
--- a/lib/rcu.h
+++ b/lib/rcu.h
@@ -21,33 +21,33 @@
extern _Atomic uint rcu_gp_ctl;
-struct rcu_birdloop {
+struct rcu_thread {
node n;
_Atomic uint ctl;
};
-extern _Thread_local struct rcu_birdloop *this_rcu_birdloop;
+extern _Thread_local struct rcu_thread *this_rcu_thread;
static inline void rcu_read_lock(void)
{
- uint cmp = atomic_load_explicit(&this_rcu_birdloop->ctl, memory_order_acquire);
+ uint cmp = atomic_load_explicit(&this_rcu_thread->ctl, memory_order_acquire);
if (cmp & RCU_NEST_MASK)
- atomic_store_explicit(&this_rcu_birdloop->ctl, cmp + RCU_NEST_CNT, memory_order_relaxed);
+ atomic_store_explicit(&this_rcu_thread->ctl, cmp + RCU_NEST_CNT, memory_order_relaxed);
else
- atomic_store(&this_rcu_birdloop->ctl, atomic_load_explicit(&rcu_gp_ctl, memory_order_acquire));
+ atomic_store(&this_rcu_thread->ctl, atomic_load_explicit(&rcu_gp_ctl, memory_order_acquire));
}
static inline void rcu_read_unlock(void)
{
- atomic_fetch_sub(&this_rcu_birdloop->ctl, RCU_NEST_CNT);
+ atomic_fetch_sub(&this_rcu_thread->ctl, RCU_NEST_CNT);
}
void synchronize_rcu(void);
/* Registering and unregistering a birdloop. To be called from birdloop implementation */
-void rcu_birdloop_start(struct rcu_birdloop *);
-void rcu_birdloop_stop(struct rcu_birdloop *);
+void rcu_thread_start(struct rcu_thread *);
+void rcu_thread_stop(struct rcu_thread *);
/* Run this from resource init */
void rcu_init(void);