Lines Matching +full:peak +full:- +full:to +full:- +full:peak
1 /* SPDX-License-Identifier: GPL-2.0 */
98 int ret = -1; in alloc_anon_50M_check()
103 return -1; in alloc_anon_50M_check()
132 int ret = -1; in alloc_pagecache_50M_check()
138 return -1; in alloc_pagecache_50M_check()
164 * and checks memory.current, memory.peak, and some memory.stat values.
169 long current, peak, peak_reset; in test_memcg_current_peak() local
172 int peak_fd = -1, peak_fd2 = -1, peak_fd3 = -1, peak_fd4 = -1; in test_memcg_current_peak()
186 peak = cg_read_long(memcg, "memory.peak"); in test_memcg_current_peak()
187 if (peak != 0) in test_memcg_current_peak()
193 peak = cg_read_long(memcg, "memory.peak"); in test_memcg_current_peak()
194 if (peak < MB(50)) in test_memcg_current_peak()
198 * We'll open a few FDs for the same memory.peak file to exercise the free-path in test_memcg_current_peak()
199 * We need at least three to be closed in a different order than writes occurred to test in test_memcg_current_peak()
200 * the linked-list handling. in test_memcg_current_peak()
202 peak_fd = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC); in test_memcg_current_peak()
204 if (peak_fd == -1) { in test_memcg_current_peak()
211 * Before we try to use memory.peak's fd, try to figure out whether in test_memcg_current_peak()
212 * this kernel supports writing to that file in the first place. (by in test_memcg_current_peak()
223 peak_fd2 = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC); in test_memcg_current_peak()
225 if (peak_fd2 == -1) in test_memcg_current_peak()
228 peak_fd3 = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC); in test_memcg_current_peak()
230 if (peak_fd3 == -1) in test_memcg_current_peak()
233 /* any non-empty string resets, but make it clear */ in test_memcg_current_peak()
248 /* Make sure a completely independent read isn't affected by our FD-local reset above*/ in test_memcg_current_peak()
249 peak = cg_read_long(memcg, "memory.peak"); in test_memcg_current_peak()
250 if (peak < MB(50)) in test_memcg_current_peak()
257 peak_fd4 = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC); in test_memcg_current_peak()
259 if (peak_fd4 == -1) in test_memcg_current_peak()
266 peak = cg_read_long_fd(peak_fd); in test_memcg_current_peak()
267 if (peak > MB(30) || peak < 0) in test_memcg_current_peak()
273 peak = cg_read_long(memcg, "memory.peak"); in test_memcg_current_peak()
274 if (peak < MB(50)) in test_memcg_current_peak()
277 /* Make sure everything is back to normal */ in test_memcg_current_peak()
278 peak = cg_read_long_fd(peak_fd); in test_memcg_current_peak()
279 if (peak < MB(50)) in test_memcg_current_peak()
282 peak = cg_read_long_fd(peak_fd4); in test_memcg_current_peak()
283 if (peak < MB(50)) in test_memcg_current_peak()
316 return -1; in alloc_pagecache_50M_noexit()
333 return -1; in alloc_anon_noexit()
354 for (limit = 10; limit > 0; limit--) { in cg_test_proc_killed()
360 return -1; in cg_test_proc_killed()
389 * After that it tries to allocate more than there is
394 * Then we try to reclaim from A/B/C using memory.reclaim until its
547 for (i = ARRAY_SIZE(children) - 1; i >= 0; i--) { in test_memcg_protection()
555 for (i = ARRAY_SIZE(parent) - 1; i >= 0; i--) { in test_memcg_protection()
579 int ret = -1; in alloc_pagecache_max_30M()
586 return -1; in alloc_pagecache_max_30M()
590 return -1; in alloc_pagecache_max_30M()
664 return -1; in alloc_anon_mlock()
672 * This test checks that memory.high is able to throttle big single shot
677 int ret = KSFT_FAIL, pid, fd = -1; in test_memcg_high_sync()
784 * Reclaim from @memcg until usage reaches @goal by writing to
790 * This function assumes that writing to memory.reclaim is the only
805 for (retries = 5; retries > 0; retries--) { in reclaim_until()
814 to_reclaim = current - goal; in reclaim_until()
819 else if (err != -EAGAIN) in reclaim_until()
832 int fd = -1; in test_memcg_reclaim()
855 * If swap is enabled, try to reclaim from both anon and file, else try in test_memcg_reclaim()
856 * to reclaim from file only. in test_memcg_reclaim()
871 if (retries--) { in test_memcg_reclaim()
876 "failed to allocate %ld for memcg reclaim test\n", in test_memcg_reclaim()
904 int ret = -1; in alloc_anon_50M_check_swap()
909 return -1; in alloc_anon_50M_check_swap()
933 * memory.swap.peak reflects the high watermark and can be reset.
939 long max, peak; in test_memcg_swap_max_peak() local
941 int swap_peak_fd = -1, mem_peak_fd = -1; in test_memcg_swap_max_peak()
943 /* any non-empty string resets */ in test_memcg_swap_max_peak()
961 swap_peak_fd = cg_open(memcg, "memory.swap.peak", in test_memcg_swap_max_peak()
964 if (swap_peak_fd == -1) { in test_memcg_swap_max_peak()
971 * Before we try to use memory.swap.peak's fd, try to figure out in test_memcg_swap_max_peak()
972 * whether this kernel supports writing to that file in the first in test_memcg_swap_max_peak()
983 mem_peak_fd = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC); 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()
994 /* switch the swap and mem fds into local-peak tracking mode*/ in test_memcg_swap_max_peak()
1003 if (cg_read_long(memcg, "memory.peak")) in test_memcg_swap_max_peak()
1038 peak = cg_read_long(memcg, "memory.peak"); in test_memcg_swap_max_peak()
1039 if (peak < MB(29)) in test_memcg_swap_max_peak()
1042 peak = cg_read_long(memcg, "memory.swap.peak"); in test_memcg_swap_max_peak()
1043 if (peak < MB(29)) in test_memcg_swap_max_peak()
1046 peak = cg_read_long_fd(mem_peak_fd); in test_memcg_swap_max_peak()
1047 if (peak < MB(29)) in test_memcg_swap_max_peak()
1050 peak = cg_read_long_fd(swap_peak_fd); in test_memcg_swap_max_peak()
1051 if (peak < MB(29)) in test_memcg_swap_max_peak()
1055 * open, reset and close the peak swap on another FD to make sure in test_memcg_swap_max_peak()
1056 * multiple extant fds don't corrupt the linked-list in test_memcg_swap_max_peak()
1058 peak_reset = cg_write(memcg, "memory.swap.peak", (char *)reset_string); in test_memcg_swap_max_peak()
1062 peak_reset = cg_write(memcg, "memory.peak", (char *)reset_string); in test_memcg_swap_max_peak()
1075 peak = cg_read_long_fd(swap_peak_fd); in test_memcg_swap_max_peak()
1076 if (peak > MB(10)) in test_memcg_swap_max_peak()
1081 * with the open FD accounted to it. in test_memcg_swap_max_peak()
1083 peak = cg_read_long_fd(mem_peak_fd); 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()
1100 peak = cg_read_long(memcg, "memory.peak"); in test_memcg_swap_max_peak()
1101 if (peak < MB(29)) in test_memcg_swap_max_peak()
1104 peak = cg_read_long(memcg, "memory.swap.peak"); in test_memcg_swap_max_peak()
1105 if (peak < MB(29)) in test_memcg_swap_max_peak()
1108 peak = cg_read_long_fd(mem_peak_fd); in test_memcg_swap_max_peak()
1109 if (peak < MB(29)) in test_memcg_swap_max_peak()
1112 peak = cg_read_long_fd(swap_peak_fd); 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()
1130 * This test disables swapping and tries to allocate anonymous memory
1131 * up to OOM. Then it checks for oom and oom_kill events in
1183 int sk, client_sk, ctl_fd, yes = 1, ret = -1; in tcp_server()
1185 close(srv_args->ctl[0]); in tcp_server()
1186 ctl_fd = srv_args->ctl[1]; in tcp_server()
1190 saddr.sin6_port = htons(srv_args->port); in tcp_server()
1209 ret = -1; in tcp_server()
1217 ret = -1; in tcp_server()
1250 sk = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); in tcp_client()
1254 ret = connect(sk, ai->ai_addr, ai->ai_addrlen); in tcp_client()
1259 while (retries--) { in tcp_client()
1272 /* exclude the memory not related to socket connection */ in tcp_client()
1273 if (values_close(current - allocated, sock, 10)) { in tcp_client()
1289 * and 61000. Once it gets a client connection, it starts writing to
1307 while (bind_retries--) { in test_memcg_sock()
1360 * This test disables swapping and tries to allocate anonymous memory
1361 * up to OOM with memory.group.oom set. Then it checks that all
1363 * were propagated to the parent level.
1433 * This test disables swapping and tries to allocate anonymous memory
1434 * up to OOM with memory.group.oom set. Then it checks that all
1489 * This test disables swapping and tries to allocate anonymous memory
1490 * up to OOM with memory.group.oom set. Then it checks that all
1579 ksft_exit_skip("Failed to set memory controller\n"); in main()
1583 ksft_exit_skip("Failed to query cgroup mount option\n"); in main()
1588 ksft_exit_skip("Failed to query cgroup mount option\n"); in main()