11/*
22 * Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
33 * Copyright (c) 2017 Cisco Systems, Inc. All rights reserved
4+ * Copyright (c) 2017 Inria. All rights reserved.
45 * $COPYRIGHT$
56 *
67 * Additional copyrights may follow
@@ -111,6 +112,22 @@ static int init(void)
111112 if (ORTE_SUCCESS != (rc = find_hole (mca_rtc_hwloc_component .kind ,
112113 & shmemaddr , shmemsize ))) {
113114 /* we couldn't find a hole, so don't use the shmem support */
115+ if (4 < opal_output_get_verbosity (orte_rtc_base_framework .framework_output )) {
116+ FILE * file = fopen ("/proc/self/maps" , "r" );
117+ if (file ) {
118+ char line [256 ];
119+ opal_output (0 , orte_rtc_base_framework .framework_output ,
120+ "%s Dumping /proc/self/maps" , ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ));
121+ while (fgets (line , sizeof (line ), file ) != NULL ) {
122+ char * end = strchr (line , '\n' );
123+ if (end )
124+ * end = '\0' ;
125+ opal_output (0 , orte_rtc_base_framework .framework_output ,
126+ "%s" , line );
127+ }
128+ fclose (file );
129+ }
130+ }
114131 return ORTE_SUCCESS ;
115132 }
116133 /* create the shmem file in our session dir so it
@@ -580,7 +597,10 @@ static int find_hole(orte_rtc_hwloc_vm_hole_kind_t hkind,
580597 return use_hole (0 , begin , addrp , size );
581598
582599 case VM_HOLE_AFTER_HEAP :
583- if (prevmkind == VM_MAP_HEAP ) {
600+ if (prevmkind == VM_MAP_HEAP && mkind != VM_MAP_HEAP ) {
601+ /* only use HEAP when there's no other HEAP after it
602+ * (there can be several of them consecutively).
603+ */
584604 fclose (file );
585605 return use_hole (prevend , begin - prevend , addrp , size );
586606 }
@@ -594,15 +614,18 @@ static int find_hole(orte_rtc_hwloc_vm_hole_kind_t hkind,
594614 break ;
595615
596616 case VM_HOLE_IN_LIBS :
617+ /* see if we are between heap and stack */
597618 if (prevmkind == VM_MAP_HEAP ) {
598619 in_libs = 1 ;
599620 }
600621 if (mkind == VM_MAP_STACK ) {
601622 in_libs = 0 ;
602623 }
603- if (in_libs ) {
624+ if (!in_libs ) {
625+ /* we're not in libs, ignore this entry */
604626 break ;
605627 }
628+ /* we're in libs, consider this entry for searching the biggest hole below */
606629 /* fallthrough */
607630
608631 case VM_HOLE_BIGGEST :
0 commit comments