Re: [PATCH] oslat: Fix --cpu-list won't allow to schedule on all possible cores

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 18 Feb 2021, Peter Xu wrote:

> 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 <jkacur@xxxxxxxxxx>
> Cc: Daniel Wagner <dwagner@xxxxxxx>
> Cc: Clark Williams <williams@xxxxxxxxxx>
> Reported-by: Pradipta Kumar Sahoo <psahoo@xxxxxxxxxx>
> Reported-by: Mike Stowell <mstowell@xxxxxxxxxx>
> Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
> ---
>  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 b2c5373..465a694 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
> 
> 

Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>



[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux