I think I would rather do something like below, to make sure we only
modify the cpuset while discovering things.
The code builds fine on FreeBSD9 and seems to work, but my testing of
changing cpuset doesn't seem to work very well so I'd like a bit more
testing.

Brice




Index: src/topology-freebsd.c
===================================================================
--- src/topology-freebsd.c      (révision 4893)
+++ src/topology-freebsd.c      (copie de travail)
@@ -178,14 +178,21 @@
 hwloc_look_freebsd(struct hwloc_topology *topology)
 {
   unsigned nbprocs = hwloc_fallback_nbprocessors(topology);
+  cpusetid_t setid;

 #ifdef HAVE__SC_LARGE_PAGESIZE
   topology->levels[0][0]->attr->machine.huge_page_size_kB = 
sysconf(_SC_LARGE_PAGESIZE);
 #endif

   hwloc_set_freebsd_hooks(topology);
+
+  cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, &setid);
+  cpuset_setid(CPU_WHICH_PID, -1, 0);
+
   hwloc_look_x86(topology, nbprocs);

+  cpuset_setid(CPU_WHICH_PID, -1, setid);
+
   hwloc_setup_pu_level(topology, nbprocs);

 #ifdef HAVE_SYSCTL





Le 11/10/2012 18:39, Sebastian Kuzminsky a écrit :
> This patch (against r4884) fixes the issue on my system.  It moves the
> lstopo process to cpuset 0, which includes all the CPUs in the system.
>
> --- r4884/hwloc-trunk.svn/tests/ports/topology-freebsd.c      
>  2012-10-02 16:13:06.000000000 -0600
> +++ cpuset/hwloc-trunk.svn/tests/ports/topology-freebsd.c      
> 2012-10-11 10:36:18.326408333 -0600
> @@ -197,6 +197,7 @@
>  void
>  hwloc_set_freebsd_hooks(struct hwloc_topology *topology)
>  {
> +  cpuset_setid(CPU_WHICH_PID, -1, 0);
>  #if defined(HAVE_SYS_CPUSET_H) && defined(HAVE_CPUSET_SETAFFINITY)
>    topology->set_thisproc_cpubind = hwloc_freebsd_set_thisproc_cpubind;
>    topology->get_thisproc_cpubind = hwloc_freebsd_get_thisproc_cpubind;
>

Reply via email to