From acd4483c640ffdff4f476824541977f4a357b275 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Fri, 19 Nov 2021 10:29:23 -0500 Subject: [PATCH] Fix rhbz2007882, rhbz2007883, and rhbz2007877 --- papi-init_thread.patch | 106 +++++++++++++++++++++++++++++++++++++++++ papi.spec | 7 ++- 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 papi-init_thread.patch diff --git a/papi-init_thread.patch b/papi-init_thread.patch new file mode 100644 index 0000000..cc2fd7a --- /dev/null +++ b/papi-init_thread.patch @@ -0,0 +1,106 @@ +commit 3625bdbad9fd57d1cdb1e5615854545167d4adcb +Author: Anthony Castaldo +Date: Wed Aug 26 17:18:29 2020 -0400 + + This modifies PAPI_library_init() to initialize components in two classes, + separated by the initialization of the papi thread structure. The first class + is those that need no thread structure, currently everything but perf_event and + perf_event_uncore. Following the init of the threading structure, we init the + second class (perf_event and perf_event_uncore) that DOES need the thread + structure to successfully init_component(). This required a change to + _papi_hwi_init_global(), to add an argument to distinguish which class it + should initialize. + +diff --git a/src/papi.c b/src/papi.c +index 33cc29935..ed75af493 100644 +--- a/src/papi.c ++++ b/src/papi.c +@@ -1151,7 +1151,23 @@ PAPI_library_init( int version ) + papi_return( init_retval ); + } + +- /* Initialize thread globals, including the main threads */ ++ /* Initialize component globals EXCEPT for perf_event, perf_event_uncore. ++ * To avoid race conditions, these components use the thread local storage ++ * construct initialized by _papi_hwi_init_global_threads(), from within ++ * their init_component(). So these must have init_component() run AFTER ++ * _papi_hwi_init_global_threads. Other components demand that init threads ++ * run AFTER init_component(), which sets up globals they need. ++ */ ++ ++ tmp = _papi_hwi_init_global( 0 ); /* Selector 0 to skip perf_event, perf_event_uncore */ ++ if ( tmp ) { ++ init_retval = tmp; ++ _papi_hwi_shutdown_global_internal( ); ++ _in_papi_library_init_cnt--; ++ papi_return( init_retval ); ++ } ++ ++ /* Initialize thread globals, including the main threads */ + + tmp = _papi_hwi_init_global_threads( ); + if ( tmp ) { +@@ -1161,9 +1177,9 @@ PAPI_library_init( int version ) + papi_return( init_retval ); + } + +- /* Initialize component globals */ ++ /* Initialize perf_event, perf_event_uncore components */ + +- tmp = _papi_hwi_init_global( ); ++ tmp = _papi_hwi_init_global( 1 ); /* Selector 1 for only perf_event, perf_event_uncore */ + if ( tmp ) { + init_retval = tmp; + _papi_hwi_shutdown_global_internal( ); +diff --git a/src/papi_internal.c b/src/papi_internal.c +index 5a1ccd433..e6dd319c2 100644 +--- a/src/papi_internal.c ++++ b/src/papi_internal.c +@@ -1928,11 +1928,13 @@ int papi_num_components = ( sizeof ( _papi_hwd ) / sizeof ( *_papi_hwd ) ) - 1; + * Routine that initializes all available components. + * A component is available if a pointer to its info vector + * appears in the NULL terminated_papi_hwd table. ++ * Modified to accept an arg: 0=do not init perf_event or ++ * perf_event_uncore. 1=init ONLY perf_event or perf_event_uncore. + */ + int +-_papi_hwi_init_global( void ) ++_papi_hwi_init_global( int PE_OR_PEU ) + { +- int retval, i = 0; ++ int retval, is_pe_peu, i = 0; + + retval = _papi_hwi_innoculate_os_vector( &_papi_os_vector ); + if ( retval != PAPI_OK ) { +@@ -1940,14 +1942,16 @@ _papi_hwi_init_global( void ) + } + + while ( _papi_hwd[i] ) { +- ++ is_pe_peu = 0; ++ if (strcmp(_papi_hwd[i]->cmp_info.name, "perf_event") == 0) is_pe_peu=1; ++ if (strcmp(_papi_hwd[i]->cmp_info.name, "perf_event_uncore") == 0) is_pe_peu=1; + retval = _papi_hwi_innoculate_vector( _papi_hwd[i] ); + if ( retval != PAPI_OK ) { + return retval; + } + + /* We can be disabled by user before init */ +- if (!_papi_hwd[i]->cmp_info.disabled) { ++ if (!_papi_hwd[i]->cmp_info.disabled && (PE_OR_PEU == is_pe_peu)) { + retval = _papi_hwd[i]->init_component( i ); + _papi_hwd[i]->cmp_info.disabled=retval; + +diff --git a/src/papi_internal.h b/src/papi_internal.h +index 6492fea4e..e0f5acd74 100644 +--- a/src/papi_internal.h ++++ b/src/papi_internal.h +@@ -467,7 +467,7 @@ int _papi_hwi_read( hwd_context_t * context, EventSetInfo_t * ESI, + long long *values ); + int _papi_hwi_cleanup_eventset( EventSetInfo_t * ESI ); + int _papi_hwi_convert_eventset_to_multiplex( _papi_int_multiplex_t * mpx ); +-int _papi_hwi_init_global( void ); ++int _papi_hwi_init_global( int PE_OR_PEU ); + int _papi_hwi_init_global_internal( void ); + int _papi_hwi_init_os(void); + void _papi_hwi_init_errors(void); diff --git a/papi.spec b/papi.spec index 56f66e2..21a5ca7 100644 --- a/papi.spec +++ b/papi.spec @@ -11,7 +11,7 @@ Summary: Performance Application Programming Interface Name: papi Version: 6.0.0 -Release: 9%{?dist} +Release: 10%{?dist} License: BSD Requires: papi-libs = %{version}-%{release} URL: http://icl.cs.utk.edu/papi/ @@ -21,6 +21,7 @@ Patch2: papi-a64fx.patch Patch3: papi-no-iozone.patch Patch4: papi-config.patch Patch5: papi-nostatic.patch +Patch6: papi-init_thread.patch BuildRequires: make BuildRequires: autoconf BuildRequires: doxygen @@ -93,6 +94,7 @@ the PAPI user-space libraries and interfaces. %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 -b .thread %build # This package fails to build with LTO due to undefined symbols. LTO @@ -191,6 +193,9 @@ find %{buildroot} -type f -executable ! -iname "*.py" ! -iname "*.sh" | xargs ch %endif %changelog +* Fri Nov 19 2021 William Cohen - 6.0.0-10 +- Correct initialization for stealtime component. + * Thu Jul 22 2021 Fedora Release Engineering - 6.0.0-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild