Skip to content

Commit ed4593e

Browse files
committed
stress-schedmix: add another way to waste cycles, perform multiple affinity setting
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
1 parent 2f880a3 commit ed4593e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

stress-schedmix.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ static void stress_schedmix_setaffinity(const pid_t pid, const int cpu)
100100
#endif
101101
}
102102

103-
static inline void stress_schedmix_waste_time(stress_args_t *args)
103+
static inline void stress_schedmix_waste_time(
104+
stress_args_t *args,
105+
const uint32_t n_cpus,
106+
const uint32_t *cpus)
104107
{
105108
int i, n, status;
106109
pid_t pid;
@@ -129,7 +132,7 @@ static inline void stress_schedmix_waste_time(stress_args_t *args)
129132
sigset_t sigmask;
130133
#endif
131134
redo:
132-
n = stress_mwc8modn(27);
135+
n = stress_mwc8modn(28);
133136
switch (n) {
134137
case 0:
135138
(void)shim_sched_yield();
@@ -308,6 +311,18 @@ static inline void stress_schedmix_waste_time(stress_args_t *args)
308311
}
309312
break;
310313
#endif
314+
case 27:
315+
if (cpus) {
316+
const pid_t pid = getpid();
317+
318+
n = stress_mwc8modn(32);
319+
for (i = 0; LIKELY(stress_continue(args) && (i < n)); i++) {
320+
const uint32_t idx = stress_mwc32modn(n_cpus);
321+
322+
stress_schedmix_setaffinity(pid, cpus[idx]);
323+
}
324+
}
325+
break;
311326
default:
312327
goto redo;
313328
}
@@ -516,7 +531,7 @@ static int stress_schedmix_child(
516531

517532
stress_schedmix_setaffinity(child_pid, cpus[idx]);
518533
}
519-
stress_schedmix_waste_time(args);
534+
stress_schedmix_waste_time(args, n_cpus, cpus);
520535
stress_bogo_inc(args);
521536
} while (stress_continue(args));
522537

0 commit comments

Comments
 (0)