]> git.proxmox.com Git - mirror_ovs.git/commit
lib: Use a more accurate value for CPU count (sched_getaffinity).
authorDavid Marchand <david.marchand@6wind.com>
Thu, 9 Jun 2016 09:52:49 +0000 (11:52 +0200)
committerBen Pfaff <blp@ovn.org>
Fri, 1 Jul 2016 21:48:40 +0000 (14:48 -0700)
commitbe15ec48d7669902f7f7ca2f76fda190b0ccfa5a
treeb35c997d29f66119094db8964d1fc5a6ada69aba
parent58e1f97be2e01dbddee6e7987472c2134d61b419
lib: Use a more accurate value for CPU count (sched_getaffinity).

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.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Co-authored-by: Liu Xiaofeng <xiaofeng.liu@6wind.com>
Signed-off-by: Liu Xiaofeng <xiaofeng.liu@6wind.com>
Co-authored-by: Quentin Monnet <quentin.monnet@6wind.com>
Signed-off-by: Quentin Monnet <quentin.monnet@6wind.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/ovs-thread.c