update_tg_load_avg(9)
π update_tg_load_avg(9) π
okay so bestie, we're deep in the Kernel API Manual today β yes, the actual kernel, yes, the scheduler, don't panic, I got you π«Ά this one is a little CFS scheduling function and it's honestly not that deep once you see what it's doing. let's go β¨
πΈ NAME πΈ
update_tg_load_avg β update the tg's load avg. that's it, that's the whole name, and honestly it ate π
π SYNOPSIS π
void update_tg_load_avg (struct cfs_rq *cfs_rq );
it returns void, so like... don't go looking for a return value, there isn't one, she gives nothing back, she just does π
π¦ ARGUMENTS π¦
cfs_rqβ thecfs_rqwhose avg changed. that's the one you're handing over, the one that moved, the main character of this call π
β¨ DESCRIPTION β¨
so this function 'ensures' β and yes the manpage itself put 'ensures' in quotes like that, iconic of it β that:
tg->load_avg := tg->cfs_rq[]->avg.load
but here's the plot twist π because tg->load_avg is a global value, there are performance considerations. like, real ones. the vibe check says: don't be out here doing expensive things in a hot path, bestie.
so how do we dodge that? in order to avoid having to look at the other cfs_rq's, we use a differential update where we store the last value we propagated π that's the whole trick.
and this in turn allows skipping updates if the differential is 'small' β again with the quotes, and again, that's literally what the page says, I'm not making this up π so yeah, small diff = we can skip, and that's a slay for your CPU cycles fr fr.
β key thing to remember: updating tg'sload_avgis necessary beforeupdate_cfs_group. not optional, not "if you feel like it", it's a prerequisite. do it first, periodt.
π SEE ALSO π
- Kernel file
./kernel/sched/fair.cβ like, the actual source, go read it, iykyk π update_cfs_rq_load_avg(9)attach_entity_load_avg(9)detach_entity_load_avg(9)cpu_util(9)sched_use_asym_prio(9)sched_group_asym(9)update_sg_lb_stats(9)update_sd_pick_busiest(9)idle_cpu_without(9)update_sd_lb_stats(9)calculate_imbalance(9)sched_balance_find_src_group(9)
and that's the whole page bestie, you're officially caught up on load average propagation π§π this came to you from the ./kernel/sched directory, and the page is dated October 2026 β so yeah, future-coded of it, we love a timestamp with range πΈ bye, go read update_cfs_group next, mwah ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms