From f2aee0ef9fbde14ac49bf5b7cb9026a567f5c1af Mon Sep 17 00:00:00 2001 From: "Broze Paul (CC-AD/ESW1)" Date: Fri, 23 Oct 2020 15:35:23 +0200 Subject: [PATCH 1/2] AOS-13229 fix introspections shm segments view feature and remove the segfault cause by the introspection --- .../introspection/mempool_introspection.inl | 25 +++++++++++++------ .../source/introspection_app.cpp | 3 +-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl index b2939987fc3..8a0e992f269 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl @@ -134,33 +134,44 @@ void MemPoolIntrospection::send() noe if (m_senderPort.hasSubscribers()) { uint32_t id = 0; - auto chunkHeader = m_senderPort.reserveChunk(sizeof(Topic)); auto sample = static_cast(chunkHeader->payload()); new (sample) Topic; if (sample->emplace_back()) { + // RouDi's shm segment auto& memPoolIntrospectionInfo = sample->back(); - prepareIntrospectionSample(memPoolIntrospectionInfo, posix::PosixGroup::getGroupOfCurrentProcess(), posix::PosixGroup::getGroupOfCurrentProcess(), id); copyMemPoolInfo(*m_rouDiInternalMemoryManager, memPoolIntrospectionInfo.m_mempoolInfo); + ++id; + // User shm segments for (auto& segment : m_segmentManager->m_segmentContainer) { + if (sample->emplace_back()) + { + auto& memPoolIntrospectionInfo = sample->back(); + prepareIntrospectionSample( + memPoolIntrospectionInfo, segment.getReaderGroup(), segment.getWriterGroup(), id); + copyMemPoolInfo(segment.getMemoryManager(), memPoolIntrospectionInfo.m_mempoolInfo); + } + else + { + LogWarn() << "Mempool Introspection Container full, Mempool Introspection Data not fully updated! " + << (id + 1) << " of " << m_segmentManager->m_segmentContainer.size() + << " memory segments sent."; + break; + } ++id; - - prepareIntrospectionSample( - memPoolIntrospectionInfo, segment.getReaderGroup(), segment.getWriterGroup(), id); - copyMemPoolInfo(segment.getMemoryManager(), memPoolIntrospectionInfo.m_mempoolInfo); } } else { - LogError() << "Mempool Introspection Container full, Mempool Introspection Data not updated!"; + LogWarn() << "Mempool Introspection Container full, Mempool Introspection Data not updated!"; } m_senderPort.deliverChunk(chunkHeader); diff --git a/tools/introspection/source/introspection_app.cpp b/tools/introspection/source/introspection_app.cpp index 43e55603173..f01da720cbe 100644 --- a/tools/introspection/source/introspection_app.cpp +++ b/tools/introspection/source/introspection_app.cpp @@ -617,7 +617,7 @@ void IntrospectionApp::runIntrospection(const iox::units::Duration updatePeriodM SubscriberType memPoolSubscriber(IntrospectionMempoolService); if (introspectionSelection.mempool == true) { - memPoolSubscriber.subscribe(iox::MAX_SHM_SEGMENTS + 1u); + memPoolSubscriber.subscribe(1u); if (waitForSubscription(memPoolSubscriber) == false) { @@ -626,7 +626,6 @@ void IntrospectionApp::runIntrospection(const iox::units::Duration updatePeriodM } } - // process SubscriberType processSubscriber(IntrospectionProcessService); if (introspectionSelection.process == true) From 0d03970002c09eb7342884a99b1dee4d25b54b2f Mon Sep 17 00:00:00 2001 From: "Broze Paul (CC-AD/ESW1)" Date: Mon, 26 Oct 2020 10:50:02 +0100 Subject: [PATCH 2/2] AOS-13229 remark, remove general name Topic --- .../internal/roudi/introspection/mempool_introspection.hpp | 2 -- .../internal/roudi/introspection/mempool_introspection.inl | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.hpp index 8da9054cb88..5c6d5334163 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.hpp @@ -53,8 +53,6 @@ class MemPoolIntrospection TERMINATE }; - using Topic = MemPoolIntrospectionInfoContainer; - public: /** * @brief The constructor for the MemPoolIntrospection. diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl index 8a0e992f269..99cd2227f19 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl @@ -134,9 +134,9 @@ void MemPoolIntrospection::send() noe if (m_senderPort.hasSubscribers()) { uint32_t id = 0; - auto chunkHeader = m_senderPort.reserveChunk(sizeof(Topic)); - auto sample = static_cast(chunkHeader->payload()); - new (sample) Topic; + auto chunkHeader = m_senderPort.reserveChunk(sizeof(MemPoolIntrospectionInfoContainer)); + auto sample = static_cast(chunkHeader->payload()); + new (sample) MemPoolIntrospectionInfoContainer; if (sample->emplace_back()) {