Re: export numa_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 12, 2013 at 12:31:18PM +0200, Daniel Kozak wrote:
> Hello,
> 
> when I compile latest libnuma.so, the numa_init symbol is not exported.
> So it is not possible to linked against this lib with code which called
> numa_init directly from code. One of affected program is HipHop Virtual
> Machine (HHVM)
> https://github.com/facebook/hiphop-php/blob/master/hphp/util/alloc.cpp#L135
> 
> So it is possible to add numa_init into global section in
> versions.ldscript?

Ah makes sense:

 // numa_init is called automatically, but is probably called after
 // JEMallocInitializer(). its idempotent, so call it here.
     numa_init();

When libnuma code is called from a constructor then the function
may need to be called explicitely to avoid ordering problems.

So yes exporting this is ok I guess.

This is also interesting. I'm surprised this doesn't work
(maybe for an old version?)

/*
   * libnuma is only partially aware of taskset. If on entry,
   * you have completely disabled a node via taskset, the node
   * will not be available, and calling numa_run_on_node will
   * not work for that node. But if only some of the cpu's on a
   * node were disabled, then calling numa_run_on_node will enable
   * them all. To prevent this, compute the actual masks up front
   */
  bitmask* enabled = numa_allocate_cpumask();
  if (numa_sched_getaffinity(0, enabled) < 0) {
    return;
  }
  node_to_cpu_mask = new std::vector<bitmask*>;
  int num_cpus = numa_num_configured_cpus();
  int max_node = numa_max_node();
  for (int i = 0; i <= max_node; i++) {
    bitmask* cpus_for_node = numa_allocate_cpumask();
    numa_node_to_cpus(i, cpus_for_node);
    for (int j = 0; j < num_cpus; j++) {
      if (!numa_bitmask_isbitset(enabled, j)) {
        numa_bitmask_clearbit(cpus_for_node, j);
      }
    }
    assert(node_to_cpu_mask->size() == i);
    node_to_cpu_mask->push_back(cpus_for_node);
  }
  numa_bitmask_free(enabled);




-andi
--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux