[procps] Re: top: NUMA node CPU utilization support

  • From: Jim Warner <james.warner@xxxxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Thu, 25 Apr 2013 04:40:36 -0500

On Apr 25, 2013, at 4:27 AM, Craig Small <csmall-procps@xxxxxxxxxx> wrote:
> I was thinking of that idea myself, I'm not sure how "robust" it is.
> I actually have a project (gjay) that uses this sort of thing using 
> dlopen() and dlsym(). I've never had problems with it but it is fiddly
> as all your functions turn into pointers and its not pretty like how
> python does it (python doesn't care).


Hi Craig,

I've just about have it ready to go and it's no big deal since the top program 
only needs 2 functions from libnuma.so.

I've shown the essential elements below.

Say, when are you gonna' push my last 2 patches?  You indicated they were 
committed locally.

Regards,
Jim


global stuff --------------------------------------------
        /* Support for NUMA Node display, node expansion/targeting and
           run-time dynamic linking with libnuma.so treated as a plugin */
static int Numa_node_tot;
static int Numa_node_sel = -1;
static void *Libnuma_handle;
#ifndef NUMA_DISABLE
#ifdef PRETEND_NUMA
static int Numa_max_node(void) { return 2; }
static int Numa_node_of_cpu(int num) { return (num % 3); }
#else
static int (*Numa_max_node)(void);
static int (*Numa_node_of_cpu)(int num);
#endif
#endif

. . .

from the before() function ------------------------------
#ifndef NUMA_DISABLE
#ifdef PRETEND_NUMA
   Numa_node_tot = Numa_max_node() + 1;
#else
   Libnuma_handle = dlopen("libnuma.so", RTLD_LAZY);
   if (Libnuma_handle) {
      Numa_max_node = dlsym(Libnuma_handle, "numa_max_node");
      Numa_node_of_cpu = dlsym(Libnuma_handle, "numa_node_of_cpu");
      if (Numa_max_node && Numa_node_of_cpu)
         Numa_node_tot = Numa_max_node() + 1;
      else {
         dlclose(Libnuma_handle);
         Libnuma_handle = NULL;
      }
   }
#endif
#endif



Other related posts: