Lines Matching refs:css
18 * Determines whether a given css can participate in rstat.
19 * css's that are cgroup::self use rstat for base stats.
20 * Other css's associated with a subsystem use rstat only when
23 static inline bool css_uses_rstat(struct cgroup_subsys_state *css)
25 return css_is_self(css) || css->ss->css_rstat_flush != NULL;
29 struct cgroup_subsys_state *css, int cpu)
31 return per_cpu_ptr(css->rstat_cpu, cpu);
57 * @css: target cgroup subsystem state
60 * Atomically inserts the css in the ss's llist for the given cpu. This is
70 __bpf_kfunc void css_rstat_updated(struct cgroup_subsys_state *css, int cpu)
80 if (!css_uses_rstat(css))
93 rstatc = css_rstat_cpu(css, cpu);
124 lhead = ss_lhead_cpu(css->ss, cpu);
128 static void __css_process_update_tree(struct cgroup_subsys_state *css, int cpu)
130 /* put @css and all ancestors on the corresponding updated lists */
132 struct css_rstat_cpu *rstatc = css_rstat_cpu(css, cpu);
133 struct cgroup_subsys_state *parent = css->parent;
145 rstatc->updated_next = css;
151 prstatc->updated_children = css;
153 css = parent;
186 * css_rstat_push_children - push children css's into the given list
190 * Return: A new singly linked list of css's to be flushed
195 * tail backward like "pushing" css's into a stack. The root is pushed by
202 struct cgroup_subsys_state *cnext = child; /* Next head of child css level */
203 struct cgroup_subsys_state *ghead = NULL; /* Head of grandchild css level */
264 * css_rstat_updated_list - build a list of updated css's to be flushed
265 * @root: root of the css subtree to traverse
267 * Return: A singly linked list of css's to be flushed
270 * each returned css is unlinked from the updated tree.
277 * child css's if not empty. Whereas updated_next is like a sibling link
278 * within the children list and terminated by the parent css. An exception
279 * here is the css root whose updated_next can be self terminated.
358 static inline void __css_rstat_lock(struct cgroup_subsys_state *css,
360 __acquires(ss_rstat_lock(css->ss))
362 struct cgroup *cgrp = css->cgroup;
366 lock = ss_rstat_lock(css->ss);
375 static inline void __css_rstat_unlock(struct cgroup_subsys_state *css,
377 __releases(ss_rstat_lock(css->ss))
379 struct cgroup *cgrp = css->cgroup;
382 lock = ss_rstat_lock(css->ss);
388 * css_rstat_flush - flush stats in @css's rstat subtree
389 * @css: target cgroup subsystem state
391 * Collect all per-cpu stats in @css's subtree into the global counters
395 * This also gets all rstat nodes in the subtree including @css off the
400 __bpf_kfunc void css_rstat_flush(struct cgroup_subsys_state *css)
403 bool is_self = css_is_self(css);
409 if (!css_uses_rstat(css))
417 __css_rstat_lock(css, cpu);
418 pos = css_rstat_updated_list(css, cpu);
427 __css_rstat_unlock(css, cpu);
433 int css_rstat_init(struct cgroup_subsys_state *css)
435 struct cgroup *cgrp = css->cgroup;
437 bool is_self = css_is_self(css);
446 } else if (css->ss->css_rstat_flush == NULL)
449 /* the root cgrp's self css has rstat_cpu preallocated */
450 if (!css->rstat_cpu) {
451 css->rstat_cpu = alloc_percpu(struct css_rstat_cpu);
452 if (!css->rstat_cpu) {
462 struct css_rstat_cpu *rstatc = css_rstat_cpu(css, cpu);
464 rstatc->owner = rstatc->updated_children = css;
478 void css_rstat_exit(struct cgroup_subsys_state *css)
482 if (!css_uses_rstat(css))
485 if (!css->rstat_cpu)
488 css_rstat_flush(css);
492 struct css_rstat_cpu *rstatc = css_rstat_cpu(css, cpu);
494 if (WARN_ON_ONCE(rstatc->updated_children != css) ||
499 if (css_is_self(css)) {
500 struct cgroup *cgrp = css->cgroup;
506 free_percpu(css->rstat_cpu);
507 css->rstat_cpu = NULL;