Hello, kevin.buck...@ecs.vuw.ac.nz, le Thu 26 Aug 2010 18:37:31 +1200, a écrit : > Firstly, I should say I am not a NetBSD developer at this (or any) > level however, I can usually find my way around a system's internals > by judicious use of the man3 content and can type code.
Then it's all good, I'm not a {aix,darwin,freebsd,hpux,osf,solaris,windows} developer either :) > Jeff Squyres suggested we, ECS VUW, try and come up with a > > src/topology-netbsd.c Yay! You're welcome! > I think I have found most of the system calls needed to duplicate > the functionality of say, topology-freebsd.c in NetBSD-land, That's probably a good start, yes, as netbsd seems to be lacking numa and socket/cache information in its kernel. > As thing stand, the procedures still have their FreeBSD names but > as you only compile one of the sources that's not an issue for now. Suffice to s/freebsd/netbsd/ anyway. > What NetBSD does not seem to have is the CPU_SETSIZE seen in something > like: > > hwloc_freebsd_bsd2hwloc(hwloc_cpuset_t hwloc_cpuset, const cpuset_t *cpuset) > { > unsigned cpu; > hwloc_cpuset_zero(hwloc_cpuset); > for (cpu = 0; cpu < HWLOC_NBMAXCPUS && cpu < CPU_SETSIZE; cpu++) > if (CPU_ISSET(cpu, cpuset)) > hwloc_cpuset_set(hwloc_cpuset, cpu); > } > > NetBSD does have this macro (rather hidden away as it turned out, in: > common/lib/libc/sys/cpuset.c ) > > #ifndef __lint__ > #define CPUSET_SIZE() sizeof( \ > struct { \ > uint32_t bits[cpuset_nentries]; \ > }) > #else > #define CPUSET_SIZE() 0 > #endif > > > but my code I don't, currently, have access to anything called > "cpuset_nentries". > > It also seems as though it only gets used after actually creating > a cpuset. > > _cpuset_create(void) > { > if (cpuset_size == 0) { > static int mib[2] = { CTL_HW, HW_NCPU }; > size_t len; > u_int nc; > > if (sysctl(mib, __arraycount(mib), &nc, &len, NULL, 0) == -1) > return NULL; > > cpuset_nentries = CPUSET_NENTRIES(nc); > cpuset_size = CPUSET_SIZE(); > } > return calloc(1, cpuset_size); > } > > > where we have: > > #define CPUSET_SHIFT 5 > #define CPUSET_NENTRIES(nc) ((nc) > 32 ? ((nc) >> CPUSET_SHIFT) : 1) > > > So, before I go pester the people who speak NetBSD-cpusets, my > question is, what is the hwloc CPU_SETSIZE actually representing? It is used to iterate over the cpus of the bsd cpuset. From what I see in netbsd's sys/sched.h, there is a cpuset_size() function which you should be able to use there. > Is it apparant to anyone on here, that what I might be able to get > from the above > > create a cpuset just to get a value for cpuset_nentries so as to be > able to define CPUSET_SIZE/CPUSET_SIZE() In the case of the function above (bsd2hwloc), you _already_ have a cpuset, and can just use cpuset_size(). In the case of hwloc2bsd, you will need to create it before calling cpuset_size() indeed. Samuel