Skip to content

Commit a4e63f2

Browse files
committed
freebsd: make sure uname and Backend info attrs are added once
Once and only once when some discovery phases may be disabled. Signed-off-by: Brice Goglin <[email protected]>
1 parent 75e01ef commit a4e63f2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

hwloc/topology-freebsd.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#include "private/private.h"
3737
#include "private/debug.h"
3838

39+
struct hwloc_freebsd_backend_data_s {
40+
int need_global_infos;
41+
};
42+
3943
#if defined(HAVE_SYS_CPUSET_H) && defined(HAVE_CPUSET_SETAFFINITY)
4044
static void
4145
hwloc_freebsd_bsd2hwloc(hwloc_bitmap_t hwloc_cpuset, const cpuset_t *cset)
@@ -525,6 +529,7 @@ hwloc_look_freebsd(struct hwloc_backend *backend, struct hwloc_disc_status *dsta
525529
* we may still force use this backend when debugging with !thissystem.
526530
*/
527531
struct hwloc_topology *topology = backend->topology;
532+
struct hwloc_freebsd_backend_data_s *data = HWLOC_BACKEND_PRIVATE_DATA(backend);
528533

529534
if (dstatus->phase == HWLOC_DISC_PHASE_CPU) {
530535
if (!topology->levels[0][0]->cpuset) {
@@ -545,8 +550,12 @@ hwloc_look_freebsd(struct hwloc_backend *backend, struct hwloc_disc_status *dsta
545550
memsize = hwloc_fallback_memsize();
546551
if (memsize > 0)
547552
topology->machine_memory.local_memory = memsize;
548-
hwloc_obj_add_info(topology->levels[0][0], "Backend", "FreeBSD");
549-
hwloc_add_uname_info(topology, NULL);
553+
}
554+
555+
if (data->need_global_infos) {
556+
hwloc_obj_add_info(topology->levels[0][0], "Backend", "FreeBSD");
557+
hwloc_add_uname_info(topology, NULL);
558+
data->need_global_infos = 0;
550559
}
551560
return 0;
552561
}
@@ -595,9 +604,15 @@ hwloc_freebsd_component_instantiate(struct hwloc_topology *topology,
595604
const void *_data3 __hwloc_attribute_unused)
596605
{
597606
struct hwloc_backend *backend;
598-
backend = hwloc_backend_alloc(topology, component, 0);
607+
struct hwloc_freebsd_backend_data_s *data;
608+
609+
backend = hwloc_backend_alloc(topology, component, sizeof(struct hwloc_freebsd_backend_data_s));
599610
if (!backend)
600611
return NULL;
612+
613+
data = HWLOC_BACKEND_PRIVATE_DATA(backend);
614+
data->need_global_infos = 1;
615+
601616
backend->discover = hwloc_look_freebsd;
602617
return backend;
603618
}

0 commit comments

Comments
 (0)