diff --git a/stress-lockf.c b/stress-lockf.c index fb2f7b5f085e..232c269d0ec8 100644 --- a/stress-lockf.c +++ b/stress-lockf.c @@ -43,7 +43,7 @@ #define LOCK_FILE_SIZE (64 * 1024) #define LOCK_SIZE (8) -#define LOCK_MAX (1024) +#define LOCK_MAX (8192) typedef struct lockf_info { off_t offset; diff --git a/stress-ng.c b/stress-ng.c index 7ab2ab1c42a6..de48d2a34738 100644 --- a/stress-ng.c +++ b/stress-ng.c @@ -1642,12 +1642,22 @@ static void kill_procs(const int sig) int j; for (j = 0; j < procs[i].started_procs; j++) { - if (procs[i].pids[j]) - (void)kill(procs[i].pids[j], signum); + if (procs[i].pids[j].pid) + (void)kill(procs[i].pids[j].pid, signum); } } } +static int on_one_sock(unsigned cpu1, unsigned cpu2, unsigned cpus) +{ + unsigned mid = cpus / 2; + if (cpu1 < mid && cpu2 < mid) + return 1; + if (cpu1 >= mid && cpu2 >= mid) + return 1; + return 0; +} + /* * wait_procs() * wait for procs @@ -1670,7 +1680,8 @@ static void MLOCKED wait_procs(bool *success, bool *resource_success) cpu_set_t proc_mask; unsigned long int cpu = 0; const uint32_t ticks_per_sec = stress_get_ticks_per_second() * 5; - const useconds_t usec_sleep = ticks_per_sec ? 1000000 / ticks_per_sec : 1000000 / 250; + //const useconds_t usec_sleep = ticks_per_sec ? 1000000 / ticks_per_sec : 1000000 / 250; + const useconds_t usec_sleep = 50000; while (opt_do_wait) { const int32_t cpus = stress_get_processors_configured(); @@ -1685,7 +1696,9 @@ static void MLOCKED wait_procs(bool *success, bool *resource_success) int j; for (j = 0; j < procs[i].started_procs; j++) { - const pid_t pid = procs[i].pids[j]; + const pid_t pid = procs[i].pids[j].pid; + unsigned last_cpu = + procs[i].pids[j].last_cpu; if (pid) { cpu_set_t mask; int32_t cpu_num; @@ -1694,10 +1707,16 @@ static void MLOCKED wait_procs(bool *success, bool *resource_success) cpu_num = mwc32() % cpus; } while (!(CPU_ISSET(cpu_num, &proc_mask))); + if (on_one_sock(last_cpu, + cpu_num, + cpus)) + cpu_num = cpus - cpu_num -1; + CPU_ZERO(&mask); CPU_SET(cpu_num, &mask); if (sched_setaffinity(pid, sizeof(mask), &mask) < 0) goto do_wait; + procs[i].pids[j].last_cpu = cpu_num; } } } @@ -1713,7 +1732,7 @@ do_wait: for (j = 0; j < procs[i].started_procs; j++) { pid_t pid; redo: - pid = procs[i].pids[j]; + pid = procs[i].pids[j].pid; if (pid) { int status, ret; @@ -1752,7 +1771,7 @@ redo: *success = false; break; } - proc_finished(&procs[i].pids[j]); + proc_finished(&procs[i].pids[j].pid); pr_dbg(stderr, "process [%d] terminated\n", ret); } else if (ret == -1) { /* Somebody interrupted the wait */ @@ -1760,7 +1779,7 @@ redo: goto redo; /* This child did not exist, mark it done anyhow */ if (errno == ECHILD) - proc_finished(&procs[i].pids[j]); + proc_finished(&procs[i].pids[j].pid); } } } @@ -1901,7 +1920,7 @@ again: default: if (pid > -1) { (void)setpgid(pid, pgrp); - procs[i].pids[j] = pid; + procs[i].pids[j].pid = pid; procs[i].started_procs++; } @@ -2952,7 +2971,7 @@ next_opt: /* Sequential mode has no bogo ops threshold */ for (i = 0; i < STRESS_MAX; i++) { procs[i].bogo_ops = 0; - procs[i].pids = calloc(opt_sequential, sizeof(pid_t)); + procs[i].pids = calloc(opt_sequential, sizeof(my_pid_t)); if (!procs[i].pids) { pr_err(stderr, "cannot allocate pid list\n"); free_procs(); @@ -2980,7 +2999,7 @@ next_opt: if (max_procs < procs[i].num_procs) max_procs = procs[i].num_procs; if (procs[i].num_procs) { - procs[i].pids = calloc(procs[i].num_procs, sizeof(pid_t)); + procs[i].pids = calloc(procs[i].num_procs, sizeof(my_pid_t)); if (!procs[i].pids) { pr_err(stderr, "cannot allocate pid list\n"); free_procs(); @@ -3008,7 +3027,7 @@ next_opt: if (max_procs < procs[i].num_procs) max_procs = procs[i].num_procs; if (procs[i].num_procs) { - procs[i].pids = calloc(procs[i].num_procs, sizeof(pid_t)); + procs[i].pids = calloc(procs[i].num_procs, sizeof(my_pid_t)); if (!procs[i].pids) { pr_err(stderr, "cannot allocate pid list\n"); free_procs(); diff --git a/stress-ng.h b/stress-ng.h index c5104a322e45..4f4098fc0d11 100644 --- a/stress-ng.h +++ b/stress-ng.h @@ -1713,7 +1713,12 @@ typedef struct { } stress_t; typedef struct { - pid_t *pids; /* process id */ + pid_t pid; + unsigned last_cpu; +} my_pid_t; + +typedef struct { + my_pid_t *pids; /* process id */ int32_t started_procs; /* count of started processes */ int32_t num_procs; /* number of process per stressor */ uint64_t bogo_ops; /* number of bogo ops */