From 29884cff6352856fee9fffecb4a715efd70e08f5 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Thu, 18 Feb 2021 14:27:29 -0500 Subject: [PATCH] oslat: Fix --cpu-list won't allow to schedule on all possible cores parse_cpumask() is too strict for oslat, in that use_current_cpuset() will filter out all the cores that are not allowed for current process to run. This seems to be unnecessary at least for oslat. For example, the bash process that runs the oslat program may have a sched affinity of 0-2, however it's still legal to have it start a oslat thread running on the cores outside 0-2 as long as the follow up sched_setaffinity() will succeed. numa_parse_cpustring_all() suites exactly for this case, which should already have considered sysconf(_SC_NPROCESSORS_ONLN) limit. Use that instead. Since at it, also remove initialization of cpu_set variable otherwise it's leaked in previous parse_cpumask too: numa_parse_cpustring_all() will return a newly allocated buffer already. Quotting from manual: numa_parse_nodestring() parses a character string list of nodes into a bit mask. The bit mask is allocated by numa_allocate_nodemask(). numa_parse_nodestring_all() is similar to numa_parse_nodestring, but can parse all possible nodes, not only current nodeset. Cc: John Kacur Cc: Daniel Wagner Cc: Clark Williams Reported-by: Pradipta Kumar Sahoo Reported-by: Mike Stowell Signed-off-by: Peter Xu Signed-off-by: John Kacur --- src/oslat/oslat.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c index b2c5373388fb..465a694cdd1d 100644 --- a/src/oslat/oslat.c +++ b/src/oslat/oslat.c @@ -785,7 +785,6 @@ int main(int argc, char *argv[]) struct thread *threads; int i, n_cores; struct bitmask *cpu_set = NULL; - int max_cpus = sysconf(_SC_NPROCESSORS_ONLN); #ifdef FRC_MISSING printf("This architecture is not yet supported. " @@ -797,10 +796,6 @@ int main(int argc, char *argv[]) exit(1); } - cpu_set = numa_allocate_cpumask(); - if (!cpu_set) - fatal("oslat: Could not allocate cpumask\n"); - g.app_name = argv[0]; g.rtprio = 0; g.bucket_size = BUCKET_SIZE; @@ -817,7 +812,8 @@ int main(int argc, char *argv[]) if (!g.cpu_list) g.cpu_list = strdup("all"); - if (parse_cpumask(g.cpu_list, max_cpus, &cpu_set) != 0) + cpu_set = numa_parse_cpustring_all(g.cpu_list); + if (!cpu_set) fatal("oslat: parse_cpumask failed.\n"); n_cores = numa_bitmask_weight(cpu_set); -- 2.26.2