mem_cgroup_scan_tasks(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… mem_cgroup_scan_tasks(9) β€” the Kernel API Manual glow-up

okay so bestie, welcome to the Kernel API Manual entry for mem_cgroup_scan_tasks, and trust me when I say this one is short and sweet but you cannot skip the last line of the description, okay? πŸ‘€


✨ SYNOPSIS ✨

void mem_cgroup_scan_tasks (struct mem_cgroup *memcg , int (*fn)(struct
task_struct *, void *) , void *arg );

πŸŽ€ ARGUMENTS πŸŽ€

  • memcg β€” the hierarchy root you're starting from πŸ‘‘
  • fn β€” the function that gets called for each task, like a little callback bestie 🫢
  • arg β€” the argument that gets passed along to fn 🎁

🌸 DESCRIPTION 🌸

So here's the vibe: this function iterates over the tasks attached to memcg or to any of its descendants β€” so the whole tree, not just the top level, iykyk β€” and it calls fn for each task. πŸ’«

If fn returns a non-zero value, the function breaks the iteration loop right there. Otherwise, it just keeps going through all the tasks and returns 0. periodt βœ‹

🚨 WARNING, no cap: this function must not be called for the root memory cgroup. Like, don't do it. It's giving undefined-vibes and we are not about that. πŸ™ˆ

πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./mm/memcontrol.c β€” and honestly the whole friend group is here, so let's shout them out one by one πŸ’–: get_mem_cgroup_css_from_folio(9), page_cgroup_ino(9), lruvec_page_state_monotonic(9), mod_memcg_state(9), mod_lruvec_state(9), count_memcg_events(9), get_mem_cgroup_from_mm(9), get_mem_cgroup_from_current(9), get_mem_cgroup_from_folio(9), mem_cgroup_iter(9), mem_cgroup_iter_break(9), folio_lruvec_lock(9), folio_lruvec_lock_irq(9), folio_lruvec_lock_irqsave(9), mem_cgroup_update_lru_size(9), mem_cgroup_margin(9), mem_cgroup_print_oom_context(9), mem_cgroup_print_oom_meminfo(9), mem_cgroup_get_oom_group(9), consume_stock(9), __memcg_kmem_charge_page(9), __memcg_kmem_uncharge_page(9), mem_cgroup_wb_stats(9), mem_cgroup_from_private_id(9), mem_cgroup_css_reset(9), mem_cgroup_calculate_protection(9), mem_cgroup_charge_hugetlb(9), mem_cgroup_swapin_charge_folio(9), mem_cgroup_replace_folio(9), mem_cgroup_migrate(9), mem_cgroup_sk_charge(9), mem_cgroup_sk_uncharge(9), __mem_cgroup_try_charge_swap(9), __mem_cgroup_uncharge_swap(9), obj_cgroup_may_zswap(9), obj_cgroup_charge_zswap(9), obj_cgroup_uncharge_zswap(9). literally the entire group chat πŸ§šβ€β™€οΈ


and that's the page, bestie β€” go read the whole ./mm source tree if you're feeling main character energy πŸ’…βœ¨ this one's dated October 2026 and it's brought to you by mem_cgroup_scan_tasks(9), signing off πŸŽ€πŸ¦‹β­

πŸ“¦ where this page comes from