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()
176 if (!memcg) in test_memcg_current_peak()
179 if (cg_create(memcg)) in test_memcg_current_peak()
183 if (current != 0) in test_memcg_current_peak()
187 if (peak != 0) in test_memcg_current_peak()
190 if (cg_run(memcg, alloc_anon_50M_check, NULL)) in test_memcg_current_peak()
194 if (peak < MB(50)) in test_memcg_current_peak()
204 if (peak_fd == -1) { in test_memcg_current_peak()
205 if (errno == ENOENT) in test_memcg_current_peak()
215 if (fstat(peak_fd, &ss)) in test_memcg_current_peak()
218 if ((ss.st_mode & S_IWUSR) == 0) { in test_memcg_current_peak()
225 if (peak_fd2 == -1) in test_memcg_current_peak()
230 if (peak_fd3 == -1) in test_memcg_current_peak()
237 if (peak_reset != sizeof(reset_string)) in test_memcg_current_peak()
241 if (peak_reset != sizeof(reset_string)) in test_memcg_current_peak()
245 if (peak_reset != sizeof(reset_string)) in test_memcg_current_peak()
250 if (peak < MB(50)) in test_memcg_current_peak()
254 if (close(peak_fd2)) in test_memcg_current_peak()
259 if (peak_fd4 == -1) in test_memcg_current_peak()
263 if (peak_reset != sizeof(reset_string)) in test_memcg_current_peak()
267 if (peak > MB(30) || peak < 0) in test_memcg_current_peak()
270 if (cg_run(memcg, alloc_pagecache_50M_check, NULL)) in test_memcg_current_peak()
274 if (peak < MB(50)) in test_memcg_current_peak()
279 if (peak < MB(50)) in test_memcg_current_peak()
283 if (peak < MB(50)) in test_memcg_current_peak()
287 if (close(peak_fd3)) in test_memcg_current_peak()
291 if (close(peak_fd4)) in test_memcg_current_peak()
298 if (!fd2_closed) in test_memcg_current_peak()
300 if (!fd3_closed) in test_memcg_current_peak()
302 if (!fd4_closed) in test_memcg_current_peak()
315 if (alloc_pagecache(fd, MB(50))) in alloc_pagecache_50M_noexit()
331 if (buf == NULL) { in alloc_anon_noexit()
348 * If we exceed a timeout, fail.
355 if (cg_read_strcmp(cgroup, "cgroup.procs", "") == 0) in cg_test_proc_killed()
374 * (or memory.low if we test soft protection)
412 if (fd < 0) in test_memcg_protection()
416 if (!parent[0]) in test_memcg_protection()
420 if (!parent[1]) in test_memcg_protection()
424 if (!parent[2]) in test_memcg_protection()
427 if (cg_create(parent[0])) in test_memcg_protection()
430 if (cg_read_long(parent[0], attribute)) { in test_memcg_protection()
432 if (min) in test_memcg_protection()
437 if (cg_write(parent[0], "cgroup.subtree_control", "+memory")) in test_memcg_protection()
440 if (cg_write(parent[0], "memory.max", "200M")) in test_memcg_protection()
443 if (cg_write(parent[0], "memory.swap.max", "0")) in test_memcg_protection()
446 if (cg_create(parent[1])) in test_memcg_protection()
449 if (cg_write(parent[1], "cgroup.subtree_control", "+memory")) in test_memcg_protection()
452 if (cg_create(parent[2])) in test_memcg_protection()
457 if (!children[i]) in test_memcg_protection()
460 if (cg_create(children[i])) in test_memcg_protection()
463 if (i > 2) in test_memcg_protection()
470 if (cg_write(parent[1], attribute, "50M")) in test_memcg_protection()
472 if (cg_write(children[0], attribute, "75M")) in test_memcg_protection()
474 if (cg_write(children[1], attribute, "25M")) in test_memcg_protection()
476 if (cg_write(children[2], attribute, "0")) in test_memcg_protection()
478 if (cg_write(children[3], attribute, "500M")) in test_memcg_protection()
484 if (attempts++ > 5) in test_memcg_protection()
489 if (cg_run(parent[2], alloc_anon, (void *)MB(148))) in test_memcg_protection()
492 if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3)) in test_memcg_protection()
498 if (!values_close(c[0], MB(29), 10)) in test_memcg_protection()
501 if (!values_close(c[1], MB(21), 10)) in test_memcg_protection()
504 if (c[3] != 0) in test_memcg_protection()
508 if (min && !rc) in test_memcg_protection()
510 else if (!min && rc) { in test_memcg_protection()
517 if (!values_close(cg_read_long(parent[1], "memory.current"), current, 3)) in test_memcg_protection()
520 if (!reclaim_until(children[0], MB(10))) in test_memcg_protection()
523 if (min) { in test_memcg_protection()
535 if (oom) in test_memcg_protection()
537 if (i <= no_low_events_index && low <= 0) in test_memcg_protection()
539 if (i > no_low_events_index && low) in test_memcg_protection()
548 if (!children[i]) in test_memcg_protection()
556 if (!parent[i]) in test_memcg_protection()
585 if (high != MB(30) && max != MB(30)) in alloc_pagecache_max_30M()
589 if (fd < 0) in alloc_pagecache_max_30M()
592 if (alloc_pagecache(fd, size)) in alloc_pagecache_max_30M()
596 if (!values_close(current, MB(30), 5)) in alloc_pagecache_max_30M()
619 if (!memcg) in test_memcg_high()
622 if (cg_create(memcg)) in test_memcg_high()
625 if (cg_read_strcmp(memcg, "memory.high", "max\n")) in test_memcg_high()
628 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_high()
631 if (cg_write(memcg, "memory.high", "30M")) in test_memcg_high()
634 if (cg_run(memcg, alloc_anon, (void *)MB(31))) in test_memcg_high()
637 if (!cg_run(memcg, alloc_pagecache_50M_check, NULL)) in test_memcg_high()
640 if (cg_run(memcg, alloc_pagecache_max_30M, NULL)) in test_memcg_high()
644 if (high <= 0) in test_memcg_high()
663 if (buf == MAP_FAILED) in alloc_anon_mlock()
683 if (!memcg) in test_memcg_high_sync()
686 if (cg_create(memcg)) in test_memcg_high_sync()
691 if (pre_high < 0 || pre_max < 0) in test_memcg_high_sync()
694 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_high_sync()
697 if (cg_write(memcg, "memory.high", "30M")) in test_memcg_high_sync()
700 if (cg_write(memcg, "memory.max", "140M")) in test_memcg_high_sync()
704 if (fd < 0) in test_memcg_high_sync()
708 if (pid < 0) in test_memcg_high_sync()
715 if (post_high < 0 || post_max < 0) in test_memcg_high_sync()
718 if (pre_high == post_high || pre_max != post_max) in test_memcg_high_sync()
724 if (fd >= 0) in test_memcg_high_sync()
744 if (!memcg) in test_memcg_max()
747 if (cg_create(memcg)) in test_memcg_max()
750 if (cg_read_strcmp(memcg, "memory.max", "max\n")) in test_memcg_max()
753 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_max()
756 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_max()
760 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_max()
763 if (cg_run(memcg, alloc_pagecache_max_30M, NULL)) in test_memcg_max()
767 if (current > MB(30) || !current) in test_memcg_max()
771 if (max <= 0) in test_memcg_max()
787 * This function will return false if the usage is already below the
795 * false if memory.reclaim's error codes do not make sense, even if
808 if (current < goal || values_close(current, goal, 3)) in reclaim_until()
811 else if (reclaimed) in reclaim_until()
817 if (!err) in reclaim_until()
819 else if (err != -EAGAIN) in reclaim_until()
827 * amount of memory (from both anon and file, if possible).
838 if (!memcg) in test_memcg_reclaim()
841 if (cg_create(memcg)) in test_memcg_reclaim()
845 if (current != 0) in test_memcg_reclaim()
849 if (fd < 0) in test_memcg_reclaim()
855 * If swap is enabled, try to reclaim from both anon and file, else try in test_memcg_reclaim()
858 if (is_swap_enabled()) { in test_memcg_reclaim()
871 if (retries--) { in test_memcg_reclaim()
884 * and file if swap is enabled. in test_memcg_reclaim()
886 if (!reclaim_until(memcg, MB(30))) in test_memcg_reclaim()
907 if (buf == NULL) { in alloc_anon_50M_check_swap()
916 if (!mem_current || !values_close(mem_current, mem_max, 3)) in alloc_anon_50M_check_swap()
920 if (!swap_current || in alloc_anon_50M_check_swap()
946 if (!is_swap_enabled()) in test_memcg_swap_max_peak()
950 if (!memcg) in test_memcg_swap_max_peak()
953 if (cg_create(memcg)) in test_memcg_swap_max_peak()
956 if (cg_read_long(memcg, "memory.swap.current")) { in test_memcg_swap_max_peak()
964 if (swap_peak_fd == -1) { in test_memcg_swap_max_peak()
965 if (errno == ENOENT) in test_memcg_swap_max_peak()
975 if (fstat(swap_peak_fd, &ss)) in test_memcg_swap_max_peak()
978 if ((ss.st_mode & S_IWUSR) == 0) { in test_memcg_swap_max_peak()
985 if (mem_peak_fd == -1) in test_memcg_swap_max_peak()
988 if (cg_read_long(memcg, "memory.swap.peak")) in test_memcg_swap_max_peak()
991 if (cg_read_long_fd(swap_peak_fd)) in test_memcg_swap_max_peak()
997 if (peak_reset != sizeof(reset_string)) in test_memcg_swap_max_peak()
1000 if (cg_read_long_fd(swap_peak_fd)) in test_memcg_swap_max_peak()
1003 if (cg_read_long(memcg, "memory.peak")) in test_memcg_swap_max_peak()
1006 if (cg_read_long_fd(mem_peak_fd)) in test_memcg_swap_max_peak()
1010 if (peak_reset != sizeof(reset_string)) in test_memcg_swap_max_peak()
1013 if (cg_read_long_fd(mem_peak_fd)) in test_memcg_swap_max_peak()
1016 if (cg_read_strcmp(memcg, "memory.max", "max\n")) in test_memcg_swap_max_peak()
1019 if (cg_read_strcmp(memcg, "memory.swap.max", "max\n")) in test_memcg_swap_max_peak()
1022 if (cg_write(memcg, "memory.swap.max", "30M")) in test_memcg_swap_max_peak()
1025 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_swap_max_peak()
1029 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_swap_max_peak()
1032 if (cg_read_key_long(memcg, "memory.events", "oom ") != 1) in test_memcg_swap_max_peak()
1035 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 1) in test_memcg_swap_max_peak()
1039 if (peak < MB(29)) in test_memcg_swap_max_peak()
1043 if (peak < MB(29)) in test_memcg_swap_max_peak()
1047 if (peak < MB(29)) in test_memcg_swap_max_peak()
1051 if (peak < MB(29)) in test_memcg_swap_max_peak()
1059 if (peak_reset) in test_memcg_swap_max_peak()
1063 if (peak_reset) in test_memcg_swap_max_peak()
1068 if (peak_reset != sizeof(reset_string)) in test_memcg_swap_max_peak()
1072 if (peak_reset != sizeof(reset_string)) in test_memcg_swap_max_peak()
1076 if (peak > MB(10)) in test_memcg_swap_max_peak()
1084 if (peak > MB(1)) in test_memcg_swap_max_peak()
1087 if (cg_read_long(memcg, "memory.peak") < MB(29)) in test_memcg_swap_max_peak()
1090 if (cg_read_long(memcg, "memory.swap.peak") < MB(29)) in test_memcg_swap_max_peak()
1093 if (cg_run(memcg, alloc_anon_50M_check_swap, (void *)MB(30))) in test_memcg_swap_max_peak()
1097 if (max <= 0) in test_memcg_swap_max_peak()
1101 if (peak < MB(29)) in test_memcg_swap_max_peak()
1105 if (peak < MB(29)) in test_memcg_swap_max_peak()
1109 if (peak < MB(29)) in test_memcg_swap_max_peak()
1113 if (peak < MB(19)) in test_memcg_swap_max_peak()
1119 if (mem_peak_fd != -1 && close(mem_peak_fd)) in test_memcg_swap_max_peak()
1121 if (swap_peak_fd != -1 && close(swap_peak_fd)) in test_memcg_swap_max_peak()
1140 if (!memcg) in test_memcg_oom_events()
1143 if (cg_create(memcg)) in test_memcg_oom_events()
1146 if (cg_write(memcg, "memory.max", "30M")) in test_memcg_oom_events()
1149 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_oom_events()
1152 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_oom_events()
1155 if (cg_read_strcmp(memcg, "cgroup.procs", "")) in test_memcg_oom_events()
1158 if (cg_read_key_long(memcg, "memory.events", "oom ") != 1) in test_memcg_oom_events()
1161 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 1) in test_memcg_oom_events()
1193 if (sk < 0) in tcp_server()
1196 if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) in tcp_server()
1199 if (bind(sk, (struct sockaddr *)&saddr, slen)) { in tcp_server()
1204 if (listen(sk, 1)) in tcp_server()
1208 if (write(ctl_fd, &ret, sizeof(ret)) != sizeof(ret)) { in tcp_server()
1214 if (client_sk < 0) in tcp_server()
1221 if (write(client_sk, buf, sizeof(buf)) <= 0) { in tcp_server()
1222 if (errno == ECONNRESET) in tcp_server()
1247 if (ret) in tcp_client()
1251 if (sk < 0) in tcp_client()
1255 if (ret < 0) in tcp_client()
1263 if (read(sk, buf, sizeof(buf)) <= 0) in tcp_client()
1269 if (current < 0 || sock < 0) in tcp_client()
1273 if (values_close(current - allocated, sock, 10)) { in tcp_client()
1301 if (!memcg) in test_memcg_sock()
1304 if (cg_create(memcg)) in test_memcg_sock()
1310 if (pipe(args.ctl)) in test_memcg_sock()
1316 if (pid < 0) in test_memcg_sock()
1320 if (read(args.ctl[0], &err, sizeof(err)) != sizeof(err)) in test_memcg_sock()
1324 if (!err) in test_memcg_sock()
1326 if (err != EADDRINUSE) in test_memcg_sock()
1332 if (err == EADDRINUSE) { in test_memcg_sock()
1337 if (tcp_client(memcg, port) != KSFT_PASS) in test_memcg_sock()
1341 if (WEXITSTATUS(err)) in test_memcg_sock()
1344 if (cg_read_long(memcg, "memory.current") < 0) in test_memcg_sock()
1347 if (cg_read_key_long(memcg, "memory.stat", "sock ")) in test_memcg_sock()
1374 if (!parent || !child) in test_memcg_oom_group_leaf_events()
1377 if (cg_create(parent)) in test_memcg_oom_group_leaf_events()
1380 if (cg_create(child)) in test_memcg_oom_group_leaf_events()
1383 if (cg_write(parent, "cgroup.subtree_control", "+memory")) in test_memcg_oom_group_leaf_events()
1386 if (cg_write(child, "memory.max", "50M")) in test_memcg_oom_group_leaf_events()
1389 if (cg_write(child, "memory.swap.max", "0")) in test_memcg_oom_group_leaf_events()
1392 if (cg_write(child, "memory.oom.group", "1")) in test_memcg_oom_group_leaf_events()
1398 if (!cg_run(child, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_leaf_events()
1401 if (cg_test_proc_killed(child)) in test_memcg_oom_group_leaf_events()
1404 if (cg_read_key_long(child, "memory.events", "oom_kill ") <= 0) in test_memcg_oom_group_leaf_events()
1410 * If memory_localevents is not enabled (the default), the parent should in test_memcg_oom_group_leaf_events()
1414 if (has_localevents && parent_oom_events != 0) in test_memcg_oom_group_leaf_events()
1416 else if (!has_localevents && parent_oom_events <= 0) in test_memcg_oom_group_leaf_events()
1422 if (child) in test_memcg_oom_group_leaf_events()
1424 if (parent) in test_memcg_oom_group_leaf_events()
1445 if (!parent || !child) in test_memcg_oom_group_parent_events()
1448 if (cg_create(parent)) in test_memcg_oom_group_parent_events()
1451 if (cg_create(child)) in test_memcg_oom_group_parent_events()
1454 if (cg_write(parent, "memory.max", "80M")) in test_memcg_oom_group_parent_events()
1457 if (cg_write(parent, "memory.swap.max", "0")) in test_memcg_oom_group_parent_events()
1460 if (cg_write(parent, "memory.oom.group", "1")) in test_memcg_oom_group_parent_events()
1467 if (!cg_run(child, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_parent_events()
1470 if (cg_test_proc_killed(child)) in test_memcg_oom_group_parent_events()
1472 if (cg_test_proc_killed(parent)) in test_memcg_oom_group_parent_events()
1478 if (child) in test_memcg_oom_group_parent_events()
1480 if (parent) in test_memcg_oom_group_parent_events()
1501 if (!memcg) in test_memcg_oom_group_score_events()
1504 if (cg_create(memcg)) in test_memcg_oom_group_score_events()
1507 if (cg_write(memcg, "memory.max", "50M")) in test_memcg_oom_group_score_events()
1510 if (cg_write(memcg, "memory.swap.max", "0")) in test_memcg_oom_group_score_events()
1513 if (cg_write(memcg, "memory.oom.group", "1")) in test_memcg_oom_group_score_events()
1517 if (set_oom_adj_score(safe_pid, OOM_SCORE_ADJ_MIN)) in test_memcg_oom_group_score_events()
1521 if (!cg_run(memcg, alloc_anon, (void *)MB(100))) in test_memcg_oom_group_score_events()
1524 if (cg_read_key_long(memcg, "memory.events", "oom_kill ") != 3) in test_memcg_oom_group_score_events()
1527 if (kill(safe_pid, SIGKILL)) in test_memcg_oom_group_score_events()
1533 if (memcg) in test_memcg_oom_group_score_events()
1567 if (cg_find_unified_root(root, sizeof(root), NULL)) in main()
1574 if (cg_read_strstr(root, "cgroup.controllers", "memory")) in main()
1577 if (cg_read_strstr(root, "cgroup.subtree_control", "memory")) in main()
1578 if (cg_write(root, "cgroup.subtree_control", "+memory")) in main()
1582 if (proc_status < 0) in main()
1587 if (proc_status < 0) in main()