This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: What *is* the API for sched_getaffinity? Should sched_getaffinity always succeed when using cpu_set_t?


On 07/19/2013 12:26 AM, Alexander Monakov wrote:
> On 07/18/2013 05:00 PM, KOSAKI Motohiro wrote:
>>> Why application should think the cpus are 8? I mean cpu offlining is typically
>>> not short term.
> [snip]
> On Thu, 18 Jul 2013, Carlos O'Donell wrote:
>> The manual is wrong. 
>>
>> You should use _SC_NPROCESSORS_ONLN.
>>
>> The manual should be fixed.
>>
>> There is no reason to recommend using configured processors to
>> assist in achieving maximum parallelism performance.
> 
> Is that really so?  IIUC, on ARM, Linux kernel can dynamically bring CPUs
> online/offline in response to load as a power saving measure, and for example
> if you run 'top' you'll see the reported number of CPUs fluctuate.
> 
> So using the number of CPUs that are online *right now* does not seem
> appropriate, because on an otherwise idle system a just-started application
> will see just one CPU as online.

That's a good point.

However the application can't tell the difference between offline and
reserved for something else, and offline ready for use. The system
might be partitioned.

The application only knows that _SC_NPROCESSORS_ONLN are online now,
and creating more threads than that might just result in wasted cycles
contended for locks.

Therefore on ARM the Linux kernel can either report the CPU offline
and expect an intelligent application *not* to spin up lots of threads,
or just report those CPUs as online (but in deep sleep, potentially off).

I think that on ARM, with CPUs offline, _SC_NPROCESSORS_ONLN should
still count those CPUs if they are going to be put back online once
load goes up.

Keep in mind that _SC_NPROCESSORS_ONLN means the number of processors
available for scheduling tasks, and a sleeping CPU that will be brought
online when load goes up should IMO count.

Unless someone has a different argument?

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]