Lines Matching +full:pre +full:- +full:processing
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include "../cgroup/cgroup-internal.h" /* cgroup_mutex and cgroup_is_dead */
13 * 1. Walk the descendants of a cgroup in pre-order.
14 * 2. Walk the descendants of a cgroup in post-order.
18 * For walking descendants, cgroup_iter can walk in either pre-order or
19 * post-order. For walking ancestors, the iter walks up from a cgroup to
25 * The prog can check (seq->num == 0) to determine whether this is
28 * do post-processing, such as outputting an epilogue.
59 struct cgroup_iter_priv *p = seq->private; in cgroup_iter_seq_start()
65 if (p->visited_all) in cgroup_iter_seq_start()
69 * return -EOPNOTSUPP to indicate incomplete iteration. in cgroup_iter_seq_start()
71 return ERR_PTR(-EOPNOTSUPP); in cgroup_iter_seq_start()
75 p->terminate = false; in cgroup_iter_seq_start()
76 p->visited_all = false; in cgroup_iter_seq_start()
77 if (p->order == BPF_CGROUP_ITER_DESCENDANTS_PRE) in cgroup_iter_seq_start()
78 return css_next_descendant_pre(NULL, p->start_css); in cgroup_iter_seq_start()
79 else if (p->order == BPF_CGROUP_ITER_DESCENDANTS_POST) in cgroup_iter_seq_start()
80 return css_next_descendant_post(NULL, p->start_css); in cgroup_iter_seq_start()
82 return p->start_css; in cgroup_iter_seq_start()
90 struct cgroup_iter_priv *p = seq->private; in cgroup_iter_seq_stop()
94 /* pass NULL to the prog for post-processing */ in cgroup_iter_seq_stop()
97 p->visited_all = true; in cgroup_iter_seq_stop()
104 struct cgroup_iter_priv *p = seq->private; in cgroup_iter_seq_next()
107 if (p->terminate) in cgroup_iter_seq_next()
110 if (p->order == BPF_CGROUP_ITER_DESCENDANTS_PRE) in cgroup_iter_seq_next()
111 return css_next_descendant_pre(curr, p->start_css); in cgroup_iter_seq_next()
112 else if (p->order == BPF_CGROUP_ITER_DESCENDANTS_POST) in cgroup_iter_seq_next()
113 return css_next_descendant_post(curr, p->start_css); in cgroup_iter_seq_next()
114 else if (p->order == BPF_CGROUP_ITER_ANCESTORS_UP) in cgroup_iter_seq_next()
115 return curr->parent; in cgroup_iter_seq_next()
123 struct cgroup_iter_priv *p = seq->private; in __cgroup_iter_seq_show()
130 if (css && cgroup_is_dead(css->cgroup)) in __cgroup_iter_seq_show()
134 ctx.cgroup = css ? css->cgroup : NULL; in __cgroup_iter_seq_show()
142 p->terminate = true; in __cgroup_iter_seq_show()
165 struct cgroup *cgrp = aux->cgroup.start; in BTF_ID_LIST_GLOBAL_SINGLE()
172 p->start_css = &cgrp->self; in BTF_ID_LIST_GLOBAL_SINGLE()
173 css_get(p->start_css); in BTF_ID_LIST_GLOBAL_SINGLE()
174 p->terminate = false; in BTF_ID_LIST_GLOBAL_SINGLE()
175 p->visited_all = false; in BTF_ID_LIST_GLOBAL_SINGLE()
176 p->order = aux->cgroup.order; in BTF_ID_LIST_GLOBAL_SINGLE()
184 css_put(p->start_css); in cgroup_iter_seq_fini()
198 int fd = linfo->cgroup.cgroup_fd; in bpf_iter_attach_cgroup()
199 u64 id = linfo->cgroup.cgroup_id; in bpf_iter_attach_cgroup()
200 int order = linfo->cgroup.order; in bpf_iter_attach_cgroup()
207 return -EINVAL; in bpf_iter_attach_cgroup()
210 return -EINVAL; in bpf_iter_attach_cgroup()
222 aux->cgroup.start = cgrp; in bpf_iter_attach_cgroup()
223 aux->cgroup.order = order; in bpf_iter_attach_cgroup()
229 cgroup_put(aux->cgroup.start); in bpf_iter_detach_cgroup()
248 cgroup_path_ns(aux->cgroup.start, buf, PATH_MAX, in bpf_iter_cgroup_show_fdinfo()
249 current->nsproxy->cgroup_ns); in bpf_iter_cgroup_show_fdinfo()
254 if (aux->cgroup.order == BPF_CGROUP_ITER_DESCENDANTS_PRE) in bpf_iter_cgroup_show_fdinfo()
256 else if (aux->cgroup.order == BPF_CGROUP_ITER_DESCENDANTS_POST) in bpf_iter_cgroup_show_fdinfo()
258 else if (aux->cgroup.order == BPF_CGROUP_ITER_ANCESTORS_UP) in bpf_iter_cgroup_show_fdinfo()
267 info->iter.cgroup.order = aux->cgroup.order; in bpf_iter_cgroup_fill_link_info()
268 info->iter.cgroup.cgroup_id = cgroup_id(aux->cgroup.start); in bpf_iter_cgroup_fill_link_info()
318 kit->start = NULL; in bpf_iter_css_new()
325 return -EINVAL; in bpf_iter_css_new()
328 kit->start = start; in bpf_iter_css_new()
329 kit->pos = NULL; in bpf_iter_css_new()
330 kit->flags = flags; in bpf_iter_css_new()
338 if (!kit->start) in bpf_iter_css_next()
341 switch (kit->flags) { in bpf_iter_css_next()
343 kit->pos = css_next_descendant_pre(kit->pos, kit->start); in bpf_iter_css_next()
346 kit->pos = css_next_descendant_post(kit->pos, kit->start); in bpf_iter_css_next()
349 kit->pos = kit->pos ? kit->pos->parent : kit->start; in bpf_iter_css_next()
352 return kit->pos; in bpf_iter_css_next()