swapping01.c: Add sleeps in the loop that dirties the memory
PATCH 1/1 swapping01.c: Add sleeps in the loop that dirties the memory
In our test env this case failed sporadically, we suspect swapout speed not fast enough in some situation.
Detail info please check following comments;
https://bugzilla.suse.com/show_bug.cgi?id=1217850#c34
--- testcases/kernel/mem/swapping/swapping01.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
testcases/kernel/mem/swapping/swapping01.c +9 -1
@@ -47,6 +47,7 @@#define COE_DELTA 1/* will try to alloc 1.3 * phy_mem */ #define COE_SLIGHT_OVER 0.3 +#define MEM_SIZE 1024 * 1024static void init_meminfo (void );static void do_alloc (int allow_raise);
@@ -101,6 +102,13 @@ static void init_meminfo(void) swap_free_init, mem_over_max); } +static void memset_blocks (char *ptr,int mem_count,int sleep_time_ms) { +for (int i =0 ; i < mem_count /1024 ; i++) { +memset (ptr + (i *MEM_SIZE ),1 ,MEM_SIZE ); +usleep (sleep_time_ms *1000 ); + } +} +static void do_alloc (int allow_raise) {long mem_count;
@@ -115,7 +123,7 @@ static void do_alloc(int allow_raise)if (allow_raise ==1 )tst_res (TINFO ,"try to allocate: %ld MB" , mem_count /1024 ); s =SAFE_MALLOC (mem_count *1024 ); -memset (s,1 , mem_count *1024 ); +memset_blocks (s, mem_count,10 );if ((allow_raise ==1 ) && (raise (SIGSTOP ) ==-1 )) {tst_res (TINFO ,"memory allocated: %ld MB" , mem_count /1024 );
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
If I'm counting right this is 10ms * 1024 which is 10s, I would be happier with 1ms sleep instead. Or if we did 10ms sleep once every 10 memsets() instead.
Also since this was proposed by Vlastimil in the bugzilla he should ideally give his ack here as well (now in CC).
Quoted 46 lines
Signed-off-by Wei Gao <[email protected]>--- testcases/kernel/mem/swapping/swapping01.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)testcases/kernel/mem/swapping/swapping01.c +9
-1@@ -47,6 +47,7 @@#define COE_DELTA 1/* will try to alloc 1.3 * phy_mem */ #define COE_SLIGHT_OVER 0.3 +#define MEM_SIZE 1024 * 1024static void init_meminfo (void );static void do_alloc (int allow_raise);@@ -101,6 +102,13 @@ static void init_meminfo(void) swap_free_init, mem_over_max); } +static void memset_blocks (char *ptr,int mem_count,int sleep_time_ms) { +for (int i =0 ; i < mem_count /1024 ; i++) { +memset (ptr + (i *MEM_SIZE ),1 ,MEM_SIZE ); +usleep (sleep_time_ms *1000 ); + } +} +static void do_alloc (int allow_raise) {long mem_count;@@ -115,7 +123,7 @@ static void do_alloc(int allow_raise)if (allow_raise ==1 )tst_res (TINFO ,"try to allocate: %ld MB" , mem_count /1024 ); s =SAFE_MALLOC (mem_count *1024 ); -memset (s,1 , mem_count *1024 ); +memset_blocks (s, mem_count,10 );if ((allow_raise ==1 ) && (raise (SIGSTOP ) ==-1 )) {tst_res (TINFO ,"memory allocated: %ld MB" , mem_count /1024 );Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Vlastimil Babka via ltp
Acked-by Vlastimil BabkaQuoted 6 lines · Cyril Hrubis
Hi!
If I'm counting right this is 10ms * 1024 which is 10s, I would be happier with 1ms sleep instead. Or if we did 10ms sleep once every 10
memsets()instead.
Yeah I proposed you can try to reduce the sleep time/frequency to basically to lowest value (with some margin) that resolves the issue reliably in your testing. That 10ms per MB was just a possible starting point.
Quoted 4 lines
Also since this was proposed by Vlastimil in the bugzilla he should ideally give his ack here as well (now in CC).
Quoted 1 line
Signed-off-by Wei Gao <[email protected]>
Quoted 46 lines
Quoted 45 lines
--- testcases/kernel/mem/swapping/swapping01.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)testcases/kernel/mem/swapping/swapping01.c +9
-1@@ -47,6 +47,7 @@#define COE_DELTA 1/* will try to alloc 1.3 * phy_mem */ #define COE_SLIGHT_OVER 0.3 +#define MEM_SIZE 1024 * 1024static void init_meminfo (void );static void do_alloc (int allow_raise);@@ -101,6 +102,13 @@ static void init_meminfo(void) swap_free_init, mem_over_max); } +static void memset_blocks (char *ptr,int mem_count,int sleep_time_ms) { +for (int i =0 ; i < mem_count /1024 ; i++) { +memset (ptr + (i *MEM_SIZE ),1 ,MEM_SIZE ); +usleep (sleep_time_ms *1000 ); + } +} +static void do_alloc (int allow_raise) {long mem_count;@@ -115,7 +123,7 @@ static void do_alloc(int allow_raise)if (allow_raise ==1 )tst_res (TINFO ,"try to allocate: %ld MB" , mem_count /1024 ); s =SAFE_MALLOC (mem_count *1024 ); -memset (s,1 , mem_count *1024 ); +memset_blocks (s, mem_count,10 );if ((allow_raise ==1 ) && (raise (SIGSTOP ) ==-1 )) {tst_res (TINFO ,"memory allocated: %ld MB" , mem_count /1024 );Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 3 lines
Yeah I proposed you can try to reduce the sleep time/frequency to basically to lowest value (with some margin) that resolves the issue reliably in your testing. That 10ms per MB was just a possible starting point.
The usuall practice we do in LTP is to measure the minimal value required for the test to pass and then double that for the final value. But even with that I suppose that the value should be less than 10s.
Wei can you please try to measure how long are the shortest sleeps we need in order to make the test pass?
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 5 lines · Cyril Hrubis
Hi!
Quoted 3 lines
Yeah I proposed you can try to reduce the sleep time/frequency to basically to lowest value (with some margin) that resolves the issue reliably in your testing. That 10ms per MB was just a possible starting point.
Quoted 7 lines
The usuall practice we do in LTP is to measure the minimal value required for the test to pass and then double that for the final value. But even with that I suppose that the value should be less than 10s.
Wei can you please try to measure how long are the shortest sleeps we need in order to make the test pass?
Run 500 times on same build for each measurement.
1) No any sleep, 17 case will failed
https://openqa.suse.de/tests/14111469#next_previous
2) sleep 1ms, no failed case happen
https://openqa.suse.de/tests/14110476#next_previous
3) sleep 0.5ms, 1 failed case happen
https://openqa.suse.de/tests/14110476#next_previous
So currently 1ms is good candidate. I will sent second patch.
Quoted 3 lines
Signature · 2 lines
Cyril Hrubis [email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 swapping01.c: Add sleeps in the loop that dirties the memory
In reply to Wei Gao via ltpIn our test env this case failed sporadically, we suspect swapout speed not fast enough in some situation.
Detail info please check following comments;
https://bugzilla.suse.com/show_bug.cgi?id=1217850#c34
--- testcases/kernel/mem/swapping/swapping01.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
testcases/kernel/mem/swapping/swapping01.c +9 -1
@@ -47,6 +47,7 @@#define COE_DELTA 1/* will try to alloc 1.3 * phy_mem */ #define COE_SLIGHT_OVER 0.3 +#define MEM_SIZE 1024 * 1024static void init_meminfo (void );static void do_alloc (int allow_raise);
@@ -101,6 +102,13 @@ static void init_meminfo(void) swap_free_init, mem_over_max); } +static void memset_blocks (char *ptr,int mem_count,int sleep_time_ms) { +for (int i =0 ; i < mem_count /1024 ; i++) { +memset (ptr + (i *MEM_SIZE ),1 ,MEM_SIZE ); +usleep (sleep_time_ms *1000 ); + } +} +static void do_alloc (int allow_raise) {long mem_count;
@@ -115,7 +123,7 @@ static void do_alloc(int allow_raise)if (allow_raise ==1 )tst_res (TINFO ,"try to allocate: %ld MB" , mem_count /1024 ); s =SAFE_MALLOC (mem_count *1024 ); -memset (s,1 , mem_count *1024 ); +memset_blocks (s, mem_count,1 );if ((allow_raise ==1 ) && (raise (SIGSTOP ) ==-1 )) {tst_res (TINFO ,"memory allocated: %ld MB" , mem_count /1024 );
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 5 lines
In our test env this case failed sporadically, we suspect swapout speed not fast enough in some situation.
Detail info please check following comments;
https://bugzilla.suse.com/show_bug.cgi?id=1217850#c34
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 24 lines
+++
b/testcases/kernel/mem/swapping/swapping01.c(quoted diff) +8
-0@@ -47,6 +47,7 @@ #define COE_DELTA 1 /* will try to alloc 1.3 * phy_mem */ #define COE_SLIGHT_OVER 0.3 +#define MEM_SIZE 1024 * 1024 static void init_meminfo(void); static void do_alloc(int allow_raise);@@ -101,6 +102,13 @@ static void init_meminfo(void) swap_free_init, mem_over_max); } +static void memset_blocks(char *ptr, int mem_count, int sleep_time_ms) { + for (int i = 0; i < mem_count / 1024; i++) { + memset(ptr + (i * MEM_SIZE), 1, MEM_SIZE); + usleep(sleep_time_ms * 1000); + } +} + static void do_alloc(int allow_raise) { long mem_count;
Review static void do_alloc(int allow_raise) · line 126
Quoted 5 lines
(quoted diff) +1
-1@@ -115,7 +123,7 @@ static void do_alloc(int allow_raise) if (allow_raise == 1) tst_res(TINFO, "try to allocate: %ld MB", mem_count / 1024); s = SAFE_MALLOC(mem_count * 1024); - memset(s, 1, mem_count * 1024); + memset_blocks(s, mem_count, 1);
nit: Actually when we have custom function used on single place, we might want to avoid the last parameter 1, right? We could usleep(1000) directly.
We use MEM_SIZE definition outside of the function anyway.
I can change it before merge:
kernel/mem/swapping/swapping01.c +3 -3
@@ -102,10 +102,10 @@ static void init_meminfo(void) swap_free_init, mem_over_max); } -static void memset_blocks (char *ptr,int mem_count,int sleep_time_ms) { +static void memset_blocks (char *ptr,int mem_count) {for (int i =0 ; i < mem_count /1024 ; i++) {memset (ptr + (i *MEM_SIZE ),1 ,MEM_SIZE ); -usleep (sleep_time_ms *1000 ); +usleep (1000 ); } }
@@ -123,7 +123,7 @@ static void do_alloc(int allow_raise)if (allow_raise ==1 )tst_res (TINFO ,"try to allocate: %ld MB" , mem_count /1024 ); s =SAFE_MALLOC (mem_count *1024 ); -memset_blocks (s, mem_count,1 ); +memset_blocks (s, mem_count);if ((allow_raise ==1 ) && (raise (SIGSTOP ) ==-1 )) {tst_res (TINFO ,"memory allocated: %ld MB" , mem_count /1024 );
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei, Cyril,
Quoted 2 lines
Hi!
Reviewed-by Cyril Hrubis <[email protected]>
Thanks, merged the original version.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp