linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Sandipan Das <sandipan@linux.ibm.com>
To: Srikar Dronamraju <srikar@linux.vnet.ibm.com>, mpe@ellerman.id.au
Cc: shiganta@in.ibm.com, nasastry@in.ibm.com, harish@linux.ibm.com,
	linuxppc-dev@lists.ozlabs.org, kamalesh@linux.vnet.ibm.com
Subject: Re: [PATCH v2] selftests: powerpc: Fix online CPU selection
Date: Thu, 30 Jul 2020 10:29:08 +0530	[thread overview]
Message-ID: <44073a8e-96d9-6fd0-44d5-554526927226@linux.ibm.com> (raw)
In-Reply-To: <20200729160344.GB14603@linux.vnet.ibm.com>

Hi Srikar, Michael,

On 29/07/20 9:33 pm, Srikar Dronamraju wrote:
> * Sandipan Das <sandipan@linux.ibm.com> [2020-06-09 13:07:33]:
> 
>> The size of the CPU affinity mask must be large enough for
>> systems with a very large number of CPUs. Otherwise, tests
>> which try to determine the first online CPU by calling
>> sched_getaffinity() will fail. This makes sure that the size
>> of the allocated affinity mask is dependent on the number of
>> CPUs as reported by get_nprocs().
>>
>> Fixes: 3752e453f6ba ("selftests/powerpc: Add tests of PMU EBBs")
>> Reported-by: Shirisha Ganta <shiganta@in.ibm.com>
>> Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
>> Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
>> ---
>> Previous versions can be found at:
>> v1: https://lore.kernel.org/linuxppc-dev/20200608144212.985144-1-sandipan@linux.ibm.com/
>>
>> @@ -88,28 +89,40 @@ void *get_auxv_entry(int type)
>>
>>  int pick_online_cpu(void)
>>  {
>> -	cpu_set_t mask;
>> -	int cpu;
>> +	int ncpus, cpu = -1;
>> +	cpu_set_t *mask;
>> +	size_t size;
>> +
>> +	ncpus = get_nprocs();
> 
> Please use get_nprocs_conf or sysconf(_SC_NPROCESSORS_CONF). The manpage
> seems to suggest the latter. Not sure how accurate the manpage is.
> 
> get_nprocs is returning online cpus and when smt is off, the cpu numbers
> would be sparse and hence the result from get_nprocs wouldn't be ideal for
> allocating cpumask. However get_nprocs_conf would return the max configured
> cpus and would be able to handle it. 
> 
> I think this was the same situation hit by Michael Ellerman.
> 

Yes, that seems to be the case. Thanks for testing this.
Will fix this in v3.

- Sandipan

      reply	other threads:[~2020-07-30  5:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09  7:37 [PATCH v2] selftests: powerpc: Fix online CPU selection Sandipan Das
2020-07-29 13:47 ` Michael Ellerman
2020-07-29 16:03 ` Srikar Dronamraju
2020-07-30  4:59   ` Sandipan Das [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44073a8e-96d9-6fd0-44d5-554526927226@linux.ibm.com \
    --to=sandipan@linux.ibm.com \
    --cc=harish@linux.ibm.com \
    --cc=kamalesh@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=nasastry@in.ibm.com \
    --cc=shiganta@in.ibm.com \
    --cc=srikar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).