diff options
author | Nathan Zimmer <nzimmer@sgi.com> | 2013-04-15 09:53:36 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-08-01 12:13:26 -0600 |
commit | 0a915aabe88ff98786a88f30d2e062ef34d0826c (patch) | |
tree | 3faf4a0009fa90d7eb54de825c62791111f5cf26 /blktrace.c | |
parent | 67313d8f411fe08f3f8a0c94ad2cf45bf569f0f8 (diff) | |
download | blktrace-0a915aabe88ff98786a88f30d2e062ef34d0826c.tar.gz blktrace-0a915aabe88ff98786a88f30d2e062ef34d0826c.tar.bz2 |
blktrace blkreplay: convert to use a dynamic cpu_set_t
Some distros have changed CPU_SETSIZE in glibc to 4096 since that matches
the NR_CPUS in the linux kernel config file. Some distros have decided to
leave CPU_SETSIZE at 1024. This is a problem if you want to run that distro
on a very large machine.
CPU_SETSIZE is use by the struct cpu_set_t. This means you to deal with cpus
greater the 1024 you must use the dynamic cpu sets, which involves converting
from things like CPU_SET to CPU_SET_S.
Cc: Jens Axboe <axboe@kernel.dk>
Modified by Jens to fix the CPU_{SET,ZERO}_S pointer mixup.
Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'blktrace.c')
-rw-r--r-- | blktrace.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -621,13 +621,19 @@ static void dpp_free(struct devpath *dpp) static int lock_on_cpu(int cpu) { - cpu_set_t cpu_mask; - - CPU_ZERO(&cpu_mask); - CPU_SET(cpu, &cpu_mask); - if (sched_setaffinity(0, sizeof(cpu_mask), &cpu_mask) < 0) + cpu_set_t * cpu_mask; + size_t size; + cpu_mask = CPU_ALLOC(ncpus); + size = CPU_ALLOC_SIZE(ncpus); + + CPU_ZERO_S(size, cpu_mask); + CPU_SET_S(cpu, size, cpu_mask); + if (sched_setaffinity(0, size, cpu_mask) < 0) { + CPU_FREE(cpu_mask); return errno; + } + CPU_FREE(cpu_mask); return 0; } |