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()
101 if (buf == NULL) { in alloc_anon_50M_check()
110 if (current < size) in alloc_anon_50M_check()
113 if (!values_close(size, current, 3)) in alloc_anon_50M_check()
117 if (anon < 0) in alloc_anon_50M_check()
120 if (!values_close(anon, current, 3)) in alloc_anon_50M_check()
137 if (fd < 0) in alloc_pagecache_50M_check()
140 if (alloc_pagecache(fd, size)) in alloc_pagecache_50M_check()
144 if (current < size) in alloc_pagecache_50M_check()
148 if (file < 0) in alloc_pagecache_50M_check()
151 if (!values_close(file, current, 10)) in alloc_pagecache_50M_check()
173 if (!memcg) in test_memcg_current()
176 if (cg_create(memcg)) in test_memcg_current()
180 if (current != 0) in test_memcg_current()
183 if (cg_run(memcg, alloc_anon_50M_check, NULL)) in test_memcg_current()
186 if (cg_run(memcg, alloc_pagecache_50M_check, NULL)) in test_memcg_current()
203 if (alloc_pagecache(fd, MB(50))) in alloc_pagecache_50M_noexit()
219 if (buf == NULL) { in alloc_anon_noexit()
236 * If we exceed a timeout, fail.
243 if (cg_read_strcmp(cgroup, "cgroup.procs", "") == 0) in cg_test_proc_killed()
262 * (or memory.low if we test soft protection)
300 if (fd < 0) in test_memcg_protection()
304 if (!parent[0]) in test_memcg_protection()
308 if (!parent[1]) in test_memcg_protection()
312 if (!parent[2]) in test_memcg_protection()
315 if (cg_create(parent[0])) in test_memcg_protection()
318 if (cg_read_long(parent[0], attribute)) { in test_memcg_protection()
320 if (min) in test_memcg_protection()
325 if (cg_write(parent[0], "cgroup.subtree_control", "+memory")) in test_memcg_protection()
328 if (cg_write(parent[0], "memory.max", "200M")) in test_memcg_protection()
331 if (cg_write(parent[0], "memory.swap.max", "0")) in test_memcg_protection()
334 if (cg_create(parent[1])) in test_memcg_protection()
337 if (cg_write(parent[1], "cgroup.subtree_control", "+memory")) in test_memcg_protection()
340 if (cg_create(parent[2])) in test_memcg_protection()
345 if (!children[i]) in test_memcg_protection()
348 if (cg_create(children[i])) in test_memcg_protection()
351 if (i > 2) in test_memcg_protection()
358 if (cg_write(parent[1], attribute, "50M")) in test_memcg_protection()
360 if (cg_write(children[0], attribute, "75M")) in test_memcg_protection()
362 if (cg_write(children[1], attribute, "25M")) in test_memcg_protection()
364 if (cg_write(children[2], attribute, "0")) in test_memcg_protection()
366 if (cg_write(children[3], attribute, "500M")) in test_memcg_protection()
372 if (attempts++ > 5) in test_memcg_protection()
377 if (cg_run(parent[2], alloc_anon, (void *)MB(148))) in test_memcg_protection()
380 if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3)) in test_memcg_protection()
386 if (!values_close(c[0], MB(29), 10)) in test_memcg_protection()
389 if (!values_close(c[1], MB(21), 10)) in test_memcg_protection()
392 if (c[3] != 0) in test_memcg_protection()
396 if (min && !rc) in test_memcg_protection()
398 else if (!min && rc) { in test_memcg_protection()
405 if (!values_close(cg_read_long(parent[1], "memory.current"), current, 3)) in test_memcg_protection()
408 if (!reclaim_until(children[0], MB(10))) in test_memcg_protection()
411 if (min) { in test_memcg_protection()
423 if (oom) in test_memcg_protection()
425 if (i <= no_low_events_index && low <= 0) in test_memcg_protection()
427 if (i > no_low_events_index && low) in test_memcg_protection()
436 if (!children[i]) in test_memcg_protection()
444 if (!parent[i]) in test_memcg_protection()
473 if (high != MB(30) && max != MB(30)) in alloc_pagecache_max_30M()
477 if (fd < 0) in alloc_pagecache_max_30M()
480 if (alloc_pagecache(fd, size)) in alloc_pagecache_max_30M()
484 if (!values_close(current, MB(30), 5)) in alloc_pagecache_max_30M()
507 if (!memcg) in test_memcg_high()
510 if (cg_create(memcg)) in test_memcg_high()
513 if (cg_read_strcmp(memcg, "memory.high", "max\n")) in test_memcg_high()
516 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_high()
519 if (cg_write(memcg, "memory.high", "30M")) in test_memcg_high()
522 if (cg_run(memcg, alloc_anon, (void *)MB(31))) in test_memcg_high()
525 if (!cg_run(memcg, alloc_pagecache_50M_check, NULL)) in test_memcg_high()
528 if (cg_run(memcg, alloc_pagecache_max_30M, NULL)) in test_memcg_high()
532 if (high <= 0) in test_memcg_high()
551 if (buf == MAP_FAILED) in alloc_anon_mlock()
571 if (!memcg) in test_memcg_high_sync()
574 if (cg_create(memcg)) in test_memcg_high_sync()
579 if (pre_high < 0 || pre_max < 0) in test_memcg_high_sync()
582 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_high_sync()
585 if (cg_write(memcg, "memory.high", "30M")) in test_memcg_high_sync()
588 if (cg_write(memcg, "memory.max", "140M")) in test_memcg_high_sync()
592 if (fd < 0) in test_memcg_high_sync()
596 if (pid < 0) in test_memcg_high_sync()
603 if (post_high < 0 || post_max < 0) in test_memcg_high_sync()
606 if (pre_high == post_high || pre_max != post_max) in test_memcg_high_sync()
612 if (fd >= 0) in test_memcg_high_sync()
632 if (!memcg) in test_memcg_max()
635 if (cg_create(memcg)) in test_memcg_max()
638 if (cg_read_strcmp(memcg, "memory.max", "max\n")) in test_memcg_max()
641 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_max()
644 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_max()
648 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_max()
651 if (cg_run(memcg, alloc_pagecache_max_30M, NULL)) in test_memcg_max()
655 if (current > MB(30) || !current) in test_memcg_max()
659 if (max <= 0) in test_memcg_max()
675 * This function will return false if the usage is already below the
683 * false if memory.reclaim's error codes do not make sense, even if
696 if (current < goal || values_close(current, goal, 3)) in reclaim_until()
699 else if (reclaimed) in reclaim_until()
705 if (!err) in reclaim_until()
707 else if (err != -EAGAIN) in reclaim_until()
715 * amount of memory (from both anon and file, if possible).
724 if (!memcg) in test_memcg_reclaim()
727 if (cg_create(memcg)) in test_memcg_reclaim()
731 if (current != 0) in test_memcg_reclaim()
735 if (fd < 0) in test_memcg_reclaim()
741 * If swap is enabled, try to reclaim from both anon and file, else try in test_memcg_reclaim()
744 if (is_swap_enabled()) { in test_memcg_reclaim()
757 if (retries--) { in test_memcg_reclaim()
770 * and file if swap is enabled. in test_memcg_reclaim()
772 if (!reclaim_until(memcg, MB(30))) in test_memcg_reclaim()
793 if (buf == NULL) { in alloc_anon_50M_check_swap()
802 if (!mem_current || !values_close(mem_current, mem_max, 3)) in alloc_anon_50M_check_swap()
806 if (!swap_current || in alloc_anon_50M_check_swap()
826 if (!is_swap_enabled()) in test_memcg_swap_max()
830 if (!memcg) in test_memcg_swap_max()
833 if (cg_create(memcg)) in test_memcg_swap_max()
836 if (cg_read_long(memcg, "memory.swap.current")) { in test_memcg_swap_max()
841 if (cg_read_strcmp(memcg, "memory.max", "max\n")) in test_memcg_swap_max()
844 if (cg_read_strcmp(memcg, "memory.swap.max", "max\n")) in test_memcg_swap_max()
847 if (cg_write(memcg, "memory.swap.max", "30M")) in test_memcg_swap_max()
850 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_swap_max()
854 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_swap_max()
857 if (cg_read_key_long(memcg, "memory.events", "oom ") != 1) in test_memcg_swap_max()
860 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 1) in test_memcg_swap_max()
863 if (cg_run(memcg, alloc_anon_50M_check_swap, (void *)MB(30))) in test_memcg_swap_max()
867 if (max <= 0) in test_memcg_swap_max()
890 if (!memcg) in test_memcg_oom_events()
893 if (cg_create(memcg)) in test_memcg_oom_events()
896 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_oom_events()
899 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_oom_events()
902 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_oom_events()
905 if (cg_read_strcmp(memcg, "cgroup.procs", "")) in test_memcg_oom_events()
908 if (cg_read_key_long(memcg, "memory.events", "oom ") != 1) in test_memcg_oom_events()
911 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 1) in test_memcg_oom_events()
943 if (sk < 0) in tcp_server()
946 if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) in tcp_server()
949 if (bind(sk, (struct sockaddr *)&saddr, slen)) { in tcp_server()
954 if (listen(sk, 1)) in tcp_server()
958 if (write(ctl_fd, &ret, sizeof(ret)) != sizeof(ret)) { in tcp_server()
964 if (client_sk < 0) in tcp_server()
971 if (write(client_sk, buf, sizeof(buf)) <= 0) { in tcp_server()
972 if (errno == ECONNRESET) in tcp_server()
997 if (ret) in tcp_client()
1001 if (sk < 0) in tcp_client()
1005 if (ret < 0) in tcp_client()
1013 if (read(sk, buf, sizeof(buf)) <= 0) in tcp_client()
1019 if (current < 0 || sock < 0) in tcp_client()
1023 if (values_close(current - allocated, sock, 10)) { in tcp_client()
1051 if (!memcg) in test_memcg_sock()
1054 if (cg_create(memcg)) in test_memcg_sock()
1060 if (pipe(args.ctl)) in test_memcg_sock()
1066 if (pid < 0) in test_memcg_sock()
1070 if (read(args.ctl[0], &err, sizeof(err)) != sizeof(err)) in test_memcg_sock()
1074 if (!err) in test_memcg_sock()
1076 if (err != EADDRINUSE) in test_memcg_sock()
1082 if (err == EADDRINUSE) { in test_memcg_sock()
1087 if (tcp_client(memcg, port) != KSFT_PASS) in test_memcg_sock()
1091 if (WEXITSTATUS(err)) in test_memcg_sock()
1094 if (cg_read_long(memcg, "memory.current") < 0) in test_memcg_sock()
1097 if (cg_read_key_long(memcg, "memory.stat", "sock ")) in test_memcg_sock()
1124 if (!parent || !child) in test_memcg_oom_group_leaf_events()
1127 if (cg_create(parent)) in test_memcg_oom_group_leaf_events()
1130 if (cg_create(child)) in test_memcg_oom_group_leaf_events()
1133 if (cg_write(parent, "cgroup.subtree_control", "+memory")) in test_memcg_oom_group_leaf_events()
1136 if (cg_write(child, "memory.max", "50M")) in test_memcg_oom_group_leaf_events()
1139 if (cg_write(child, "memory.swap.max", "0")) in test_memcg_oom_group_leaf_events()
1142 if (cg_write(child, "memory.oom.group", "1")) in test_memcg_oom_group_leaf_events()
1148 if (!cg_run(child, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_leaf_events()
1151 if (cg_test_proc_killed(child)) in test_memcg_oom_group_leaf_events()
1154 if (cg_read_key_long(child, "memory.events", "oom_kill ") <= 0) in test_memcg_oom_group_leaf_events()
1160 * If memory_localevents is not enabled (the default), the parent should in test_memcg_oom_group_leaf_events()
1164 if (has_localevents && parent_oom_events != 0) in test_memcg_oom_group_leaf_events()
1166 else if (!has_localevents && parent_oom_events <= 0) in test_memcg_oom_group_leaf_events()
1172 if (child) in test_memcg_oom_group_leaf_events()
1174 if (parent) in test_memcg_oom_group_leaf_events()
1195 if (!parent || !child) in test_memcg_oom_group_parent_events()
1198 if (cg_create(parent)) in test_memcg_oom_group_parent_events()
1201 if (cg_create(child)) in test_memcg_oom_group_parent_events()
1204 if (cg_write(parent, "memory.max", "80M")) in test_memcg_oom_group_parent_events()
1207 if (cg_write(parent, "memory.swap.max", "0")) in test_memcg_oom_group_parent_events()
1210 if (cg_write(parent, "memory.oom.group", "1")) in test_memcg_oom_group_parent_events()
1217 if (!cg_run(child, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_parent_events()
1220 if (cg_test_proc_killed(child)) in test_memcg_oom_group_parent_events()
1222 if (cg_test_proc_killed(parent)) in test_memcg_oom_group_parent_events()
1228 if (child) in test_memcg_oom_group_parent_events()
1230 if (parent) in test_memcg_oom_group_parent_events()
1251 if (!memcg) in test_memcg_oom_group_score_events()
1254 if (cg_create(memcg)) in test_memcg_oom_group_score_events()
1257 if (cg_write(memcg, "memory.max", "50M")) in test_memcg_oom_group_score_events()
1260 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_oom_group_score_events()
1263 if (cg_write(memcg, "memory.oom.group", "1")) in test_memcg_oom_group_score_events()
1267 if (set_oom_adj_score(safe_pid, OOM_SCORE_ADJ_MIN)) in test_memcg_oom_group_score_events()
1271 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_score_events()
1274 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3) in test_memcg_oom_group_score_events()
1277 if (kill(safe_pid, SIGKILL)) in test_memcg_oom_group_score_events()
1283 if (memcg) in test_memcg_oom_group_score_events()
1317 if (cg_find_unified_root(root, sizeof(root))) in main()
1324 if (cg_read_strstr(root, "cgroup.controllers", "memory")) in main()
1327 if (cg_read_strstr(root, "cgroup.subtree_control", "memory")) in main()
1328 if (cg_write(root, "cgroup.subtree_control", "+memory")) in main()
1332 if (proc_status < 0) in main()
1337 if (proc_status < 0) in main()