Lines Matching full:if
40 if (!parent || !child) in test_memcg_subtree_control()
43 if (cg_create(parent)) in test_memcg_subtree_control()
46 if (cg_write(parent, "cgroup.subtree_control", "+memory")) in test_memcg_subtree_control()
49 if (cg_create(child)) in test_memcg_subtree_control()
52 if (cg_read_strstr(child, "cgroup.controllers", "memory")) in test_memcg_subtree_control()
58 if (!parent2 || !child2) in test_memcg_subtree_control()
61 if (cg_create(parent2)) in test_memcg_subtree_control()
64 if (cg_create(child2)) in test_memcg_subtree_control()
67 if (cg_read(child2, "cgroup.controllers", buf, sizeof(buf))) in test_memcg_subtree_control()
70 if (!cg_read_strstr(child2, "cgroup.controllers", "memory")) in test_memcg_subtree_control()
105 if (current < size) in alloc_anon_50M_check()
108 if (!values_close(size, current, 3)) in alloc_anon_50M_check()
112 if (anon < 0) in alloc_anon_50M_check()
115 if (!values_close(anon, current, 3)) in alloc_anon_50M_check()
132 if (fd < 0) in alloc_pagecache_50M_check()
135 if (alloc_pagecache(fd, size)) in alloc_pagecache_50M_check()
139 if (current < size) in alloc_pagecache_50M_check()
143 if (file < 0) in alloc_pagecache_50M_check()
146 if (!values_close(file, current, 10)) in alloc_pagecache_50M_check()
168 if (!memcg) in test_memcg_current()
171 if (cg_create(memcg)) in test_memcg_current()
175 if (current != 0) in test_memcg_current()
178 if (cg_run(memcg, alloc_anon_50M_check, NULL)) in test_memcg_current()
181 if (cg_run(memcg, alloc_pagecache_50M_check, NULL)) in test_memcg_current()
198 if (alloc_pagecache(fd, MB(50))) in alloc_pagecache_50M_noexit()
226 * If we exceed a timeout, fail.
233 if (cg_read_strcmp(cgroup, "cgroup.procs", "") == 0) in cg_test_proc_killed()
250 * (or memory.low if we test soft protection)
281 if (fd < 0) in test_memcg_protection()
285 if (!parent[0]) in test_memcg_protection()
289 if (!parent[1]) in test_memcg_protection()
293 if (!parent[2]) in test_memcg_protection()
296 if (cg_create(parent[0])) in test_memcg_protection()
299 if (cg_read_long(parent[0], attribute)) { in test_memcg_protection()
301 if (min) in test_memcg_protection()
306 if (cg_write(parent[0], "cgroup.subtree_control", "+memory")) in test_memcg_protection()
309 if (cg_write(parent[0], "memory.max", "200M")) in test_memcg_protection()
312 if (cg_write(parent[0], "memory.swap.max", "0")) in test_memcg_protection()
315 if (cg_create(parent[1])) in test_memcg_protection()
318 if (cg_write(parent[1], "cgroup.subtree_control", "+memory")) in test_memcg_protection()
321 if (cg_create(parent[2])) in test_memcg_protection()
326 if (!children[i]) in test_memcg_protection()
329 if (cg_create(children[i])) in test_memcg_protection()
332 if (i > 2) in test_memcg_protection()
339 if (cg_write(parent[1], attribute, "50M")) in test_memcg_protection()
341 if (cg_write(children[0], attribute, "75M")) in test_memcg_protection()
343 if (cg_write(children[1], attribute, "25M")) in test_memcg_protection()
345 if (cg_write(children[2], attribute, "0")) in test_memcg_protection()
347 if (cg_write(children[3], attribute, "500M")) in test_memcg_protection()
353 if (attempts++ > 5) in test_memcg_protection()
358 if (cg_run(parent[2], alloc_anon, (void *)MB(148))) in test_memcg_protection()
361 if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3)) in test_memcg_protection()
367 if (!values_close(c[0], MB(29), 10)) in test_memcg_protection()
370 if (!values_close(c[1], MB(21), 10)) in test_memcg_protection()
373 if (c[3] != 0) in test_memcg_protection()
377 if (min && !rc) in test_memcg_protection()
379 else if (!min && rc) { in test_memcg_protection()
385 if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3)) in test_memcg_protection()
388 if (min) { in test_memcg_protection()
400 if (oom) in test_memcg_protection()
402 if (i <= no_low_events_index && low <= 0) in test_memcg_protection()
404 if (i > no_low_events_index && low) in test_memcg_protection()
413 if (!children[i]) in test_memcg_protection()
421 if (!parent[i]) in test_memcg_protection()
450 if (high != MB(30) && max != MB(30)) in alloc_pagecache_max_30M()
454 if (fd < 0) in alloc_pagecache_max_30M()
457 if (alloc_pagecache(fd, size)) in alloc_pagecache_max_30M()
461 if (!values_close(current, MB(30), 5)) in alloc_pagecache_max_30M()
484 if (!memcg) in test_memcg_high()
487 if (cg_create(memcg)) in test_memcg_high()
490 if (cg_read_strcmp(memcg, "memory.high", "max\n")) in test_memcg_high()
493 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_high()
496 if (cg_write(memcg, "memory.high", "30M")) in test_memcg_high()
499 if (cg_run(memcg, alloc_anon, (void *)MB(31))) in test_memcg_high()
502 if (!cg_run(memcg, alloc_pagecache_50M_check, NULL)) in test_memcg_high()
505 if (cg_run(memcg, alloc_pagecache_max_30M, NULL)) in test_memcg_high()
509 if (high <= 0) in test_memcg_high()
528 if (buf == MAP_FAILED) in alloc_anon_mlock()
548 if (!memcg) in test_memcg_high_sync()
551 if (cg_create(memcg)) in test_memcg_high_sync()
556 if (pre_high < 0 || pre_max < 0) in test_memcg_high_sync()
559 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_high_sync()
562 if (cg_write(memcg, "memory.high", "30M")) in test_memcg_high_sync()
565 if (cg_write(memcg, "memory.max", "140M")) in test_memcg_high_sync()
569 if (fd < 0) in test_memcg_high_sync()
573 if (pid < 0) in test_memcg_high_sync()
580 if (post_high < 0 || post_max < 0) in test_memcg_high_sync()
583 if (pre_high == post_high || pre_max != post_max) in test_memcg_high_sync()
589 if (fd >= 0) in test_memcg_high_sync()
609 if (!memcg) in test_memcg_max()
612 if (cg_create(memcg)) in test_memcg_max()
615 if (cg_read_strcmp(memcg, "memory.max", "max\n")) in test_memcg_max()
618 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_max()
621 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_max()
625 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_max()
628 if (cg_run(memcg, alloc_pagecache_max_30M, NULL)) in test_memcg_max()
632 if (current > MB(30) || !current) in test_memcg_max()
636 if (max <= 0) in test_memcg_max()
650 * amount of memory (from both anon and file, if possible).
660 if (!memcg) in test_memcg_reclaim()
663 if (cg_create(memcg)) in test_memcg_reclaim()
667 if (current != 0) in test_memcg_reclaim()
671 if (fd < 0) in test_memcg_reclaim()
677 * If swap is enabled, try to reclaim from both anon and file, else try in test_memcg_reclaim()
680 if (is_swap_enabled()) { in test_memcg_reclaim()
693 if (retries--) { in test_memcg_reclaim()
706 * and file if swap is enabled. in test_memcg_reclaim()
716 * We only keep looping if we get EAGAIN, which means we could in test_memcg_reclaim()
719 if (to_reclaim <= 0) in test_memcg_reclaim()
725 if (!err) { in test_memcg_reclaim()
727 * If writing succeeds, then the written amount should have been in test_memcg_reclaim()
731 if (!values_close(current, MB(30), 3) && current > MB(30)) in test_memcg_reclaim()
737 if (err == -EAGAIN && retries--) in test_memcg_reclaim()
766 if (!mem_current || !values_close(mem_current, mem_max, 3)) in alloc_anon_50M_check_swap()
770 if (!swap_current || in alloc_anon_50M_check_swap()
790 if (!is_swap_enabled()) in test_memcg_swap_max()
794 if (!memcg) in test_memcg_swap_max()
797 if (cg_create(memcg)) in test_memcg_swap_max()
800 if (cg_read_long(memcg, "memory.swap.current")) { in test_memcg_swap_max()
805 if (cg_read_strcmp(memcg, "memory.max", "max\n")) in test_memcg_swap_max()
808 if (cg_read_strcmp(memcg, "memory.swap.max", "max\n")) in test_memcg_swap_max()
811 if (cg_write(memcg, "memory.swap.max", "30M")) in test_memcg_swap_max()
814 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_swap_max()
818 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_swap_max()
821 if (cg_read_key_long(memcg, "memory.events", "oom ") != 1) in test_memcg_swap_max()
824 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 1) in test_memcg_swap_max()
827 if (cg_run(memcg, alloc_anon_50M_check_swap, (void *)MB(30))) in test_memcg_swap_max()
831 if (max <= 0) in test_memcg_swap_max()
854 if (!memcg) in test_memcg_oom_events()
857 if (cg_create(memcg)) in test_memcg_oom_events()
860 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_oom_events()
863 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_oom_events()
866 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_oom_events()
869 if (cg_read_strcmp(memcg, "cgroup.procs", "")) in test_memcg_oom_events()
872 if (cg_read_key_long(memcg, "memory.events", "oom ") != 1) in test_memcg_oom_events()
875 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 1) in test_memcg_oom_events()
907 if (sk < 0) in tcp_server()
910 if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) in tcp_server()
913 if (bind(sk, (struct sockaddr *)&saddr, slen)) { in tcp_server()
918 if (listen(sk, 1)) in tcp_server()
922 if (write(ctl_fd, &ret, sizeof(ret)) != sizeof(ret)) { in tcp_server()
928 if (client_sk < 0) in tcp_server()
935 if (write(client_sk, buf, sizeof(buf)) <= 0) { in tcp_server()
936 if (errno == ECONNRESET) in tcp_server()
959 if (ret) in tcp_client()
963 if (sk < 0) in tcp_client()
967 if (ret < 0) in tcp_client()
975 if (read(sk, buf, sizeof(buf)) <= 0) in tcp_client()
981 if (current < 0 || sock < 0) in tcp_client()
984 if (values_close(current, sock, 10)) { in tcp_client()
1012 if (!memcg) in test_memcg_sock()
1015 if (cg_create(memcg)) in test_memcg_sock()
1021 if (pipe(args.ctl)) in test_memcg_sock()
1027 if (pid < 0) in test_memcg_sock()
1031 if (read(args.ctl[0], &err, sizeof(err)) != sizeof(err)) in test_memcg_sock()
1035 if (!err) in test_memcg_sock()
1037 if (err != EADDRINUSE) in test_memcg_sock()
1043 if (err == EADDRINUSE) { in test_memcg_sock()
1048 if (tcp_client(memcg, port) != KSFT_PASS) in test_memcg_sock()
1052 if (WEXITSTATUS(err)) in test_memcg_sock()
1055 if (cg_read_long(memcg, "memory.current") < 0) in test_memcg_sock()
1058 if (cg_read_key_long(memcg, "memory.stat", "sock ")) in test_memcg_sock()
1085 if (!parent || !child) in test_memcg_oom_group_leaf_events()
1088 if (cg_create(parent)) in test_memcg_oom_group_leaf_events()
1091 if (cg_create(child)) in test_memcg_oom_group_leaf_events()
1094 if (cg_write(parent, "cgroup.subtree_control", "+memory")) in test_memcg_oom_group_leaf_events()
1097 if (cg_write(child, "memory.max", "50M")) in test_memcg_oom_group_leaf_events()
1100 if (cg_write(child, "memory.swap.max", "0")) in test_memcg_oom_group_leaf_events()
1103 if (cg_write(child, "memory.oom.group", "1")) in test_memcg_oom_group_leaf_events()
1109 if (!cg_run(child, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_leaf_events()
1112 if (cg_test_proc_killed(child)) in test_memcg_oom_group_leaf_events()
1115 if (cg_read_key_long(child, "memory.events", "oom_kill ") <= 0) in test_memcg_oom_group_leaf_events()
1121 * If memory_localevents is not enabled (the default), the parent should in test_memcg_oom_group_leaf_events()
1125 if (has_localevents && parent_oom_events != 0) in test_memcg_oom_group_leaf_events()
1127 else if (!has_localevents && parent_oom_events <= 0) in test_memcg_oom_group_leaf_events()
1133 if (child) in test_memcg_oom_group_leaf_events()
1135 if (parent) in test_memcg_oom_group_leaf_events()
1156 if (!parent || !child) in test_memcg_oom_group_parent_events()
1159 if (cg_create(parent)) in test_memcg_oom_group_parent_events()
1162 if (cg_create(child)) in test_memcg_oom_group_parent_events()
1165 if (cg_write(parent, "memory.max", "80M")) in test_memcg_oom_group_parent_events()
1168 if (cg_write(parent, "memory.swap.max", "0")) in test_memcg_oom_group_parent_events()
1171 if (cg_write(parent, "memory.oom.group", "1")) in test_memcg_oom_group_parent_events()
1178 if (!cg_run(child, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_parent_events()
1181 if (cg_test_proc_killed(child)) in test_memcg_oom_group_parent_events()
1183 if (cg_test_proc_killed(parent)) in test_memcg_oom_group_parent_events()
1189 if (child) in test_memcg_oom_group_parent_events()
1191 if (parent) in test_memcg_oom_group_parent_events()
1212 if (!memcg) in test_memcg_oom_group_score_events()
1215 if (cg_create(memcg)) in test_memcg_oom_group_score_events()
1218 if (cg_write(memcg, "memory.max", "50M")) in test_memcg_oom_group_score_events()
1221 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_oom_group_score_events()
1224 if (cg_write(memcg, "memory.oom.group", "1")) in test_memcg_oom_group_score_events()
1228 if (set_oom_adj_score(safe_pid, OOM_SCORE_ADJ_MIN)) in test_memcg_oom_group_score_events()
1232 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_score_events()
1235 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3) in test_memcg_oom_group_score_events()
1238 if (kill(safe_pid, SIGKILL)) in test_memcg_oom_group_score_events()
1244 if (memcg) in test_memcg_oom_group_score_events()
1278 if (cg_find_unified_root(root, sizeof(root))) in main()
1285 if (cg_read_strstr(root, "cgroup.controllers", "memory")) in main()
1288 if (cg_read_strstr(root, "cgroup.subtree_control", "memory")) in main()
1289 if (cg_write(root, "cgroup.subtree_control", "+memory")) in main()
1293 if (proc_status < 0) in main()
1298 if (proc_status < 0) in main()