From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andi Kleen Subject: Re: export numa_init Date: Sun, 13 Oct 2013 03:12:58 +0200 Message-ID: <20131013011257.GB2592@two.firstfloor.org> References: <1381573878.2421.6.camel@localhost.localdomain> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <1381573878.2421.6.camel@localhost.localdomain> Sender: linux-numa-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Daniel Kozak Cc: linux-numa@vger.kernel.org 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; 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