forked from luck/tmp_suning_uos_patched
scftorture: Prevent compiler from reducing race probabilities
Detecting smp_call_function() memory misordering requires close timing, so it is necessary to have the checks immediately before and after the call to the smp_call_function*() function under test. This commit therefore inserts barrier() calls to prevent the compiler from optimizing memory-misordering detection down into the zone of extreme improbability. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
parent
dbf83b655a
commit
ee7035d295
|
@ -322,6 +322,7 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
|
||||||
scfp->n_single++;
|
scfp->n_single++;
|
||||||
if (scfcp) {
|
if (scfcp) {
|
||||||
scfcp->scfc_cpu = cpu;
|
scfcp->scfc_cpu = cpu;
|
||||||
|
barrier(); // Prevent race-reduction compiler optimizations.
|
||||||
scfcp->scfc_in = true;
|
scfcp->scfc_in = true;
|
||||||
}
|
}
|
||||||
ret = smp_call_function_single(cpu, scf_handler_1, (void *)scfcp, scfsp->scfs_wait);
|
ret = smp_call_function_single(cpu, scf_handler_1, (void *)scfcp, scfsp->scfs_wait);
|
||||||
|
@ -339,8 +340,10 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
|
||||||
scfp->n_many_wait++;
|
scfp->n_many_wait++;
|
||||||
else
|
else
|
||||||
scfp->n_many++;
|
scfp->n_many++;
|
||||||
if (scfcp)
|
if (scfcp) {
|
||||||
|
barrier(); // Prevent race-reduction compiler optimizations.
|
||||||
scfcp->scfc_in = true;
|
scfcp->scfc_in = true;
|
||||||
|
}
|
||||||
smp_call_function_many(cpu_online_mask, scf_handler, scfcp, scfsp->scfs_wait);
|
smp_call_function_many(cpu_online_mask, scf_handler, scfcp, scfsp->scfs_wait);
|
||||||
break;
|
break;
|
||||||
case SCF_PRIM_ALL:
|
case SCF_PRIM_ALL:
|
||||||
|
@ -348,8 +351,10 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
|
||||||
scfp->n_all_wait++;
|
scfp->n_all_wait++;
|
||||||
else
|
else
|
||||||
scfp->n_all++;
|
scfp->n_all++;
|
||||||
if (scfcp)
|
if (scfcp) {
|
||||||
|
barrier(); // Prevent race-reduction compiler optimizations.
|
||||||
scfcp->scfc_in = true;
|
scfcp->scfc_in = true;
|
||||||
|
}
|
||||||
smp_call_function(scf_handler, scfcp, scfsp->scfs_wait);
|
smp_call_function(scf_handler, scfcp, scfsp->scfs_wait);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -358,6 +363,7 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
|
||||||
atomic_inc(&n_mb_out_errs); // Leak rather than trash!
|
atomic_inc(&n_mb_out_errs); // Leak rather than trash!
|
||||||
else
|
else
|
||||||
kfree(scfcp);
|
kfree(scfcp);
|
||||||
|
barrier(); // Prevent race-reduction compiler optimizations.
|
||||||
}
|
}
|
||||||
if (use_cpus_read_lock)
|
if (use_cpus_read_lock)
|
||||||
cpus_read_unlock();
|
cpus_read_unlock();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user