[ovs-dev] [PATCH v4] lib: Use a more accurate value for CPU count (sched_getaffinity).

Ryan Moats rmoats at us.ibm.com
Thu Jun 9 13:04:01 UTC 2016



Quentin Monnet <quentin.monnet at 6wind.com> wrote on 06/09/2016 04:52:49 AM:

> From: Quentin Monnet <quentin.monnet at 6wind.com>
> To: Ben Pfaff <blp at ovn.org>
> Cc: David Marchand <david.marchand at 6wind.com>, Ryan Moats/Omaha/
> IBM at IBMUS, ovs-dev <dev at openvswitch.org>
> Date: 06/09/2016 04:53 AM
> Subject: [PATCH v4] lib: Use a more accurate value for CPU count
> (sched_getaffinity).
>
> From: David Marchand <david.marchand at 6wind.com>
>
> Relying on /proc/cpuinfo to count the number of available cores is not
> the best option:
>
> - The code is x86-specific.
> - If the process is started with a different CPU affinity, then it will
>   wrongly try to start too many threads (for an example, imagine an OVS
>   daemon restricted to 4 CPU threads on a 128 threads system).
>
> This commit removes /proc/cpuinfo parsing. For Linux systems, it
> introduces instead a call to sched_getaffinity(), which is
> architecture-independant, in order to retrieve the list of CPU threads
> available to the current process and to count them. Other UNIX-like
> systems only use _SC_NPROCESSORS_ONLN.

After double checking, I'm not *entirely* sure that's true, but it can
be updated in a follow-on patch

>
> Signed-off-by: David Marchand <david.marchand at 6wind.com>
> Signed-off-by: Liu Xiaofeng <xiaofeng.liu at 6wind.com>
> Signed-off-by: Quentin Monnet <quentin.monnet at 6wind.com>

I acked the first one, so "in for a penny, in for a pound"...

Acked-by: Ryan Moats <rmoats at us.ibm.com>



More information about the dev mailing list