36
36
#include "private/private.h"
37
37
#include "private/debug.h"
38
38
39
+ struct hwloc_freebsd_backend_data_s {
40
+ int need_global_infos ;
41
+ };
42
+
39
43
#if defined(HAVE_SYS_CPUSET_H ) && defined(HAVE_CPUSET_SETAFFINITY )
40
44
static void
41
45
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
525
529
* we may still force use this backend when debugging with !thissystem.
526
530
*/
527
531
struct hwloc_topology * topology = backend -> topology ;
532
+ struct hwloc_freebsd_backend_data_s * data = HWLOC_BACKEND_PRIVATE_DATA (backend );
528
533
529
534
if (dstatus -> phase == HWLOC_DISC_PHASE_CPU ) {
530
535
if (!topology -> levels [0 ][0 ]-> cpuset ) {
@@ -545,8 +550,12 @@ hwloc_look_freebsd(struct hwloc_backend *backend, struct hwloc_disc_status *dsta
545
550
memsize = hwloc_fallback_memsize ();
546
551
if (memsize > 0 )
547
552
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 ;
550
559
}
551
560
return 0 ;
552
561
}
@@ -595,9 +604,15 @@ hwloc_freebsd_component_instantiate(struct hwloc_topology *topology,
595
604
const void * _data3 __hwloc_attribute_unused )
596
605
{
597
606
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 ));
599
610
if (!backend )
600
611
return NULL ;
612
+
613
+ data = HWLOC_BACKEND_PRIVATE_DATA (backend );
614
+ data -> need_global_infos = 1 ;
615
+
601
616
backend -> discover = hwloc_look_freebsd ;
602
617
return backend ;
603
618
}
0 commit comments