/* * This test checks that pids.max prevents forking new children above the * specified limit in the cgroup.
*/ staticint test_pids_max(constchar *root)
{ int ret = KSFT_FAIL; char *cg_pids; int pid;
cg_pids = cg_name(root, "pids_test"); if (!cg_pids) goto cleanup;
if (cg_create(cg_pids)) goto cleanup;
if (cg_read_strcmp(cg_pids, "pids.max", "max\n")) goto cleanup;
if (cg_write(cg_pids, "pids.max", "2")) goto cleanup;
/* * This test checks that pids.events are counted in cgroup associated with pids.max
*/ staticint test_pids_events(constchar *root)
{ int ret = KSFT_FAIL; char *cg_parent = NULL, *cg_child = NULL; int pid;
if (cgroup_feature("pids_localevents") <= 0) return KSFT_SKIP;
if (cg_create(cg_parent)) goto cleanup; if (cg_write(cg_parent, "cgroup.subtree_control", "+pids")) goto cleanup; if (cg_create(cg_child)) goto cleanup;
if (cg_write(cg_parent, "pids.max", "2")) goto cleanup;
if (cg_read_strcmp(cg_child, "pids.max", "max\n")) goto cleanup;
int main(int argc, char **argv)
{ char root[PATH_MAX];
ksft_print_header();
ksft_set_plan(ARRAY_SIZE(tests)); if (cg_find_unified_root(root, sizeof(root), NULL))
ksft_exit_skip("cgroup v2 isn't mounted\n");
/* * Check that pids controller is available: * pids is listed in cgroup.controllers
*/ if (cg_read_strstr(root, "cgroup.controllers", "pids"))
ksft_exit_skip("pids controller isn't available\n");
if (cg_read_strstr(root, "cgroup.subtree_control", "pids")) if (cg_write(root, "cgroup.subtree_control", "+pids"))
ksft_exit_skip("Failed to set pids controller\n");
for (int i = 0; i < ARRAY_SIZE(tests); i++) { switch (tests[i].fn(root)) { case KSFT_PASS:
ksft_test_result_pass("%s\n", tests[i].name); break; case KSFT_SKIP:
ksft_test_result_skip("%s\n", tests[i].name); break; default:
ksft_test_result_fail("%s\n", tests[i].name); break;
}
}
ksft_finished();
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
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.