Skip to content

Commit 4df55bd

Browse files
committed
scftorture: Consolidate scftorture_invoke_one() scf_check initialization
This commit hoists much of the initialization of the scf_check structure out of the switch statement, thus saving a few lines of code. The initialization of the ->scfc_in field remains in each leg of the switch statement in order to more heavily stress memory ordering. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 676e546 commit 4df55bd

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

kernel/scftorture.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,13 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
299299
preempt_disable();
300300
if (scfsp->scfs_prim == SCF_PRIM_SINGLE || scfsp->scfs_wait) {
301301
scfcp = kmalloc(sizeof(*scfcp), GFP_ATOMIC);
302-
if (WARN_ON_ONCE(!scfcp))
302+
if (WARN_ON_ONCE(!scfcp)) {
303303
atomic_inc(&n_alloc_errs);
304+
} else {
305+
scfcp->scfc_cpu = -1;
306+
scfcp->scfc_wait = scfsp->scfs_wait;
307+
scfcp->scfc_out = false;
308+
}
304309
}
305310
switch (scfsp->scfs_prim) {
306311
case SCF_PRIM_SINGLE:
@@ -311,8 +316,6 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
311316
scfp->n_single++;
312317
if (scfcp) {
313318
scfcp->scfc_cpu = cpu;
314-
scfcp->scfc_wait = scfsp->scfs_wait;
315-
scfcp->scfc_out = false;
316319
scfcp->scfc_in = true;
317320
}
318321
ret = smp_call_function_single(cpu, scf_handler_1, (void *)scfcp, scfsp->scfs_wait);
@@ -330,25 +333,17 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
330333
scfp->n_many_wait++;
331334
else
332335
scfp->n_many++;
333-
if (scfcp) {
334-
scfcp->scfc_cpu = -1;
335-
scfcp->scfc_wait = true;
336-
scfcp->scfc_out = false;
336+
if (scfcp)
337337
scfcp->scfc_in = true;
338-
}
339338
smp_call_function_many(cpu_online_mask, scf_handler, scfcp, scfsp->scfs_wait);
340339
break;
341340
case SCF_PRIM_ALL:
342341
if (scfsp->scfs_wait)
343342
scfp->n_all_wait++;
344343
else
345344
scfp->n_all++;
346-
if (scfcp) {
347-
scfcp->scfc_cpu = -1;
348-
scfcp->scfc_wait = true;
349-
scfcp->scfc_out = false;
345+
if (scfcp)
350346
scfcp->scfc_in = true;
351-
}
352347
smp_call_function(scf_handler, scfcp, scfsp->scfs_wait);
353348
break;
354349
}

0 commit comments

Comments
 (0)