diff --git a/Control/AthenaMonitoring/CMakeLists.txt b/Control/AthenaMonitoring/CMakeLists.txt index ca5e9b503c19059f04a8e9bf01347a3490abe786..5a900a3c8cc58f8d6ce865924db97bc327b9a503 100644 --- a/Control/AthenaMonitoring/CMakeLists.txt +++ b/Control/AthenaMonitoring/CMakeLists.txt @@ -28,6 +28,7 @@ atlas_add_library( TrigAnalysisInterfaces TrigDecisionInterface TrigDecisionToolLib + TrigNavToolsLib PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} diff --git a/Control/AthenaMonitoring/src/AthenaMonManager.cxx b/Control/AthenaMonitoring/src/AthenaMonManager.cxx index 8306a6575dc02fcb646570d0c6160927b79f7d39..a91ae0e5922785322a01cabe53fa4370222a549a 100644 --- a/Control/AthenaMonitoring/src/AthenaMonManager.cxx +++ b/Control/AthenaMonitoring/src/AthenaMonManager.cxx @@ -29,6 +29,8 @@ #include "AthenaPoolUtilities/AthenaAttributeList.h" #include "EventInfo/EventID.h" +#include "TrigNavTools/TrigNavigationThinningSvcMutex.h" + #include "SGAudCore/ISGAudSvc.h" #include <limits.h> @@ -537,6 +539,16 @@ execute() Imp::LWHistLeakChecker lc(m_d); if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::execute():" << endmsg; + // This is legacy R2 monitoring. + // We only permit serial access (over all slots) to both HLT monitoring AND navigation thinning, as both use the same underlying thread un-safe navigation tool + // All of these elements are deprecated for R3 and are in the process of being replaced. + std::unique_lock<std::mutex> hltLock(TrigNavigationThinningSvcMutex::s_mutex, std::defer_lock); + if (name() == "HLTMonManager") { + ATH_MSG_DEBUG("HLTMonManager is obtaining the TrigNavigationThinningSvc lock in slot " + << Gaudi::Hive::currentContext().slot() << " for event " << Gaudi::Hive::currentContext().eventID().event_number() ); + hltLock.lock(); + } + StatusCode sc; sc.setChecked(); @@ -595,6 +607,7 @@ execute() } if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg; + ATH_MSG_DEBUG(name() << " is releasing the TrigNavigationThinningSvc lock"); return StatusCode::SUCCESS; } diff --git a/Trigger/TrigEvent/TrigNavTools/TrigNavTools/TrigNavigationThinningSvcMutex.h b/Trigger/TrigEvent/TrigNavTools/TrigNavTools/TrigNavigationThinningSvcMutex.h new file mode 100644 index 0000000000000000000000000000000000000000..6f4b2944e942b95dbd2ae0ccb093f1d97de09544 --- /dev/null +++ b/Trigger/TrigEvent/TrigNavTools/TrigNavTools/TrigNavigationThinningSvcMutex.h @@ -0,0 +1,22 @@ +// -*- c++ -*- + +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGNAVTOOLS_TRIGNAVIGATIONTHINNINGSVCMUTEX_H +#define TRIGNAVTOOLS_TRIGNAVIGATIONTHINNINGSVCMUTEX_H + +#include <mutex> + +/** + * @brief Low-granularity protection for Run 2 data paths. + * Currently shared by the TrigNavigationThinningSvc and AthenaMonNamager + * Both of which are deprecated and can be removed following R2->R3 nav conversion project. + */ +class TrigNavigationThinningSvcMutex { +public: + static std::mutex s_mutex; +}; + +#endif diff --git a/Trigger/TrigEvent/TrigNavTools/src/TrigNavigationThinningSvc.cxx b/Trigger/TrigEvent/TrigNavTools/src/TrigNavigationThinningSvc.cxx index fdb4a33b80ed64ece4c56af8ed7b20bf00156c98..dee68d32e3605b7a7183b73d6d4f5fd6a3abe02d 100644 --- a/Trigger/TrigEvent/TrigNavTools/src/TrigNavigationThinningSvc.cxx +++ b/Trigger/TrigEvent/TrigNavTools/src/TrigNavigationThinningSvc.cxx @@ -3,6 +3,7 @@ */ #include "TrigNavigationThinningSvc.h" +#include "TrigNavTools/TrigNavigationThinningSvcMutex.h" #include "getLabel.h" #include "TrigDecisionTool/ChainGroup.h" #include "TrigConfHLTData/HLTTriggerElement.h" @@ -15,12 +16,11 @@ #include <sstream> #include <iostream> - +std::mutex TrigNavigationThinningSvcMutex::s_mutex ATLAS_THREAD_SAFE; using HLT::TrigNavTools::SlimmingHelper; using namespace HLT; - /********************************************************************** * * Constructors and destructors @@ -282,7 +282,8 @@ StatusCode TrigNavigationThinningSvc::dropChains(State& state) const { StatusCode TrigNavigationThinningSvc::doSlimming( const EventContext& ctx, std::vector<uint32_t>& slimmed_and_serialized) const { - std::lock_guard<std::mutex> lock(m_mutex); + ATH_MSG_DEBUG(name() << " is obtaining the TrigNavigationThinningSvc lock in slot " << ctx.slot() << " for event " << ctx.eventID().event_number() ); + std::lock_guard<std::mutex> lock(TrigNavigationThinningSvcMutex::s_mutex); // grab the navigation Trig::ExpertMethods *navAccess = m_trigDecisionTool->ExperimentalAndExpertMethods(); @@ -293,6 +294,7 @@ StatusCode TrigNavigationThinningSvc::doSlimming( const EventContext& ctx, if(cnav == 0) { ATH_MSG_WARNING ( "Could not get navigation from Trigger Decision Tool" ); ATH_MSG_WARNING ( "Navigation will not be slimmed in this event" ); + ATH_MSG_DEBUG(name() << " is releasing the TrigNavigationThinningSvc lock"); return StatusCode::SUCCESS; } @@ -312,6 +314,7 @@ StatusCode TrigNavigationThinningSvc::doSlimming( const EventContext& ctx, CHECK( (this->*function)(state) ); } } + ATH_MSG_DEBUG(name() << " is releasing the TrigNavigationThinningSvc lock"); return StatusCode::SUCCESS; } diff --git a/Trigger/TrigEvent/TrigNavTools/src/TrigNavigationThinningSvc.h b/Trigger/TrigEvent/TrigNavTools/src/TrigNavigationThinningSvc.h index a55564298eaac63f486ba636301bcb62495d69d1..cd0acf9a579db92399a98559ff532e9a4d5d2c6f 100644 --- a/Trigger/TrigEvent/TrigNavTools/src/TrigNavigationThinningSvc.h +++ b/Trigger/TrigEvent/TrigNavTools/src/TrigNavigationThinningSvc.h @@ -13,8 +13,6 @@ #include "AthenaBaseComps/AthService.h" #include "AthenaKernel/ITrigNavigationThinningSvc.h" -#include <mutex> - namespace HLT { class NavigationCore; } @@ -249,8 +247,6 @@ private: */ StatusCode propagateFeaturesToChildren(const HLT::TriggerElement *te) const; - mutable std::mutex m_mutex; - // store the CLID and subtype ids of all the of the deleted features so we can // remove their holders from the navigation structure. //std::vector<std::pair<CLID, uint16_t> > *m_deletedFeatures;