/* Walking parents prints parent and then root. */ staticvoid test_walk_ancestors_up(struct cgroup_iter *skel)
{ /* terminate the walk when ROOT is met. */
skel->bss->terminal_cgroup = cg_id[ROOT];
/* Early termination prints parent only. */ staticvoid test_early_termination(struct cgroup_iter *skel)
{ /* terminate the walk after the first element is processed. */
skel->bss->terminate_early = 1;
cgrp_fd = create_and_get_cgroup(cgrp_name); if (!ASSERT_GE(cgrp_fd, 0, "create cgrp")) return;
/* The cgroup will be dead during read() iteration, so it only has * epilogue in the output
*/
snprintf(expected_output, sizeof(expected_output), EPILOGUE);
link = bpf_program__attach_iter(skel->progs.cgroup_id_printer, &opts); if (!ASSERT_OK_PTR(link, "attach_iter")) goto close_cgrp;
iter_fd = bpf_iter_create(bpf_link__fd(link)); if (!ASSERT_GE(iter_fd, 0, "iter_create")) goto free_link;
/* Close link fd and cgroup fd */
bpf_link__destroy(link);
close(cgrp_fd);
/* Remove cgroup to mark it as dead */
remove_cgroup(cgrp_name);
/* Two kern_sync_rcu() and usleep() pairs are used to wait for the * releases of cgroup css, and the last kern_sync_rcu() and usleep() * pair is used to wait for the free of cgroup itself.
*/
kern_sync_rcu();
usleep(8000);
kern_sync_rcu();
usleep(8000);
kern_sync_rcu();
usleep(1000);
memset(buf, 0, sizeof(buf));
left = ARRAY_SIZE(buf);
p = buf; while ((len = read(iter_fd, p, left)) > 0) {
p += len;
left -= len;
}
skel = cgroup_iter__open_and_load(); if (!ASSERT_OK_PTR(skel, "cgroup_iter__open_and_load")) goto out;
if (test__start_subtest("cgroup_iter__invalid_cgroup"))
test_invalid_cgroup(skel); if (test__start_subtest("cgroup_iter__invalid_cgroup_spec"))
test_invalid_cgroup_spec(skel); if (test__start_subtest("cgroup_iter__preorder"))
test_walk_preorder(skel); if (test__start_subtest("cgroup_iter__postorder"))
test_walk_postorder(skel); if (test__start_subtest("cgroup_iter__ancestors_up_walk"))
test_walk_ancestors_up(skel); if (test__start_subtest("cgroup_iter__early_termination"))
test_early_termination(skel); if (test__start_subtest("cgroup_iter__self_only"))
test_walk_self_only(skel); if (test__start_subtest("cgroup_iter__dead_self_only"))
test_walk_dead_self_only(skel); if (test__start_subtest("cgroup_iter__self_only_css_task"))
test_walk_self_only_css_task();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.