swapon01.c: Apply a margin to avoid oom
PATCH 1/1 swapon01.c: Apply a margin to avoid oom
During our test i find a oom error during test which triggered by tst_pollute_memory.
kernel: oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
kernel: Memory cgroup out of memory: Killed process 9575 (swapon01) total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB, shmem-rss:0k0
--- testcases/kernel/syscalls/swapon/swapon01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/swapon/swapon01.c +3 -1
@@ -41,7 +41,9 @@ static void setup(void)make_swapfile (SWAP_FILE ,10 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); -SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +/* Apply a margin to avoid oom during tst_pollute_memory */ +SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM +TESTMEM /100 ); }static struct tst_test test = {
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 19 lines · Wei Gao via ltp
During our test i find a oom error during test which triggered by
tst_pollute_memory.kernel:
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
kernel: Memory cgroup out of memory: Killed process 9575 (swapon01)
total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB, shmem-rss:0k0Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/swapon/swapon01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)testcases/kernel/syscalls/swapon/swapon01.c +0
-0
testcases/kernel/syscalls/swapon/swapon01.c static void setup(void) · line 47
Quoted 8 lines
testcases/kernel/syscalls/swapon/swapon01.c +3
-1@@ -41,7 +41,9 @@ static void setup(void)make_swapfile (SWAP_FILE ,10 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); -SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +/* Apply a margin to avoid oom during tst_pollute_memory */ +SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM +TESTMEM /100 );
Even with a bit of margin added there is still not guarantee to avoid OOM completely.
As the Cgroup V1 and V2 track memory and swap in two ways, if the margin is too large that might not make the swap happen which is not our expectation.
So other method I can think of is to disable the OOM in Cgoup,
echo 1 > memory.oom_control
or, set overcommit_memory to 2 to prevent the OOM from occurring.
echo 2 > /proc/sys/vm/overcommit_memory
Quoted 11 lines
testcases/kernel/syscalls/swapon/swapon01.c +0
-0}static struct
tst_testtest = {
--
2.35.3--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 35 lines · Li Wang
Hi Wei,
Quoted 19 lines · Wei Gao via ltp
During our test i find a oom error during test which triggered by
tst_pollute_memory.kernel:
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
kernel: Memory cgroup out of memory: Killed process 9575 (swapon01)
total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB, shmem-rss:0k0Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/swapon/swapon01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)testcases/kernel/syscalls/swapon/swapon01.c +0
-0testcases/kernel/syscalls/swapon/swapon01.c static void setup(void) · line 47
Quoted 8 lines
testcases/kernel/syscalls/swapon/swapon01.c +3
-1@@ -41,7 +41,9 @@ static void setup(void)make_swapfile (SWAP_FILE ,10 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); -SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +/* Apply a margin to avoid oom during tst_pollute_memory */ +SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM +TESTMEM /100 );Even with a bit of margin added there is still not guarantee to avoid OOM completely.
Quoted 5 lines
As the Cgroup V1 and V2 track memory and swap in two ways, if the margin is too large that might not make the swap happen which is not our expectation.
So other method I can think of is to disable the OOM in Cgoup,
echo 1 > memory.oom_control
This option not exist in cgroupv2, it seems no direct oom control for cgroupv2
Quoted 2 lines
or, set
overcommit_memoryto 2 to prevent the OOM from occurring.
echo 2 >/proc/sys/vm/overcommit_memory
I have tried this option, oom still happen.
Quoted 19 lines
Quoted 15 lines
testcases/kernel/syscalls/swapon/swapon01.c +0
-0}static struct
tst_testtest = {
--
2.35.3--
Mailing list info: https://lists.linux.it/listinfo/ltpSignature · 2 lines
Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 40 lines · Wei Gao
Quoted 3 lines · Li Wang
Hi Wei,
On Thu, Mar 14, 2024 at 9:33 AM Wei Gao via ltp <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
During our test i find a oom error during test which triggered by
tst_pollute_memory.kernel:
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
Quoted 16 lines
Quoted 16 lines
kernel: Memory cgroup out of memory: Killed process 9575 (swapon01) total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB, shmem-rss:0k0
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/swapon/swapon01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)testcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -41,7 +41,9 @@ static void setup(void)make_swapfile (SWAP_FILE ,10 ,0 );Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c static void setup(void)
Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c +3
-1SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); -SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +/* Apply a margin to avoid oom during tst_pollute_memory */ + SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM +TESTMEM/100);
Quoted 6 lines
Quoted 1 line
Even with a bit of margin added there is still not guarantee to avoid OOM completely.
As the Cgroup V1 and V2 track memory and swap in two ways, if the margin
Quoted 9 lines
is
Quoted 1 line
too large that might not make the swap happen which is not our
expectation.
Quoted 3 lines
So other method I can think of is to disable the OOM in Cgoup,
echo 1 > memory.oom_controlThis option not exist in cgroupv2, it seems no direct oom control for cgroupv2
Ok, which version (found the OOM issue) did you test on? Maybe here we have to split the control work into two parts (V1 and V2).
Quoted 4 lines
Quoted 2 lines
or, set
overcommit_memoryto 2 to prevent the OOM from occurring.
echo 2 >/proc/sys/vm/overcommit_memoryI have tried this option, oom still happen.
Well, it looks like overcommit controlled by overcommit_memory is allowed for the entire system, not just the Cgroup.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 46 lines · Li Wang
Quoted 44 lines · Wei Gao
Quoted 3 lines · Li Wang
Hi Wei,
On Thu, Mar 14, 2024 at 9:33 AM Wei Gao via ltp <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
During our test i find a oom error during test which triggered by
tst_pollute_memory.kernel:
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
Quoted 16 lines
Quoted 16 lines
kernel: Memory cgroup out of memory: Killed process 9575 (swapon01) total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB, shmem-rss:0k0
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/swapon/swapon01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)testcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -41,7 +41,9 @@ static void setup(void)make_swapfile (SWAP_FILE ,10 ,0 );Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c static void setup(void)
Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c +3
-1SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); -SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +/* Apply a margin to avoid oom during tst_pollute_memory */ + SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM +TESTMEM/100);
Quoted 6 lines
Quoted 1 line
Even with a bit of margin added there is still not guarantee to avoid OOM completely.
As the Cgroup V1 and V2 track memory and swap in two ways, if the margin
is
Quoted 1 line
too large that might not make the swap happen which is not our
expectation.
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
So other method I can think of is to disable the OOM in Cgoup,
echo 1 > memory.oom_controlThis option not exist in cgroupv2, it seems no direct oom control for cgroupv2
Ok, which version (found the OOM issue) did you test on?
mount | grep cgroup
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
Quoted 1 line
Maybe here we have to split the control work into two parts (V1 and V2).
How to disable OOM and also let swap action happen at the same time for cgroup V2?
Thanks for your such quick feedback :)
Quoted 15 lines
Quoted 7 lines
Quoted 5 lines
or, set
overcommit_memoryto 2 to prevent the OOM from occurring.
echo 2 >/proc/sys/vm/overcommit_memoryI have tried this option, oom still happen.
Well, it looks like overcommit controlled by
overcommit_memoryis allowed for the entire system, not just the Cgroup.Signature · 2 lines
Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 61 lines · Wei Gao
Quoted 6 lines · Li Wang
Quoted 4 lines · Wei Gao
Quoted 3 lines · Li Wang
Hi Wei,
On Thu, Mar 14, 2024 at 9:33 AM Wei Gao via ltp <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · wrote:
Quoted 6 lines
During our test i find a oom error during test which triggered by
tst_pollute_memory.kernel:
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
kernel: Memory cgroup out of memory: Killed process 9575 (swapon01) total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB,
shmem-rss:0k0
Quoted 22 lines
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/swapon/swapon01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)testcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -41,7 +41,9 @@ static void setup(void)make_swapfile (SWAP_FILE ,10 ,0 );Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c static void setup(void) · line 46
Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c +3
-1SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); -SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +/* Apply a margin to avoid oom during tst_pollute_memory */ + SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM +TESTMEM/100);
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Even with a bit of margin added there is still not guarantee to
avoid OOM
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
completely.
As the Cgroup V1 and V2 track memory and swap in two ways, if the
margin
Quoted 11 lines
Quoted 9 lines
is
Quoted 1 line
too large that might not make the swap happen which is not our
expectation.
Quoted 3 lines
So other method I can think of is to disable the OOM in Cgoup,
echo 1 > memory.oom_controlThis option not exist in cgroupv2, it seems no direct oom control for cgroupv2
Ok, which version (found the OOM issue) did you test on?
mount | grep cgroup
cgroup2 on/sys/fs/cgrouptype cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
Quoted 7 lines
Quoted 1 line
Maybe here we have to split the control work into two parts (V1 and V2).
How to disable OOM and also let swap action happen at the same time for cgroup V2?
The Cgroup v2 does not provide a way to disable OOM inside directly.
If we want to avoid OOM happening, just have to manage OOM behavior in cgroup v2 by setting appropriate values for 'memory.max', 'memory.high', and using 'memory.oom.group' to determine whether the OOM killer should target individual processes or the whole Cgroup.
After looking back at this case again, I guess the main reason is that the swapfile is too small to bear the memory load, one direct method is like you to enlarge the 'memory.max' value, but that still does not resolve problems eventually.
One possible solution is crate a bit larger swapfile for the test, and unlimited
the swap out size. Can you try this patch on your system?
testcases/kernel/syscalls/swapon/swapon01.c +5 -1
@@ -38,10 +38,14 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); }static struct tst_test test = {
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 101 lines · Li Wang
Quoted 64 lines · Wei Gao
Quoted 7 lines · Li Wang
Quoted 4 lines · Wei Gao
Quoted 3 lines · Li Wang
Hi Wei,
On Thu, Mar 14, 2024 at 9:33 AM Wei Gao via ltp <[email protected]
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · wrote:
Quoted 6 lines
During our test i find a oom error during test which triggered by
tst_pollute_memory.kernel:
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
kernel: Memory cgroup out of memory: Killed process 9575
(swapon01)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB,
shmem-rss:0k0
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/swapon/swapon01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)testcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -41,7 +41,9 @@ static void setup(void)make_swapfile (SWAP_FILE ,10 ,0 );Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
testcases/kernel/syscalls/swapon/swapon01.c static void setup(void) · line 45
Quoted 4 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-1SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); -SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +/* Apply a margin to avoid oom during tst_pollute_memory */
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
testcases/kernel/syscalls/swapon/swapon01.c static void setup(void) · line 46
Quoted 1 line
testcases/kernel/syscalls/swapon/swapon01.c +1
-0+ SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM +TESTMEM/100);
Quoted 3 lines
Quoted 1 line
Even with a bit of margin added there is still not guarantee to
avoid OOM
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
completely.
As the Cgroup V1 and V2 track memory and swap in two ways, if the
margin
Quoted 11 lines
Quoted 9 lines
is
Quoted 1 line
too large that might not make the swap happen which is not our
expectation.
Quoted 3 lines
So other method I can think of is to disable the OOM in Cgoup,
echo 1 > memory.oom_controlThis option not exist in cgroupv2, it seems no direct oom control for cgroupv2
Ok, which version (found the OOM issue) did you test on?
mount | grep cgroup
cgroup2 on/sys/fs/cgrouptype cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)Quoted 7 lines
Quoted 1 line
Maybe here we have to split the control work into two parts (V1 and V2).
How to disable OOM and also let swap action happen at the same time for cgroup V2?
The Cgroup v2 does not provide a way to disable OOM inside directly.
If we want to avoid OOM happening, just have to manage OOM behavior in cgroup v2 by setting appropriate values for 'memory.max', 'memory.high', and using 'memory.oom.group' to determine whether the OOM killer should target individual processes or the whole Cgroup.
After looking back at this case again, I guess the main reason is that the swapfile is too small to bear the memory load, one direct method is like you to enlarge the 'memory.max' value, but that still does not resolve problems eventually.
One possible solution is crate a bit larger swapfile for the test, and unlimited
the swap out size. Can you try this patch on your system?testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -38,10 +38,14 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );
testcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 51
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +4
-0SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); }static struct tst_test test = {
If this still does not work as expected, then we need plus additional policy to shrink the pollute memory size.
- tst_pollute_memory(TESTMEM, 0x41);
+ tst_pollute_memory(TESTMEM * 9/10, 0x41);
Quoted 1 line
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 85 lines · Li Wang
Quoted 83 lines · Li Wang
Quoted 64 lines · Wei Gao
Quoted 7 lines · Li Wang
Quoted 4 lines · Wei Gao
Quoted 3 lines · Li Wang
Hi Wei,
On Thu, Mar 14, 2024 at 9:33 AM Wei Gao via ltp <[email protected]
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · wrote:
Quoted 6 lines
During our test i find a oom error during test which triggered by
tst_pollute_memory.kernel:
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
kernel: Memory cgroup out of memory: Killed process 9575
(swapon01)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB,
shmem-rss:0k0
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/syscalls/swapon/swapon01.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)testcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -41,7 +41,9 @@ static void setup(void)make_swapfile (SWAP_FILE ,10 ,0 );Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
testcases/kernel/syscalls/swapon/swapon01.c static void setup(void) · line 45
Quoted 4 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-1SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); -SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +/* Apply a margin to avoid oom during tst_pollute_memory */
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
testcases/kernel/syscalls/swapon/swapon01.c static void setup(void) · line 46
Quoted 1 line
testcases/kernel/syscalls/swapon/swapon01.c +1
-0+ SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM +TESTMEM/100);
Quoted 3 lines
Quoted 1 line
Even with a bit of margin added there is still not guarantee to
avoid OOM
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
completely.
As the Cgroup V1 and V2 track memory and swap in two ways, if the
margin
Quoted 11 lines
Quoted 9 lines
is
Quoted 1 line
too large that might not make the swap happen which is not our
expectation.
Quoted 3 lines
So other method I can think of is to disable the OOM in Cgoup,
echo 1 > memory.oom_controlThis option not exist in cgroupv2, it seems no direct oom control for cgroupv2
Ok, which version (found the OOM issue) did you test on?
mount | grep cgroup
cgroup2 on/sys/fs/cgrouptype cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)Quoted 7 lines
Quoted 1 line
Maybe here we have to split the control work into two parts (V1 and V2).
How to disable OOM and also let swap action happen at the same time for cgroup V2?
The Cgroup v2 does not provide a way to disable OOM inside directly.
If we want to avoid OOM happening, just have to manage OOM behavior in cgroup v2 by setting appropriate values for 'memory.max', 'memory.high', and using 'memory.oom.group' to determine whether the OOM killer should target individual processes or the whole Cgroup.
Quoted 8 lines
Quoted 8 lines
After looking back at this case again, I guess the main reason is that the swapfile is too small to bear the memory load, one direct method is like you to enlarge the 'memory.max' value, but that still does not resolve problems eventually.
One possible solution is crate a bit larger swapfile for the test, and unlimited
the swap out size. Can you try this patch on your system?
This not work.
Quoted 24 lines
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -38,10 +38,14 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );testcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 51
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +4
-0SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); }static struct tst_test test = {If this still does not work as expected, then we need plus additional policy to shrink the pollute memory size.
Review
Quoted 2 lines
(quoted diff) +1
-1- tst_pollute_memory(TESTMEM, 0x41); + tst_pollute_memory(TESTMEM * 9/10, 0x41);
This works.
Quoted 6 lines
Quoted 2 lines
Signature · 2 lines
Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 16 lines · Wei Gao
Quoted 1 line
Quoted 1 line
Quoted 1 line
How to disable OOM and also let swap action happen at the same time
for
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
cgroup V2?
The Cgroup v2 does not provide a way to disable OOM inside directly.
If we want to avoid OOM happening, just have to manage OOM behavior in cgroup v2 by setting appropriate values for 'memory.max',
'memory.high',
Quoted 4 lines
Quoted 4 lines
and using 'memory.oom.group' to determine whether the OOM killer should target individual processes or the whole Cgroup.
After looking back at this case again, I guess the main reason is that
the
Quoted 1 line
Quoted 1 line
swapfile is too small to bear the memory load, one direct method is
Quoted 9 lines
like
Quoted 6 lines
Quoted 6 lines
you to enlarge the 'memory.max' value, but that still does not resolve problems eventually.
One possible solution is crate a bit larger swapfile for the test, and unlimited
the swap out size. Can you try this patch on your system?This not work.
Interesting, how about resizing the swapfile size to larger? can you try that.
Quoted 24 lines
Quoted 24 lines
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -38,10 +38,14 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );testcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 51
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +4
-0SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); }static struct tst_test test = {If this still does not work as expected, then we need plus additional policy to shrink the pollute memory size.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- tst_pollute_memory(TESTMEM, 0x41); + tst_pollute_memory(TESTMEM * 9/10, 0x41);This works.
Can you post more info about the test output?
One concern I have is that the swap is not being triggered with shrinking the pollute memory.
And also it'd be great to have free -h cat /proc/meminfo lscpu uname -r info.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 swapon01: swapon01: prevent OOM happening in swap process
Here we take many ways to prevent the OOM happening with run the swapon test:
* shrink the pollute memory size
* increase swapfile size
* setting swap max for Cgroup
* setting test oom_score_adj to -1000
---
Notes:
Hi Wei,
Could you please test this patch and post the output messages? Thanks!!
testcases/kernel/syscalls/swapon/swapon01.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/swapon/swapon01.c +14 -3
@@ -26,7 +26,7 @@ static void verify_swapon(void) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); -tst_pollute_memory (TESTMEM ,0x41 ); +tst_pollute_memory (TESTMEM *9 /10 ,0x41 );tst_res (TINFO ,"SwapCached: %ld Kb" ,SAFE_READ_MEMINFO ("SwapCached:" ));if (TST_PASS &&tst_syscall (__NR_swapoff,SWAP_FILE ) !=0 ) {
@@ -37,11 +37,21 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct tst_test test = {
@@ -51,5 +61,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 8 lines · Li Wang
Here we take many ways to prevent the OOM happening with run the swapon test:
* shrink the pollute memory size
* increase swapfile size
* setting swap max for Cgroup
* setting testoom_score_adjto -1000
Quoted 8 lines
Reproted-by Wei Gao <[email protected]>Signed-off-by Li Wang <[email protected]>---
Notes:
Hi Wei,Could you please test this patch and post the output messages?
tst_device.c:97: TINFO: Found free device 1 '/dev/loop1'
tst_test.c:1741: TINFO: LTP version: 20240129-94-g8f14b06e0
tst_test.c:1627: TINFO: Timeout per run is 0h 00m 30s tst_supported_fs_types.c:97: TINFO: Kernel supports ext2 tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext3 tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext4 tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports xfs tst_supported_fs_types.c:62: TINFO: mkfs.xfs does exist tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs tst_supported_fs_types.c:62: TINFO: mkfs.btrfs does exist tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist tst_supported_fs_types.c:97: TINFO: Kernel supports vfat tst_supported_fs_types.c:62: TINFO: mkfs.vfat does exist tst_supported_fs_types.c:97: TINFO: Kernel supports exfat tst_supported_fs_types.c:58: TINFO: mkfs.exfat does not exist tst_supported_fs_types.c:128: TINFO: Filesystem ntfs is not supported tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext2 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swafHGLPe/mntpoint fstyp=ext2 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:27: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext3 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext3 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swafHGLPe/mntpoint fstyp=ext3 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:27: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext4 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext4 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swafHGLPe/mntpoint fstyp=ext4 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:27: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on xfs ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with xfs opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swafHGLPe/mntpoint fstyp=xfs flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:27: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on btrfs ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with btrfs opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swafHGLPe/mntpoint fstyp=btrfs flags=0 libswap.c:42: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:125: TINFO: File 'mntpoint/swapfile01' is not contiguous libswap.c:42: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01 swapon01.c:27: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on vfat ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with vfat opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swafHGLPe/mntpoint fstyp=vfat flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:27: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on tmpfs ===
tst_test.c:1118: TINFO: Skipping mkfs for TMPFS filesystem
tst_test.c:1098: TINFO: Limiting tmpfs size to 32MB
tst_test.c:1132: TINFO: Mounting ltp-tmpfs to /tmp/LTP_swafHGLPe/mntpoint fstyp=tmpfs flags=0 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:214: TCONF: Swapfile on tmpfs not implemented
Summary:
passed 6 failed 0 broken 0 skipped 1
warnings 0
Quoted 52 lines
Thanks!!
testcases/kernel/syscalls/swapon/swapon01.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)testcases/kernel/syscalls/swapon/swapon01.c +14
-3@@ -26,7 +26,7 @@ static void verify_swapon(void) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); -tst_pollute_memory (TESTMEM ,0x41 ); +tst_pollute_memory (TESTMEM *9 /10 ,0x41 );tst_res (TINFO ,"SwapCached: %ld Kb" ,SAFE_READ_MEMINFO ("SwapCached:" ));if (TST_PASS &&tst_syscall (__NR_swapoff,SWAP_FILE ) !=0 ) {@@ -37,11 +37,21 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct tst_test test = {@@ -51,5 +61,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };Signature · 1 line
2.40.1
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 95 lines · Wei Gao
Quoted 8 lines · Li Wang
Here we take many ways to prevent the OOM happening with run the swapon test:
* shrink the pollute memory size
* increase swapfile size
* setting swap max for Cgroup
* setting testoom_score_adjto -1000Quoted 8 lines
Reproted-by Wei Gao <[email protected]>Signed-off-by Li Wang <[email protected]>---
Notes:
Hi Wei,Could you please test this patch and post the output messages?
tst_device.c:97: TINFO: Found free device 1 '
/dev/loop1' tst_test.c:1741: TINFO: LTP version: 20240129-94-g8f14b06e0 tst_test.c:1627: TINFO: Timeout per run is 0h 00m 30s tst_supported_fs_types.c:97: TINFO: Kernel supports ext2 tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext3 tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext4 tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports xfs tst_supported_fs_types.c:62: TINFO: mkfs.xfs does exist tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs tst_supported_fs_types.c:62: TINFO: mkfs.btrfs does exist tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist
tst_supported_fs_types.c:97: TINFO: Kernel supports vfat tst_supported_fs_types.c:62: TINFO: mkfs.vfat does exist tst_supported_fs_types.c:97: TINFO: Kernel supports exfat tst_supported_fs_types.c:58: TINFO: mkfs.exfat does not exist tst_supported_fs_types.c:128: TINFO: Filesystem ntfs is not supported tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 === tst_test.c:1118: TINFO: Formatting/dev/loop1with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext3 === tst_test.c:1118: TINFO: Formatting/dev/loop1with ext3 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=ext3 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext4 === tst_test.c:1118: TINFO: Formatting/dev/loop1with ext4 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=ext4 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on xfs === tst_test.c:1118: TINFO: Formatting/dev/loop1with xfs opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=xfs flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on btrfs === tst_test.c:1118: TINFO: Formatting/dev/loop1with btrfs opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=btrfs flags=0
libswap.c:42: TINFO:FS_NOCOW_FLattribute set on mntpoint/swapfile01 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:125: TINFO: File 'mntpoint/swapfile01' is not contiguous libswap.c:42: TINFO:FS_NOCOW_FLattribute set on mntpoint/swapfile01 swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on vfat === tst_test.c:1118: TINFO: Formatting/dev/loop1with vfat opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=vfat flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed
Quoted 2 lines
swapon01.c:30: TINFO: SwapCached: 0 Kb
That's my concern here, with shrinking the polluted memory size, swapping is not triggered, this is not what we expected.
And could you cat /proc/sys/vm/swappiness before doing the test?
An improved V2 (with setting swappiness to 60 percent):
testcases/kernel/syscalls/swapon/swapon01.c +1 -1
@@ -26,7 +26,7 @@ static void verify_swapon(void) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); -tst_pollute_memory (TESTMEM ,0x41 ); +tst_pollute_memory (TESTMEM *9 /10 ,0x41 ); tst_res(TINFO, "SwapCached: %ld Kb",
SAFE_READ_MEMINFO("SwapCached:"));
if (TST_PASS && tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {@@ -37,11 +37,25 @@ static void verify_swapon(void)
static void setup(void)
{
+ tst_enable_oom_protection(0);
is_swap_supported(SWAP_FILE);- make_swapfile(SWAP_FILE, 10, 0);
+ make_swapfile(SWAP_FILE, 1024, 0);
SAFE_CG_PRINTF(tst_cg, "cgroup.procs", "%d", getpid());
SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM);+
+ if (SAFE_CG_HAS(tst_cg, "memory.swap.max"))
+ SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld", TESTMEM *
2);
+
+ if (SAFE_CG_HAS(tst_cg, "memory.swappiness"))
+ SAFE_CG_PRINT(tst_cg, "memory.swappiness", "60");
+ else
+ FILE_PRINTF("/proc/sys/vm/swappiness", "%d", 60);
+}
+
+static void cleanup(void)
+{
+ tst_disable_oom_protection(0);
}
static struct tst_test test = {
@@ -50,6 +64,12 @@ static struct tst_test test = {
.needs_root = 1,
.all_filesystems = 1,
.needs_cgroup_ctrls = (const char *const []){ "memory", NULL },+ .save_restore = (const struct tst_path_val[]) {
+ {"/proc/sys/vm/swappiness", NULL,
+ TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
+ {}
+ },
.test_all = verify_swapon,
- .setup = setup + .setup = setup, + .cleanup = cleanup
};
Quoted 72 lines
tst_test.c:1701: TINFO: === Testing on tmpfs === tst_test.c:1118: TINFO: Skipping mkfs for TMPFS filesystem tst_test.c:1098: TINFO: Limiting tmpfs size to 32MB tst_test.c:1132: TINFO: Mounting ltp-tmpfs to
/tmp/LTP_swafHGLPe/mntpointfstyp=tmpfs flags=0
tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:214: TCONF: Swapfile on tmpfs not implementedSummary:
passed 6 failed 0 broken 0 skipped 1warnings 0
Review
Quoted 6 lines
Thanks!!
testcases/kernel/syscalls/swapon/swapon01.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/testcases/kernel/syscalls/swapon/swapon01.ctestcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 30
Quoted 10 lines
index
d406e4bd9..b4fc02d6e100644testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -26,7 +26,7 @@ static void verify_swapon(void) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); -tst_pollute_memory (TESTMEM ,0x41 ); +tst_pollute_memory (TESTMEM *9 /10 ,0x41 ); tst_res(TINFO, "SwapCached: %ld Kb",
SAFE_READ_MEMINFO("SwapCached:"));Quoted 36 lines
testcases/kernel/syscalls/swapon/swapon01.c +13
-3if (TST_PASS &&tst_syscall (__NR_swapoff,SWAP_FILE ) !=0 ) {@@ -37,11 +37,21 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct tst_test test = {@@ -51,5 +61,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup }; --2.40.1
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 97 lines · Li Wang
Quoted 93 lines · Wei Gao
Quoted 8 lines · Li Wang
Here we take many ways to prevent the OOM happening with run the swapon test:
* shrink the pollute memory size
* increase swapfile size
* setting swap max for Cgroup
* setting testoom_score_adjto -1000Quoted 8 lines
Reproted-by Wei Gao <[email protected]>Signed-off-by Li Wang <[email protected]>---
Notes:
Hi Wei,Could you please test this patch and post the output messages?
tst_device.c:97: TINFO: Found free device 1 '
/dev/loop1' tst_test.c:1741: TINFO: LTP version: 20240129-94-g8f14b06e0 tst_test.c:1627: TINFO: Timeout per run is 0h 00m 30s tst_supported_fs_types.c:97: TINFO: Kernel supports ext2 tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext3 tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext4 tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports xfs tst_supported_fs_types.c:62: TINFO: mkfs.xfs does exist tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs tst_supported_fs_types.c:62: TINFO: mkfs.btrfs does exist tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist
tst_supported_fs_types.c:97: TINFO: Kernel supports vfat tst_supported_fs_types.c:62: TINFO: mkfs.vfat does exist tst_supported_fs_types.c:97: TINFO: Kernel supports exfat tst_supported_fs_types.c:58: TINFO: mkfs.exfat does not exist tst_supported_fs_types.c:128: TINFO: Filesystem ntfs is not supported tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 === tst_test.c:1118: TINFO: Formatting/dev/loop1with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext3 === tst_test.c:1118: TINFO: Formatting/dev/loop1with ext3 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=ext3 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext4 === tst_test.c:1118: TINFO: Formatting/dev/loop1with ext4 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=ext4 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on xfs === tst_test.c:1118: TINFO: Formatting/dev/loop1with xfs opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=xfs flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on btrfs === tst_test.c:1118: TINFO: Formatting/dev/loop1with btrfs opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=btrfs flags=0
libswap.c:42: TINFO:FS_NOCOW_FLattribute set on mntpoint/swapfile01 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:125: TINFO: File 'mntpoint/swapfile01' is not contiguous libswap.c:42: TINFO:FS_NOCOW_FLattribute set on mntpoint/swapfile01 swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on vfat === tst_test.c:1118: TINFO: Formatting/dev/loop1with vfat opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to/tmp/LTP_swafHGLPe/mntpointfstyp=vfat flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed
Quoted 7 lines
Quoted 2 lines
swapon01.c:30: TINFO: SwapCached: 0 Kb
That's my concern here, with shrinking the polluted memory size, swapping is not triggered, this is not what we expected.
And could you
cat /proc/sys/vm/swappinessbefore doing the test?
before the test the swappiness is 60
cat /proc/sys/vm/swappiness
60
I have tried use swappiness 60 or 100 the result is same(SwapCached: 0 Kb) tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1118: TINFO: Formatting /dev/loop4 with ext2 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop4 to /tmp/LTP_swajCvvix/mntpoint fstyp=ext2 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:27: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:31: TINFO: SwapCached: 0 Kb <<<<<<<<<
Quoted 137 lines
An improved V2 (with setting swappiness to 60 percent):
testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -26,7 +26,7 @@ static void verify_swapon(void) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); -tst_pollute_memory (TESTMEM ,0x41 ); +tst_pollute_memory (TESTMEM *9 /10 ,0x41 );tst_res (TINFO ,"SwapCached: %ld Kb" ,SAFE_READ_MEMINFO ("SwapCached:" ));if (TST_PASS && tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {testcases/kernel/syscalls/swapon/swapon01.c +15
-1@@ -37,11 +37,25 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%ld" ,TESTMEM *2 ); + +if (SAFE_CG_HAS (tst_cg,"memory.swappiness" )) +SAFE_CG_PRINT (tst_cg,"memory.swappiness" ,"60" ); +else +FILE_PRINTF ("/proc/sys/vm/swappiness" ,"%d" ,60 ); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct
tst_testtest = {testcases/kernel/syscalls/swapon/swapon01.c +7
-1@@ -50,6 +64,12 @@ static struct tst_test test = { .needs_root = 1, .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, + .save_restore = (const struct tst_path_val []) { + {"/proc/sys/vm/swappiness" ,NULL , +TST_SR_SKIP_MISSING |TST_SR_TCONF_RO }, + {} + }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };Quoted 76 lines
tst_test.c:1701: TINFO: === Testing on tmpfs === tst_test.c:1118: TINFO: Skipping mkfs for TMPFS filesystem tst_test.c:1098: TINFO: Limiting tmpfs size to 32MB tst_test.c:1132: TINFO: Mounting ltp-tmpfs to
/tmp/LTP_swafHGLPe/mntpointfstyp=tmpfs flags=0
tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:214: TCONF: Swapfile on tmpfs not implementedSummary:
passed 6 failed 0 broken 0 skipped 1warnings 0
Review
Quoted 6 lines
Thanks!!
testcases/kernel/syscalls/swapon/swapon01.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/testcases/kernel/syscalls/swapon/swapon01.ctestcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 30
Quoted 10 lines
index
d406e4bd9..b4fc02d6e100644testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -26,7 +26,7 @@ static void verify_swapon(void) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); -tst_pollute_memory (TESTMEM ,0x41 ); +tst_pollute_memory (TESTMEM *9 /10 ,0x41 ); tst_res(TINFO, "SwapCached: %ld Kb",
SAFE_READ_MEMINFO("SwapCached:"));Quoted 36 lines
testcases/kernel/syscalls/swapon/swapon01.c +13
-3if (TST_PASS &&tst_syscall (__NR_swapoff,SWAP_FILE ) !=0 ) {@@ -37,11 +37,21 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct tst_test test = {@@ -51,5 +61,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup }; --2.40.1
Signature · 2 lines
Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Hi Wei,
Can you try this one and post the test log here?
And again, it'd be helpful to know the config of your SUT. e.g. free -h lscpu uname -r infoformation
testcases/kernel/syscalls/swapon/swapon01.c +5 -1
@@ -37,11 +37,20 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) + SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld", TESTMEM *
2);
+}
+
+static void cleanup(void)
+{
+ tst_disable_oom_protection(0);
}
static struct tst_test test = {
@@ -51,5 +60,6 @@ static struct tst_test test = {
.all_filesystems = 1,
.needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon,
- .setup = setup + .setup = setup, + .cleanup = cleanup
};
Quoted 267 lines · Wei Gao
Quoted 38 lines · Li Wang
Quoted 36 lines · Wei Gao
Quoted 8 lines · Li Wang
Here we take many ways to prevent the OOM happening with run the swapon test:
* shrink the pollute memory size
* increase swapfile size
* setting swap max for Cgroup
* setting testoom_score_adjto -1000Quoted 8 lines
Reproted-by Wei Gao <[email protected]>Signed-off-by Li Wang <[email protected]>---
Notes:
Hi Wei,Could you please test this patch and post the output messages?
tst_device.c:97: TINFO: Found free device 1 '
/dev/loop1' tst_test.c:1741: TINFO: LTP version: 20240129-94-g8f14b06e0 tst_test.c:1627: TINFO: Timeout per run is 0h 00m 30s tst_supported_fs_types.c:97: TINFO: Kernel supports ext2 tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext3 tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext4 tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports xfs tst_supported_fs_types.c:62: TINFO: mkfs.xfs does exist tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs tst_supported_fs_types.c:62: TINFO: mkfs.btrfs does exist tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist
tst_supported_fs_types.c:97: TINFO: Kernel supports vfat tst_supported_fs_types.c:62: TINFO: mkfs.vfat does exist tst_supported_fs_types.c:97: TINFO: Kernel supports exfat tst_supported_fs_types.c:58: TINFO: mkfs.exfat does not existQuoted 8 lines
Quoted 8 lines
tst_supported_fs_types.c:128: TINFO: Filesystem ntfs is not supported tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 === tst_test.c:1118: TINFO: Formatting
/dev/loop1with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to
/tmp/LTP_swafHGLPe/mntpointQuoted 9 lines
Quoted 9 lines
fstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext3 === tst_test.c:1118: TINFO: Formatting/dev/loop1with ext3 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to
/tmp/LTP_swafHGLPe/mntpointQuoted 9 lines
Quoted 9 lines
fstyp=ext3 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext4 === tst_test.c:1118: TINFO: Formatting/dev/loop1with ext4 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop1to
/tmp/LTP_swafHGLPe/mntpointQuoted 8 lines
Quoted 8 lines
fstyp=ext4 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on xfs === tst_test.c:1118: TINFO: Formatting/dev/loop1with xfs opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to
/tmp/LTP_swafHGLPe/mntpointQuoted 8 lines
Quoted 8 lines
fstyp=xfs flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on btrfs === tst_test.c:1118: TINFO: Formatting/dev/loop1with btrfs opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to
/tmp/LTP_swafHGLPe/mntpointQuoted 11 lines
Quoted 11 lines
fstyp=btrfs flags=0
libswap.c:42: TINFO:FS_NOCOW_FLattribute set on mntpoint/swapfile01 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:125: TINFO: File 'mntpoint/swapfile01' is not contiguous libswap.c:42: TINFO:FS_NOCOW_FLattribute set on mntpoint/swapfile01 swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:30: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on vfat === tst_test.c:1118: TINFO: Formatting/dev/loop1with vfat opts='' extra opts=''
tst_test.c:1132: TINFO: Mounting/dev/loop1to
/tmp/LTP_swafHGLPe/mntpointQuoted 6 lines
Quoted 4 lines
fstyp=vfat flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passedQuoted 7 lines
Quoted 2 lines
swapon01.c:30: TINFO: SwapCached: 0 Kb
That's my concern here, with shrinking the polluted memory size, swapping is not triggered, this is not what we expected.
And could you
cat /proc/sys/vm/swappinessbefore doing the test?before the test the swappiness is 60
cat/proc/sys/vm/swappiness
60I have tried use swappiness 60 or 100 the result is same(SwapCached: 0 Kb) tst_test.c:1701: TINFO: === Testing on ext2 === tst_test.c:1118: TINFO: Formatting
/dev/loop4with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting/dev/loop4to/tmp/LTP_swajCvvix/mntpointfstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapon01.c:27: TPASS:tst_syscall(__NR_swapon, SWAP_FILE, 0)passed swapon01.c:31: TINFO: SwapCached: 0 Kb <<<<<<<<<Quoted 19 lines
An improved V2 (with setting swappiness to 60 percent):
testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -26,7 +26,7 @@ static void verify_swapon(void) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); -tst_pollute_memory (TESTMEM ,0x41 ); +tst_pollute_memory (TESTMEM *9 /10 ,0x41 );tst_res (TINFO ,"SwapCached: %ld Kb" ,SAFE_READ_MEMINFO ("SwapCached:" ));if (TST_PASS && tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {testcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -37,11 +37,25 @@ static void verify_swapon(void)static void setup (void ) {testcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 48
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +5
-1+tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) + SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld", TESTMEM*
Quoted 32 lines
testcases/kernel/syscalls/swapon/swapon01.c +10
-02); + +if (SAFE_CG_HAS (tst_cg,"memory.swappiness" )) +SAFE_CG_PRINT (tst_cg,"memory.swappiness" ,"60" ); +else +FILE_PRINTF ("/proc/sys/vm/swappiness" ,"%d" ,60 ); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct
tst_testtest = {testcases/kernel/syscalls/swapon/swapon01.c +7
-1@@ -50,6 +64,12 @@ static struct tst_test test = { .needs_root = 1, .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, + .save_restore = (const struct tst_path_val []) { + {"/proc/sys/vm/swappiness" ,NULL , +TST_SR_SKIP_MISSING |TST_SR_TCONF_RO }, + {} + }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };Quoted 4 lines
Quoted 4 lines
tst_test.c:1701: TINFO: === Testing on tmpfs === tst_test.c:1118: TINFO: Skipping mkfs for TMPFS filesystem tst_test.c:1098: TINFO: Limiting tmpfs size to 32MB tst_test.c:1132: TINFO: Mounting ltp-tmpfs to
/tmp/LTP_swafHGLPe/mntpointQuoted 72 lines
Quoted 54 lines
fstyp=tmpfs flags=0
tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:214: TCONF: Swapfile on tmpfs not implementedSummary:
passed 6 failed 0 broken 0 skipped 1warnings 0
Review
Quoted 6 lines
Thanks!!
testcases/kernel/syscalls/swapon/swapon01.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/testcases/kernel/syscalls/swapon/swapon01.ctestcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 30
Quoted 10 lines
index
d406e4bd9..b4fc02d6e100644testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -26,7 +26,7 @@ static void verify_swapon(void) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); -tst_pollute_memory (TESTMEM ,0x41 ); +tst_pollute_memory (TESTMEM *9 /10 ,0x41 ); tst_res(TINFO, "SwapCached: %ld Kb",
SAFE_READ_MEMINFO("SwapCached:"));Quoted 24 lines
testcases/kernel/syscalls/swapon/swapon01.c +11
-1if (TST_PASS &&tst_syscall (__NR_swapoff,SWAP_FILE ) !=0 ) {@@ -37,11 +37,21 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); +if (TST_CG_VER_IS_V1 (tst_cg,"memory" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" , ~0UL ); +else +SAFE_CG_PRINT (tst_cg,"memory.swap.max" ,"max" ); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }Quoted 14 lines
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-2static struct tst_test test = {@@ -51,5 +61,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup }; --Quoted 2 lines
2.40.1
--
Regards,
Li Wang
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 36 lines · Li Wang
Hi Wei,
Can you try this one and post the test log here?
And again, it'd be helpful to know the config of your SUT. e.g.
free -hlscpuuname -rinfoformationtestcases/kernel/syscalls/swapon/swapon01.c +10
-1@@ -37,11 +37,20 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%ld" ,TESTMEM *2 ); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct
tst_testtest = {
testcases/kernel/syscalls/swapon/swapon01.c static struct tst_test test = { · line 65
Quoted 7 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-1@@ -51,5 +60,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };
localhost:~ # free -h <<<< before running case
total used free shared buff/cache available
Mem: 3.8Gi 478Mi 3.3Gi 9.0Mi 346Mi 3.4Gi
Swap: 0B 0B 0B
localhost:~ # lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Vendor ID: GenuineIntel
BIOS Vendor ID: QEMU
Model name: Intel(R) Xeon(R) Gold 5218R CPU @ 2.10GHz
BIOS Model name: pc-i440fx-7.1 CPU @ 2.0GHz
BIOS CPU family: 1
CPU family: 6
Model: 85
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 2
Stepping: 7
BogoMIPS: 4190.15
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1 gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnow prefetch cpuid_fault ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust b mi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512 vl xsaveopt xsavec xgetbv1 xsaves arat vnmi umip pku ospke avx512_vnni md_clear arch_capabilities
Virtualization features:
Virtualization: VT-x Hypervisor vendor: KVM Virtualization type: full Caches (sum of all): L1d: 64 KiB (2 instances) L1i: 64 KiB (2 instances) L2: 8 MiB (2 instances) L3: 32 MiB (2 instances) NUMA: NUMA node(s): 2 NUMA node0 CPU(s): 0 NUMA node1 CPU(s): 1 Vulnerabilities: Gather data sampling: Unknown: Dependent on hypervisor status Itlb multihit: Not affected L1tf: Not affected Mds: Not affected Meltdown: Not affected Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown Retbleed: Mitigation; Enhanced IBRS Spec rstack overflow: Not affected Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Spectre v2: Mitigation; Enhanced / Automatic IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence Srbds: Not affected Tsx async abort: Mitigation; Clear CPU buffers; SMT Host state unknown
localhost:~ # uname -r
6.4.0-9-default
swapon01 100% 851KB 386.5KB/s 00:02
tst_device.c:97: TINFO: Found free device 0 '/dev/loop0'
tst_test.c:1741: TINFO: LTP version: 20240129-94-g8f14b06e0
tst_test.c:1627: TINFO: Timeout per run is 0h 00m 30s tst_supported_fs_types.c:97: TINFO: Kernel supports ext2 tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext3 tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext4 tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports xfs tst_supported_fs_types.c:62: TINFO: mkfs.xfs does exist tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs tst_supported_fs_types.c:62: TINFO: mkfs.btrfs does exist tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist tst_supported_fs_types.c:97: TINFO: Kernel supports vfat tst_supported_fs_types.c:62: TINFO: mkfs.vfat does exist tst_supported_fs_types.c:97: TINFO: Kernel supports exfat tst_supported_fs_types.c:58: TINFO: mkfs.exfat does not exist tst_supported_fs_types.c:128: TINFO: Filesystem ntfs is not supported tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1118: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop0 to /tmp/LTP_swakWRRNY/mntpoint fstyp=ext2 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:27: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed
Test timeouted, sending SIGKILL!
tst_test.c:1680: TINFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1 tst_test.c:1681: TBROK: Test killed! (timeout?)
Summary:
passed 1
failed 0
broken 1
skipped 0
warnings 0
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 1...
tst_device.c:413: TINFO: Likely gvfsd-trash is probing newly mounted fs, kill it to speed up tests.
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 2...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 3...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 4...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 5...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 6...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 7...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 8...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 9...tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 10...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 11...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 12...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 13...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 14...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 15...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 16...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 17...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 18...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 19...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 20...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 21...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 22...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 23...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 24...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 25...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 26...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 27...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 28...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 29...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 30...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 31...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 32...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 33...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 34...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 35...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 36...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 37...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 38...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 39...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 40...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 41...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 42...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 43...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 44...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 45...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 46...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 47...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 48...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 49...
tst_device.c:409: TINFO: umount('mntpoint') failed with EBUSY, try 50...
tst_device.c:419: TWARN: Failed to umount('mntpoint') after 50 retries
tst_device.c:264: TWARN: ioctl(/dev/loop0, LOOP_CLR_FD, 0) no ENXIO for too long
tst_tmpdir.c:343: TWARN: tst_rmdir: rmobj(/tmp/LTP_swakWRRNY) failed: unlink(/tmp/LTP_swakWRRNY/mntpoint/swapfile01) failed; errno=1: EPERM
localhost:~ # free -h <<<< after running case
total used free shared buff/cache available
Mem: 3.8Gi 480Mi 3.3Gi 32Mi 395Mi 3.4Gi Swap: 3.0Mi 0B 3.0Mi
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 49 lines · Wei Gao
Quoted 14 lines · Li Wang
Hi Wei,
Can you try this one and post the test log here?
And again, it'd be helpful to know the config of your SUT. e.g.
free -hlscpuuname -rinfoformationtestcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -37,11 +37,20 @@ static void verify_swapon(void)static void setup (void ) {testcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 48
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +5
-1+tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) + SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld", TESTMEM*
Quoted 12 lines
testcases/kernel/syscalls/swapon/swapon01.c +5
-02); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct
tst_testtest = {testcases/kernel/syscalls/swapon/swapon01.c static struct tst_test test = { · line 65
Quoted 7 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-1@@ -51,5 +60,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };
Quoted 7 lines
localhost:~ # free -h <<<< before running case
total used free shared buff/cache
available
Mem: 3.8Gi 478Mi 3.3Gi 9.0Mi 346Mi
3.4Gi
Swap: 0B 0B 0B
I see, it is very likely that your system has no swap space so that the TESTMEM(1GB) can not be swapped out, then OOM killer has to be called out.
I can reproduce your problem by disabling all swap files on my system.
So the possible fix way is to reduce the TESTMEM size and increase the tested swapfile.
I guess this patch can work for you, have a try?
testcases/kernel/syscalls/swapon/swapon01.c +2 -2
@@ -20,7 +20,7 @@#define MNTPOINT "mntpoint"#define SWAP_FILE MNTPOINT"/swapfile01" -#define TESTMEM (1UL<<30) +#define TESTMEM (1UL<<24)/* 16MB */ static void verify_swapon (void ) {
@@ -38,7 +38,7 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,4096 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM );
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 63 lines · Li Wang
Quoted 49 lines · Wei Gao
Quoted 14 lines · Li Wang
Hi Wei,
Can you try this one and post the test log here?
And again, it'd be helpful to know the config of your SUT. e.g.
free -hlscpuuname -rinfoformationtestcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -37,11 +37,20 @@ static void verify_swapon(void)static void setup (void ) {testcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 48
Quoted 10 lines
testcases/kernel/syscalls/swapon/swapon01.c +5
-1+tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) + SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld", TESTMEM*
Quoted 12 lines
testcases/kernel/syscalls/swapon/swapon01.c +5
-02); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }static struct
tst_testtest = {testcases/kernel/syscalls/swapon/swapon01.c static struct tst_test test = { · line 65
Quoted 7 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-1@@ -51,5 +60,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };Quoted 7 lines
localhost:~ # free -h <<<< before running case
total used free shared buff/cache
available
Mem: 3.8Gi 478Mi 3.3Gi 9.0Mi 346Mi
3.4Gi
Swap: 0B 0B 0BI see, it is very likely that your system has no swap space so that the TESTMEM(1GB) can not be swapped out, then OOM killer has to be called out.
Quoted 6 lines
I can reproduce your problem by disabling all swap files on my system.
So the possible fix way is to reduce the TESTMEM size and increase the tested swapfile.
I guess this patch can work for you, have a try?
No oom, but SwapCached size is unstable, most of time is still 0
wegao:/home/ltp # ./scp.sh
rm -f -f -r swapon01 swapon02 swapon03 *.o *.pyc .cache.mk *.dwo .*.dwo
make -C "/home/ltp/lib" -f "/home/ltp/lib/Makefile" all
make[1]: Entering directory '/home/ltp/lib'
GEN ltp-version.h
make[2]: Nothing to be done for 'all'.
make[2]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/ltp/lib'
BUILD libltpswap.a
make[1]: Nothing to be done for 'all'.
CC testcases/kernel/syscalls/swapon/swapon01
CC testcases/kernel/syscalls/swapon/swapon02
CC testcases/kernel/syscalls/swapon/swapon03
swapon01 100% 851KB 373.6KB/s 00:02
tst_device.c:97: TINFO: Found free device 1 '/dev/loop1'
tst_test.c:1741: TINFO: LTP version: 20240129-92-g9fa305fe3
tst_test.c:1627: TINFO: Timeout per run is 0h 00m 30s
tst_supported_fs_types.c:97: TINFO: Kernel supports ext2 tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext3 tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext4 tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports xfs tst_supported_fs_types.c:62: TINFO: mkfs.xfs does exist tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs tst_supported_fs_types.c:62: TINFO: mkfs.btrfs does exist tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist tst_supported_fs_types.c:97: TINFO: Kernel supports vfat tst_supported_fs_types.c:62: TINFO: mkfs.vfat does exist tst_supported_fs_types.c:97: TINFO: Kernel supports exfat tst_supported_fs_types.c:58: TINFO: mkfs.exfat does not exist tst_supported_fs_types.c:128: TINFO: Filesystem ntfs is not supported tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext2 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaDbjDqs/mntpoint fstyp=ext2 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed
swapon01.c:31: TINFO: SwapCached: 56 Kb <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< tst_test.c:1701: TINFO: === Testing on ext3 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext3 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaDbjDqs/mntpoint fstyp=ext3 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed
swapon01.c:31: TINFO: SwapCached: 0 Kb <<<<<<<<<<<<<<<<<<<<<<<<<<
tst_test.c:1701: TINFO: === Testing on ext4 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext4 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaDbjDqs/mntpoint fstyp=ext4 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed
swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on xfs ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with xfs opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaDbjDqs/mntpoint fstyp=xfs flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed
swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on btrfs ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with btrfs opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaDbjDqs/mntpoint fstyp=btrfs flags=0 libswap.c:42: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22)
libswap.c:125: TINFO: File 'mntpoint/swapfile01' is not contiguous
libswap.c:42: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01 swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed
swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on vfat ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with vfat opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaDbjDqs/mntpoint fstyp=vfat flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed
swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on tmpfs ===
tst_test.c:1118: TINFO: Skipping mkfs for TMPFS filesystem
tst_test.c:1098: TINFO: Limiting tmpfs size to 32MB
tst_test.c:1132: TINFO: Mounting ltp-tmpfs to /tmp/LTP_swaDbjDqs/mntpoint fstyp=tmpfs flags=0 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22)
libswap.c:214: TCONF: Swapfile on tmpfs not implemented
Summary:
passed 6 failed 0 broken 0 skipped 1
warnings 0
wegao:/home/ltp # ./scp.sh
rm -f -f -r swapon01 swapon02 swapon03 *.o *.pyc .cache.mk *.dwo .*.dwo
make -C "/home/ltp/lib" -f "/home/ltp/lib/Makefile" all
make[1]: Entering directory '/home/ltp/lib'
GEN ltp-version.h
make[2]: Nothing to be done for 'all'.
make[2]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/ltp/lib'
BUILD libltpswap.a
make[1]: Nothing to be done for 'all'.
CC testcases/kernel/syscalls/swapon/swapon01
CC testcases/kernel/syscalls/swapon/swapon02
CC testcases/kernel/syscalls/swapon/swapon03
swapon01 100% 851KB 96.5KB/s 00:08
tst_device.c:97: TINFO: Found free device 1 '/dev/loop1'
tst_test.c:1741: TINFO: LTP version: 20240129-92-g9fa305fe3
tst_test.c:1627: TINFO: Timeout per run is 0h 00m 30s tst_supported_fs_types.c:97: TINFO: Kernel supports ext2 tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext3 tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports ext4 tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist tst_supported_fs_types.c:97: TINFO: Kernel supports xfs tst_supported_fs_types.c:62: TINFO: mkfs.xfs does exist tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs tst_supported_fs_types.c:62: TINFO: mkfs.btrfs does exist tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist tst_supported_fs_types.c:97: TINFO: Kernel supports vfat tst_supported_fs_types.c:62: TINFO: mkfs.vfat does exist tst_supported_fs_types.c:97: TINFO: Kernel supports exfat tst_supported_fs_types.c:58: TINFO: mkfs.exfat does not exist tst_supported_fs_types.c:128: TINFO: Filesystem ntfs is not supported tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext2 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaJSeWym/mntpoint fstyp=ext2 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:31: TINFO: SwapCached: 0 Kb <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< tst_test.c:1701: TINFO: === Testing on ext3 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext3 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaJSeWym/mntpoint fstyp=ext3 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on ext4 ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with ext4 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaJSeWym/mntpoint fstyp=ext4 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on xfs ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with xfs opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaJSeWym/mntpoint fstyp=xfs flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on btrfs ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with btrfs opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaJSeWym/mntpoint fstyp=btrfs flags=0 libswap.c:42: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:125: TINFO: File 'mntpoint/swapfile01' is not contiguous libswap.c:42: TINFO: FS_NOCOW_FL attribute set on mntpoint/swapfile01 swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on vfat ===
tst_test.c:1118: TINFO: Formatting /dev/loop1 with vfat opts='' extra opts='' tst_test.c:1132: TINFO: Mounting /dev/loop1 to /tmp/LTP_swaJSeWym/mntpoint fstyp=vfat flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapon01.c:28: TPASS: tst_syscall(__NR_swapon, SWAP_FILE, 0) passed swapon01.c:31: TINFO: SwapCached: 0 Kb
tst_test.c:1701: TINFO: === Testing on tmpfs ===
tst_test.c:1118: TINFO: Skipping mkfs for TMPFS filesystem
tst_test.c:1098: TINFO: Limiting tmpfs size to 32MB
tst_test.c:1132: TINFO: Mounting ltp-tmpfs to /tmp/LTP_swaJSeWym/mntpoint fstyp=tmpfs flags=0 tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:214: TCONF: Swapfile on tmpfs not implemented
Summary:
passed 6 failed 0 broken 0 skipped 1
warnings 0
Quoted 26 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-2@@ -20,7 +20,7 @@#define MNTPOINT "mntpoint"#define SWAP_FILE MNTPOINT"/swapfile01" -#define TESTMEM (1UL<<30) +#define TESTMEM (1UL<<24)/* 16MB */ static void verify_swapon (void ) {@@ -38,7 +38,7 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,4096 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM );Signature · 3 lines
-- Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 66 lines · Wei Gao
Quoted 22 lines · Li Wang
Quoted 20 lines · Wei Gao
Quoted 19 lines · Li Wang
Hi Wei,
Can you try this one and post the test log here?
And again, it'd be helpful to know the config of your SUT. e.g.
free -hlscpuuname -rinfoformationtestcases/kernel/syscalls/swapon/swapon01.c +2
-1@@ -37,11 +37,20 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );Quoted 5 lines
Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 48
Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c +3
-0SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) + SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld",TESTMEM
Quoted 9 lines
Quoted 9 lines
*
Quoted 8 lines
testcases/kernel/syscalls/swapon/swapon01.c +5
-02); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }Quoted 4 lines
Quoted 4 lines
testcases/kernel/syscalls/swapon/swapon01.c static struct tst_test test = { · line 61
Quoted 4 lines
static struct
tst_testtest = {testcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -51,5 +60,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){"memory" ,NULL },
Quoted 23 lines
Quoted 11 lines
testcases/kernel/syscalls/swapon/swapon01.c static struct tst_test test = { · line 65
Quoted 7 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-1.test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };Quoted 7 lines
localhost:~ # free -h <<<< before running case
total used free shared buff/cache
available
Mem: 3.8Gi 478Mi 3.3Gi 9.0Mi 346Mi
3.4Gi
Swap: 0B 0B 0BI see, it is very likely that your system has no swap space so that the TESTMEM(1GB) can not be swapped out, then OOM killer has to be called out.
Quoted 9 lines
Quoted 6 lines
I can reproduce your problem by disabling all swap files on my system.
So the possible fix way is to reduce the TESTMEM size and increase the tested swapfile.
I guess this patch can work for you, have a try?
No oom, but SwapCached size is unstable, most of time is still 0
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper size.
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for swapoff01.c.
And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 82 lines · Li Wang
Quoted 66 lines · Wei Gao
Quoted 22 lines · Li Wang
Quoted 20 lines · Wei Gao
Quoted 19 lines · Li Wang
Hi Wei,
Can you try this one and post the test log here?
And again, it'd be helpful to know the config of your SUT. e.g.
free -hlscpuuname -rinfoformationtestcases/kernel/syscalls/swapon/swapon01.c +2
-1@@ -37,11 +37,20 @@ static void verify_swapon(void)static void setup (void ) { +tst_enable_oom_protection (0 );is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,1024 ,0 );Quoted 5 lines
Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c static void verify_swapon(void) · line 48
Quoted 5 lines
testcases/kernel/syscalls/swapon/swapon01.c +3
-0SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); + +if (SAFE_CG_HAS (tst_cg,"memory.swap.max" )) + SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%ld",TESTMEM
Quoted 9 lines
Quoted 9 lines
*
Quoted 8 lines
testcases/kernel/syscalls/swapon/swapon01.c +5
-02); +} + +static void cleanup (void ) +{ +tst_disable_oom_protection (0 ); }Quoted 4 lines
Quoted 4 lines
testcases/kernel/syscalls/swapon/swapon01.c static struct tst_test test = { · line 61
Quoted 4 lines
static struct
tst_testtest = {testcases/kernel/syscalls/swapon/swapon01.c +0
-0@@ -51,5 +60,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){"memory" ,NULL },
Quoted 23 lines
Quoted 11 lines
testcases/kernel/syscalls/swapon/swapon01.c static struct tst_test test = { · line 65
Quoted 7 lines
testcases/kernel/syscalls/swapon/swapon01.c +2
-1.test_all = verify_swapon, - .setup = setup + .setup = setup, + .cleanup = cleanup };Quoted 7 lines
localhost:~ # free -h <<<< before running case
total used free shared buff/cache
available
Mem: 3.8Gi 478Mi 3.3Gi 9.0Mi 346Mi
3.4Gi
Swap: 0B 0B 0BI see, it is very likely that your system has no swap space so that the TESTMEM(1GB) can not be swapped out, then OOM killer has to be called out.
Quoted 9 lines
Quoted 6 lines
I can reproduce your problem by disabling all swap files on my system.
So the possible fix way is to reduce the TESTMEM size and increase the tested swapfile.
I guess this patch can work for you, have a try?
No oom, but SwapCached size is unstable, most of time is still 0
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper size.
Quoted 7 lines
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check following patch?
testcases/kernel/syscalls/swapon/swapon01.c +11 -1
@@ -14,13 +14,15 @@#include <unistd.h> #include <errno.h> #include <stdlib.h> +#include <sys/statvfs.h> #include "tst_test.h" #include "lapi/syscalls.h" #include "libswap.h" #define MNTPOINT "mntpoint"#define SWAP_FILE MNTPOINT"/swapfile01"#define TESTMEM (1UL<<30) +#define SWAP_SIZE 100 * 1024 * 1024/* 100MB */ static void verify_swapon (void ) {
@@ -37,8 +39,16 @@ static void verify_swapon(void)static void setup (void ) { +struct statvfs fs_info; +unsigned long blk_size; + +if (statvfs ("." , &fs_info) ==-1 ) +tst_brk (TBROK |TERRNO ,"Failed to call statvfs" ); + + blk_size = fs_info.f_bsize; +is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (SWAP_FILE ,SWAP_SIZE / blk_size ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM );
Quoted 4 lines
Signature · 3 lines
-- Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 8 lines · Wei Gao
Quoted 8 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper size.
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.
Quoted 7 lines
Quoted 3 lines
And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check following patch?
Can we rewrite the make_swapfile() API to support passing MB size for making the swapfile?
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 16 lines · Wei Gao
Quoted 13 lines
Quoted 13 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper size.
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
Quoted 6 lines
Quoted 2 lines
100M is good enough for current system, could you help check following patch?
Can we rewrite the
make_swapfile()API to support passing MB size for making the swapfile?
I guess it would be desirable (but keep also possible to pass that 10 blocks, therefore maybe use flag to distinguish between MB and blocks?).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 20 lines · Petr Vorel
Quoted 18 lines · Wei Gao
Quoted 17 lines
Quoted 7 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper size.
Quoted 6 lines
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check following patch?
Quoted 7 lines
Quoted 2 lines
Can we rewrite the
make_swapfile()API to support passing MB size for making the swapfile?I guess it would be desirable (but keep also possible to pass that 10 blocks,
therefore maybe use flag to distinguish between MB and blocks?).
That's fine but a bit complex for users to distinguish flags.
Or, what about making the function use the flag as static, and export two additional functions with MB and blocks?
enum swapfile_method {
SWAPFILE_BY_SIZE,
SWAPFILE_BY_BLOCKS
};
static int make_swapfile(const char *swapfile, unsigned int para, int safe,
enum swapfile_method method) {
// The main logic to achieve the swapfile-making process
// ...
}int make_swapfile_size(const char *swapfile, unsigned int size, int safe) {
return make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE); }
int make_swapfile_blks(const char *swapfile, unsigned int blocks, int safe)
{
return make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS);
}Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 49 lines · Li Wang
Quoted 21 lines · Petr Vorel
Quoted 7 lines · Wei Gao
Quoted 6 lines
Quoted 6 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper
size.
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check following patch?
Quoted 7 lines
Quoted 2 lines
Can we rewrite the
make_swapfile()API to support passing MB size for making the swapfile?I guess it would be desirable (but keep also possible to pass that 10 blocks,
therefore maybe use flag to distinguish between MB and blocks?).That's fine but a bit complex for users to distinguish flags.
Or, what about making the function use the flag as static, and export two additional functions with MB and blocks?
enum
swapfile_method{
SWAPFILE_BY_SIZE,
SWAPFILE_BY_BLOCKS
};static int make_swapfile(const char *swapfile, unsigned int para, int
safe, enum swapfile_method method) { // The main logic to achieve the swapfile-making process // ... }
Quoted 9 lines
int
make_swapfile_size(const char *swapfile, unsigned int size, int safe){return make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE); }int make_swapfile_blks(const char *swapfile, unsigned int blocks, int
safe) { return make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS); }
Even simpler to define two macros with one make_swapfile():
#define MAKE_SWAPFILE_SIZE(swapfile, size, safe) \
make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE)
#define MAKE_SWAPFILE_BLKS(swapfile, blocks, safe) \
make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 61 lines · Li Wang
Quoted 49 lines · Li Wang
Quoted 21 lines · Petr Vorel
Quoted 7 lines · Wei Gao
Quoted 6 lines
Quoted 6 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper
size.
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check following patch?
Quoted 7 lines
Quoted 2 lines
Can we rewrite the
make_swapfile()API to support passing MB size for making the swapfile?I guess it would be desirable (but keep also possible to pass that 10 blocks,
therefore maybe use flag to distinguish between MB and blocks?).That's fine but a bit complex for users to distinguish flags.
Or, what about making the function use the flag as static, and export two additional functions with MB and blocks?
enum
swapfile_method{
SWAPFILE_BY_SIZE,
SWAPFILE_BY_BLOCKS
};static int make_swapfile(const char *swapfile, unsigned int para, int
safe, enum swapfile_method method) { // The main logic to achieve the swapfile-making process // ... }Quoted 9 lines
int
make_swapfile_size(const char *swapfile, unsigned int size, int safe){return make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE); }int make_swapfile_blks(const char *swapfile, unsigned int blocks, int
safe) { return make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS); }
Quoted 9 lines
Even simpler to define two macros with one
make_swapfile():#define
MAKE_SWAPFILE_SIZE(swapfile, size, safe)\
make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE)#define
MAKE_SWAPFILE_BLKS(swapfile, blocks, safe)\
make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)
Make a quick below patch:
include/libswap.h +12 -1
@@ -14,7 +14,18 @@/* * Make a swap file */ -int make_swapfile (const char *swapfile,int blocks,int safe); +enum swapfile_method { +SWAPFILE_BY_SIZE , +SWAPFILE_BY_BLOCKS +}; + +int make_swapfile (const char *swapfile,unsigned int para,int safe,enum swapfile_method method); + +#define MAKE_SWAPFILE_SIZE (swapfile, size, safe) \ + make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE) + +#define MAKE_SWAPFILE_BLKS (swapfile, blocks, safe) \ + make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)/* * Check swapon/swapoff support status of filesystems or files
libs/libltpswap/libswap.c +8 -2
@@ -133,18 +133,24 @@ out:return contiguous; } -int make_swapfile (const char *swapfile,int blocks,int safe) +int make_swapfile (const char *swapfile,unsigned int para,int safe,enum swapfile_method method) {struct statvfs fs_info;unsigned long blk_size, bs;size_t pg_size =sysconf (_SC_PAGESIZE);char mnt_path[100 ]; +unsigned int blocks;if (statvfs ("." , &fs_info) ==-1 )return -1 ; blk_size = fs_info.f_bsize; +if (method ==SWAPFILE_BY_SIZE ) + blocks = para *1024 *1024 / blk_size; +else + blocks = para; +/* To guarantee at least one page can be swapped out */ if (blk_size * blocks < pg_size) bs = pg_size;
@@ -181,7 +187,7 @@ int make_swapfile(const char *swapfile, int blocks, int safe)bool is_swap_supported (const char *filename) {int i, sw_support =0 ; -int ret =make_swapfile (filename,10 ,1 ); +int ret =make_swapfile (filename,10 ,1 ,SWAPFILE_BY_BLOCKS );int fi_contiguous =file_is_contiguous (filename);long fs_type =tst_fs_type (filename);const char *fstype =tst_fs_type_name (fs_type);
testcases/kernel/syscalls/swapon/swapon01.c +1 -1
@@ -38,7 +38,7 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +MAKE_SWAPFILE_SIZE (SWAP_FILE ,100 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM );
testcases/kernel/syscalls/swapon/swapon02.c +2 -2
@@ -50,8 +50,8 @@ static void setup(void)is_swap_supported (TEST_FILE );SAFE_TOUCH (NOTSWAP_FILE ,0777 ,NULL ); -make_swapfile (SWAP_FILE ,10 ,0 ); -make_swapfile (USED_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (SWAP_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (USED_FILE ,10 ,0 );if (tst_syscall (__NR_swapon,USED_FILE ,0 ))tst_res (TWARN |TERRNO ,"swapon(alreadyused) failed" );
testcases/kernel/syscalls/swapon/swapon03.c +2 -2
@@ -49,7 +49,7 @@ static int setup_swap(void)/* Create the swapfile */ snprintf (filename,sizeof (filename),"%s%02d" ,TEST_FILE , j +2 ); -make_swapfile (filename,10 ,0 ); +MAKE_SWAPFILE_BLKS (filename,10 ,0 );/* turn on the swap file */ TST_EXP_PASS_SILENT (swapon (filename,0 ));
@@ -62,7 +62,7 @@ static int setup_swap(void)tst_brk (TFAIL ,"Failed to setup swap files" );tst_res (TINFO ,"Successfully created %d swap files" , swapfiles); -make_swapfile (TEST_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (TEST_FILE ,10 ,0 );return 0 ; }
Quoted 4 lines
Signature · 3 lines
-- Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 67 lines · Wei Gao
Quoted 19 lines · Li Wang
Quoted 17 lines · Li Wang
Quoted 13 lines · Petr Vorel
Quoted 7 lines · Wei Gao
Quoted 6 lines
Quoted 6 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper
size.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check
following
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
patch?
Can we rewrite the
make_swapfile()API to support passing MB sizefor
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
Quoted 1 line
making the swapfile?
I guess it would be desirable (but keep also possible to pass that 10 blocks,
therefore maybe use flag to distinguish between MB and blocks?).That's fine but a bit complex for users to distinguish flags.
Or, what about making the function use the flag as static, and export two additional functions with MB and blocks?
enum
swapfile_method{
SWAPFILE_BY_SIZE,
SWAPFILE_BY_BLOCKS
};Quoted 7 lines
Quoted 7 lines
static int make_swapfile(const char *swapfile, unsigned int para, int
safe, enum swapfile_method method) { // The main logic to achieve the swapfile-making process // ... }int make_swapfile_size(const char *swapfile, unsigned int size, int
safe) {
Quoted 11 lines
Quoted 8 lines
return make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE); }int make_swapfile_blks(const char *swapfile, unsigned int blocks, int
safe) { return make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS); }Even simpler to define two macros with one
make_swapfile():
Quoted 9 lines
Quoted 7 lines
#define
MAKE_SWAPFILE_SIZE(swapfile, size, safe)\
make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE)#define
MAKE_SWAPFILE_BLKS(swapfile, blocks, safe)\
make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)Make a quick below patch:
Thanks for your work Wei! (but seems duplicated with my patchset[1])
[1] https://lists.linux.it/pipermail/ltp/2024-March/037627.html
Sorry, I didn't mean to take the credit, I just tested it and found that the changes are quite simple, so just sent it out...
Would you mind helping out with comments and reviews there? And I can help to add your SBT tag later.
Quoted 128 lines
include/libswap.h +12
-1@@ -14,7 +14,18 @@/* * Make a swap file */ -int make_swapfile (const char *swapfile,int blocks,int safe); +enum swapfile_method { +SWAPFILE_BY_SIZE , +SWAPFILE_BY_BLOCKS +}; + +int make_swapfile (const char *swapfile,unsigned int para,int safe,enum swapfile_method method); + +#define MAKE_SWAPFILE_SIZE (swapfile, size, safe) \ + make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE) + +#define MAKE_SWAPFILE_BLKS (swapfile, blocks, safe) \ + make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)/* * Check swapon/swapoff support status of filesystems or files
libs/libltpswap/libswap.c +7
-1@@ -133,18 +133,24 @@ out:return contiguous; } -int make_swapfile (const char *swapfile,int blocks,int safe) +int make_swapfile (const char *swapfile,unsigned int para,int safe,enum swapfile_method method) {struct statvfs fs_info;unsigned long blk_size, bs;size_t pg_size =sysconf (_SC_PAGESIZE);char mnt_path[100 ]; +unsigned int blocks;if (statvfs ("." , &fs_info) ==-1 )return -1 ; blk_size = fs_info.f_bsize; +if (method ==SWAPFILE_BY_SIZE ) + blocks = para *1024 *1024 / blk_size; +else + blocks = para; +/* To guarantee at least one page can be swapped out */ if (blk_size * blocks < pg_size)bs = pg_size;libs/libltpswap/libswap.c +1
-1@@ -181,7 +187,7 @@ int make_swapfile(const char *swapfile, int blocks, int safe)bool is_swap_supported (const char *filename) {int i, sw_support =0 ; -int ret =make_swapfile (filename,10 ,1 ); +int ret =make_swapfile (filename,10 ,1 ,SWAPFILE_BY_BLOCKS );int fi_contiguous =file_is_contiguous (filename);long fs_type =tst_fs_type (filename);const char *fstype = tst_fs_type_name(fs_type);testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -38,7 +38,7 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +MAKE_SWAPFILE_SIZE (SWAP_FILE ,100 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM );testcases/kernel/syscalls/swapon/swapon02.c +2
-2@@ -50,8 +50,8 @@ static void setup(void)is_swap_supported (TEST_FILE );SAFE_TOUCH (NOTSWAP_FILE ,0777 ,NULL ); -make_swapfile (SWAP_FILE ,10 ,0 ); -make_swapfile (USED_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (SWAP_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (USED_FILE ,10 ,0 );if (tst_syscall (__NR_swapon,USED_FILE ,0 ))tst_res (TWARN |TERRNO ,"swapon(alreadyused) failed" );testcases/kernel/syscalls/swapon/swapon03.c +1
-1@@ -49,7 +49,7 @@ static int setup_swap(void)/* Create the swapfile */ snprintf (filename,sizeof (filename),"%s%02d" ,TEST_FILE , j +2 ); -make_swapfile (filename,10 ,0 ); +MAKE_SWAPFILE_BLKS (filename,10 ,0 );/* turn on the swap file */ TST_EXP_PASS_SILENT(swapon(filename, 0));testcases/kernel/syscalls/swapon/swapon03.c +1
-1@@ -62,7 +62,7 @@ static int setup_swap(void)tst_brk (TFAIL ,"Failed to setup swap files" );tst_res (TINFO ,"Successfully created %d swap files" , swapfiles); -make_swapfile (TEST_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (TEST_FILE ,10 ,0 );return 0 ; }Quoted 5 lines
--
Regards,
Li Wang
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
Quoted 79 lines · Li Wang
Quoted 67 lines · Wei Gao
Quoted 19 lines · Li Wang
Quoted 17 lines · Li Wang
Quoted 13 lines · Petr Vorel
Quoted 7 lines · Wei Gao
Quoted 6 lines
Quoted 6 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper
size.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check
following
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
patch?
Can we rewrite the
make_swapfile()API to support passing MB sizefor
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
Quoted 1 line
making the swapfile?
I guess it would be desirable (but keep also possible to pass that 10 blocks,
therefore maybe use flag to distinguish between MB and blocks?).That's fine but a bit complex for users to distinguish flags.
Or, what about making the function use the flag as static, and export two additional functions with MB and blocks?
enum
swapfile_method{
SWAPFILE_BY_SIZE,
SWAPFILE_BY_BLOCKS
};Quoted 7 lines
Quoted 7 lines
static int make_swapfile(const char *swapfile, unsigned int para, int
safe, enum swapfile_method method) { // The main logic to achieve the swapfile-making process // ... }int make_swapfile_size(const char *swapfile, unsigned int size, int
safe) {
Quoted 11 lines
Quoted 8 lines
return make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE); }int make_swapfile_blks(const char *swapfile, unsigned int blocks, int
safe) { return make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS); }Even simpler to define two macros with one
make_swapfile():Quoted 9 lines
Quoted 7 lines
#define
MAKE_SWAPFILE_SIZE(swapfile, size, safe)\
make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE)#define
MAKE_SWAPFILE_BLKS(swapfile, blocks, safe)\
make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)Make a quick below patch:
Quoted 9 lines
Thanks for your work Wei! (but seems duplicated with my patchset[1])
[1] https://lists.linux.it/pipermail/ltp/2024-March/037627.htmlSorry, I didn't mean to take the credit, I just tested it and found that the changes are quite simple, so just sent it out...
Would you mind helping out with comments and reviews there? And I can help to add your SBT tag later.
No problem, i have checked your patch and looks good to me, no more comments. I suppose we can merge this soon, thanks for your patch :)
Quoted 134 lines
Quoted 130 lines
include/libswap.h +12
-1@@ -14,7 +14,18 @@/* * Make a swap file */ -int make_swapfile (const char *swapfile,int blocks,int safe); +enum swapfile_method { +SWAPFILE_BY_SIZE , +SWAPFILE_BY_BLOCKS +}; + +int make_swapfile (const char *swapfile,unsigned int para,int safe,enum swapfile_method method); + +#define MAKE_SWAPFILE_SIZE (swapfile, size, safe) \ + make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE) + +#define MAKE_SWAPFILE_BLKS (swapfile, blocks, safe) \ + make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)/* * Check swapon/swapoff support status of filesystems or files
libs/libltpswap/libswap.c +7
-1@@ -133,18 +133,24 @@ out:return contiguous; } -int make_swapfile (const char *swapfile,int blocks,int safe) +int make_swapfile (const char *swapfile,unsigned int para,int safe,enum swapfile_method method) {struct statvfs fs_info;unsigned long blk_size, bs;size_t pg_size =sysconf (_SC_PAGESIZE);char mnt_path[100 ]; +unsigned int blocks;if (statvfs ("." , &fs_info) ==-1 )return -1 ; blk_size = fs_info.f_bsize; +if (method ==SWAPFILE_BY_SIZE ) + blocks = para *1024 *1024 / blk_size; +else + blocks = para; +/* To guarantee at least one page can be swapped out */ if (blk_size * blocks < pg_size)bs = pg_size;libs/libltpswap/libswap.c +1
-1@@ -181,7 +187,7 @@ int make_swapfile(const char *swapfile, int blocks, int safe)bool is_swap_supported (const char *filename) {int i, sw_support =0 ; -int ret =make_swapfile (filename,10 ,1 ); +int ret =make_swapfile (filename,10 ,1 ,SWAPFILE_BY_BLOCKS );int fi_contiguous =file_is_contiguous (filename);long fs_type =tst_fs_type (filename);const char *fstype = tst_fs_type_name(fs_type);testcases/kernel/syscalls/swapon/swapon01.c +1
-1@@ -38,7 +38,7 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,10 ,0 ); +MAKE_SWAPFILE_SIZE (SWAP_FILE ,100 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM );testcases/kernel/syscalls/swapon/swapon02.c +2
-2@@ -50,8 +50,8 @@ static void setup(void)is_swap_supported (TEST_FILE );SAFE_TOUCH (NOTSWAP_FILE ,0777 ,NULL ); -make_swapfile (SWAP_FILE ,10 ,0 ); -make_swapfile (USED_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (SWAP_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (USED_FILE ,10 ,0 );if (tst_syscall (__NR_swapon,USED_FILE ,0 ))tst_res (TWARN |TERRNO ,"swapon(alreadyused) failed" );testcases/kernel/syscalls/swapon/swapon03.c +1
-1@@ -49,7 +49,7 @@ static int setup_swap(void)/* Create the swapfile */ snprintf (filename,sizeof (filename),"%s%02d" ,TEST_FILE , j +2 ); -make_swapfile (filename,10 ,0 ); +MAKE_SWAPFILE_BLKS (filename,10 ,0 );/* turn on the swap file */ TST_EXP_PASS_SILENT(swapon(filename, 0));testcases/kernel/syscalls/swapon/swapon03.c +1
-1@@ -62,7 +62,7 @@ static int setup_swap(void)tst_brk (TFAIL ,"Failed to setup swap files" );tst_res (TINFO ,"Successfully created %d swap files" , swapfiles); -make_swapfile (TEST_FILE ,10 ,0 ); +MAKE_SWAPFILE_BLKS (TEST_FILE ,10 ,0 );return 0 ; }Quoted 5 lines
--
Regards,
Li WangSignature · 2 lines
Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
In reply to Li WangQuoted 61 lines · Li Wang
Quoted 50 lines · Petr Vorel
Quoted 22 lines
Quoted 8 lines · Wei Gao
Quoted 6 lines
Quoted 6 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper
size.
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check following patch?
Quoted 6 lines
Quoted 2 lines
Can we rewrite the
make_swapfile()API to support passing MB size for making the swapfile?I guess it would be desirable (but keep also possible to pass that 10 blocks,
therefore maybe use flag to distinguish between MB and blocks?).That's fine but a bit complex for users to distinguish flags.
Or, what about making the function use the flag as static, and export two additional functions with MB and blocks?
enum
swapfile_method{
SWAPFILE_BY_SIZE,
SWAPFILE_BY_BLOCKS
};static int make_swapfile(const char *swapfile, unsigned int para, int
safe, enum swapfile_method method) { // The main logic to achieve the swapfile-making process // ... }Quoted 8 lines
int
make_swapfile_size(const char *swapfile, unsigned int size, int safe){return make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE); }int make_swapfile_blks(const char *swapfile, unsigned int blocks, int
safe) { return make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS); }
Quoted 7 lines
Even simpler to define two macros with one
make_swapfile():#define
MAKE_SWAPFILE_SIZE(swapfile, size, safe)\
make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE)#define
MAKE_SWAPFILE_BLKS(swapfile, blocks, safe)\
make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS)
+1
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] swapon01: swapon01: prevent OOM happening in swap process
In reply to Li WangQuoted 30 lines · Petr Vorel
Quoted 21 lines
Quoted 19 lines · Wei Gao
Quoted 17 lines
Quoted 7 lines
That's because the available swapfile on your SUT is too small, you can adjust it (then retest it) by yourself to find a proper size.
Quoted 6 lines
This is fine as long as the swapfile size is less than 300MB, otherwise we need to set .dev_min_size like what we did for
swapoff01.c.And, on the other side, we can't guarantee the system SwapCached happened every time, it depends on the system's configuration.
100M is good enough for current system, could you help check following patch?
Quoted 6 lines
Quoted 2 lines
Can we rewrite the
make_swapfile()API to support passing MB size for making the swapfile?I guess it would be desirable (but keep also possible to pass that 10 blocks,
therefore maybe use flag to distinguish between MB and blocks?).
Quoted 4 lines
That's fine but a bit complex for users to distinguish flags.
Or, what about making the function use the flag as static, and export two additional functions with MB and blocks?
Yes, I meant something like that (2 wrappers which would pass the flag to the 3rd function which actually implements it.
Quoted 11 lines
enum
swapfile_method{
SWAPFILE_BY_SIZE,
SWAPFILE_BY_BLOCKS
};static int make_swapfile(const char *swapfile, unsigned int para, int safe,
enum swapfile_method method) { // The main logic to achieve the swapfile-making process // ... }
Quoted 8 lines
int
make_swapfile_size(const char *swapfile, unsigned int size, int safe){return make_swapfile(swapfile, size, safe, SWAPFILE_BY_SIZE); }int
make_swapfile_blks(const char *swapfile, unsigned int blocks, int safe){ return make_swapfile(swapfile, blocks, safe, SWAPFILE_BY_BLOCKS); }
+1
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp