<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 25, 2020 at 7:56 PM Martin Doucha <<a href="mailto:mdoucha@suse.cz">mdoucha@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 25. 11. 20 12:22, Richard Palethorpe wrote:<br>
> Hello Li,<br>
> <br>
> Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>> writes:<br>
> <br>
>> It makes no sense to run parallel thread to simulate race conditions on<br>
>> system with CPU number less than two, especially for kvm guest, it does<br>
>> not have any chance to get real parallel running and probably encounter<br>
>> failure as below:<br>
> <br>
> Most of the tests using FuzzySync do not need true parallism. We were<br>
> able to reproduce a number of race conditions on a single vCPU. Infact<br>
> it may actually benefit some races because one thread has to pause to<br>
> allow the other to run, perhaps creating a huge race window.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> <br>
>><br>
>> === 100% reproducible on a 1cpu guest ===<br>
>><br>
>> cmdline="af_alg07"<br>
>> contacts=""<br>
>> analysis=exit<br>
>> <<<test_output>>><br>
>> tst_test.c:1248: TINFO: Timeout per run is 0h 05m 00s<br>
>> ../../../include/tst_fuzzy_sync.h:507: TINFO: Minimum sampling period ended<br>
>> ../../../include/tst_fuzzy_sync.h:330: TINFO: loop = 1024, delay_bias = 0<br>
>> ../../../include/tst_fuzzy_sync.h:318: TINFO: start_a - start_b: { avg = -137522ns, avg_dev = 854248ns, dev_ratio = 6.21 }<br>
>> ../../../include/tst_fuzzy_sync.h:318: TINFO: end_a - start_a  : { avg =  1915ns, avg_dev =   535ns, dev_ratio = 0.28 }<br>
>> ../../../include/tst_fuzzy_sync.h:318: TINFO: end_b - start_b  : { avg =  1885ns, avg_dev =    42ns, dev_ratio = 0.02 }<br>
>> ../../../include/tst_fuzzy_sync.h:318: TINFO: end_a - end_b    : { avg = -137492ns, avg_dev = 854818ns, dev_ratio = 6.22 }<br>
>> ../../../include/tst_fuzzy_sync.h:318: TINFO: spins            : { avg = 554786  , avg_dev =  7355  , dev_ratio = 0.01 }<br>
>> ../../../include/tst_fuzzy_sync.h:636: TINFO: Exceeded execution time, requesting exit<br>
>> af_alg07.c:96: TFAIL: fchownat() failed to fail, kernel may be vulnerable<br>
>><br>
>> Signed-off-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>><br>
>> CC: Richard Palethorpe <<a href="mailto:rpalethorpe@suse.de" target="_blank">rpalethorpe@suse.de</a>><br>
>> ---<br>
>>  include/tst_fuzzy_sync.h | 3 +++<br>
>>  1 file changed, 3 insertions(+)<br>
>><br>
>> diff --git a/include/tst_fuzzy_sync.h b/include/tst_fuzzy_sync.h<br>
>> index 4141f5c64..2e864b312 100644<br>
>> --- a/include/tst_fuzzy_sync.h<br>
>> +++ b/include/tst_fuzzy_sync.h<br>
>> @@ -281,6 +281,9 @@ static void tst_init_stat(struct tst_fzsync_stat *s)<br>
>>  static void tst_fzsync_pair_reset(struct tst_fzsync_pair *pair,<br>
>>                                void *(*run_b)(void *))<br>
>>  {<br>
>> +    if (get_nprocs() < 2)<br>
>> +            tst_brk(TCONF, "Fuzzy Sync requires at least two CPUs available");<br>
>> +<br>
>>      tst_fzsync_pair_cleanup(pair);<br>
>>  <br>
>>      tst_init_stat(&pair->diff_ss);<br>
> <br>
> Perhaps this test would pass with more loops and a big enough delay<br>
> range, but this is also wasting time on a single vCPU. I'm not sure<br>
> whether we should filter this test at the LTP level; it may trigger the<br>
> bug on some single CPU configs.<br>
<br>
No, af_alg07 requires 2 CPUs, otherwise it'll report false positives.<br>
The test will pass only if fchownat() hits a half-closed socket and<br>
returns error. But IIRC the half-closed socket will be destroyed during<br>
reschedule which means there's no race window to hit anymore. But it<br>
would be better to put the TCONF condition into the test itself.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">+1</div><div class="gmail_default" style="font-size:small">Correct, I stand by Martin's point. </div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">And we can avoid adding this patch to FuzzySync lib, but for af_alg07 2cpus is required.</div><div class="gmail_default" style="font-size:small">(maybe go with Cyril's suggest to add .min_cpus)</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>