Skip to content

Extend the generic skeleton to opening non-owned shared memory objects.#482

Open
Rahul-Sutariya wants to merge 1 commit into
eclipse-score:mainfrom
Rahul-Sutariya:extend_genericSkeleton_to_open_non_owned_shared_mem_obj
Open

Extend the generic skeleton to opening non-owned shared memory objects.#482
Rahul-Sutariya wants to merge 1 commit into
eclipse-score:mainfrom
Rahul-Sutariya:extend_genericSkeleton_to_open_non_owned_shared_mem_obj

Conversation

@Rahul-Sutariya
Copy link
Copy Markdown
Contributor

Issue: #387

@Rahul-Sutariya Rahul-Sutariya changed the title Extend the generic skeleton to open non-owned shared memory objects and construct the shared memory path from inter-VM shared memory. Extend the generic skeleton to support opening non-owned shared memory objects. Add ShmPathBuilder extension to inject inter-VM–specific path elements while constructing shared memory paths from inter-VM shared memory configuration. May 28, 2026
@Rahul-Sutariya Rahul-Sutariya changed the title Extend the generic skeleton to support opening non-owned shared memory objects. Add ShmPathBuilder extension to inject inter-VM–specific path elements while constructing shared memory paths from inter-VM shared memory configuration. Extend the generic skeleton to opening non-owned shared memory objects and add ShmPathBuilder extension for inter-VM shm path construction. May 28, 2026
@Rahul-Sutariya Rahul-Sutariya marked this pull request as ready for review May 28, 2026 13:48
@Rahul-Sutariya Rahul-Sutariya self-assigned this May 29, 2026

// Inter-VM shared-memory backends can have a short NAME_MAX, use compact 5-digit service ID instead of the default
// 16-digit padding
void AppendServiceAndInstanceCompact(std::ostream& out,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave out this "compacting". If we would takes this over from the PoC ... then we would really materialize all the bugs/short-commings, which BlackBerry had in their sample-contribution :) (namely they had a weird restriction in their qvmshm implementation regarding path-name-sizes).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed compacting, spilt the pr and updated to: #492

{
public:
explicit ShmPathBuilder(const std::uint16_t service_id) noexcept : IShmPathBuilder{}, service_id_{service_id} {}
explicit ShmPathBuilder(const std::uint16_t service_id, const bool inter_vm_support = false) noexcept
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a doxygen comment to this ctor.
document/comment the inter_vm_support parameter. Note, that it is an interim solution, to express the intent to have a shm-object, which supports sharing across VMs by encoding it into the path-name. A future solution will be based on a redesigned lib/memory/shared API abstraction.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gateway_shm_ready_ = false;
break;

case ShmReuseStrategy::kUnknownStrategy:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should have a "fal through" here:

case ShmReuseStrategy::kUnknownStrategy:
default:
   SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE(false, "Unknown SHM reuse strategy.");
   break;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapted the changes, thanks

"Could not open existing shared memory region for gateway-forwarded service.");
}
was_old_shm_region_reopened_ = false;
gateway_shm_ready_ = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, we should rename gateway_shm_ready_ -> use_gateway_forwarded_shm_

midterm we might need some refactoring imho ... because now we have different flags, which are mutual exclusive (was_old_shm_region_reopened_ , use_gateway_forwarded-shm_) which is a bit ugly...

So from a high-level perspective, we have either a "normal" skeleton ... or a "forwarding" skeleton.
So - for now we express the latter only with this flag use_gateway_forwarded_shm_ ... which looks a bit "hacky" as a lot of behaviour is different in this case. So I'm thinking in the direction to introduce a more generic "mode" attribute in our skeleton class, which is either "REGULAR" or "FORWARDING" ... but this is - as I said - for future refactorings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remanned gateway_shm_ready_ -> use_gateway_forwarded_shm_, thanks

// re-open that shared memory in PrepareOffer(). In that case, we should retrieved the EventDataControl and
// EventDataStorage from the shared memory and attempt to rollback the Skeleton tracing transaction log.
if (was_old_shm_region_reopened_)
if (gateway_shm_ready_)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do an assert here! If we end up in this template-function call AND gateway_shm_ready_ (now - see above use_gateway_forwarded_shm_ ) is true, something went wrong.
Why? Because this specific interVM functionality is only used in our gateway setups, where always GenericSkeleton is used - no "typed skeletons". But in case of a GenericSkeleton this template-func will never be called! Because in this case we only deal with GenericSkeletonEvents, which do not call this template func, but instead the non-template func Skeleton::RegisterGeneric()!

So - make an assert here and document, that use_gateway_forwarded_shm_ == true is only expected in gateway-use-cases, where GenericSkeletons are used ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the changes, Thanks

const auto event_metainfo_it = find_element(storage_->events_metainfo_, element_fq_id);
const auto event_data_storage_it = find_element(storage_->events_, element_fq_id);

if (lola_service_instance_deployment_.inter_vm_support_ && lola_service_instance_deployment_.inter_vm_forwarded_)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See argumentation above! In case we are in the interVM-gateway case, we expect a GenericSkeleton being used. But then, we would NOT end up in this template func as it is only used within "typed skeletons".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the changes. Thanks

return quality_type_;
}

Result<void> Skeleton::ValidateDataShmObject(const SkeletonEventBindings& events,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not see any calls to this method (and also not to ValidateControlShmObject)

Where did you expect the validation calls to happen?
My 1st guess would be directly after opening the shm-objects in PrepareOffer?

But now I had a 2nd look... and I'm not sure, whether this validation you implemented here is "added value".
My thoughts:

  • in Skeleton::RegisterGeneric() further down you have the code every GenericSkeletonEvent (and later also field) will run through, to register at its parent skeleton, thereby also "checking" the shared memory (CONTROL and DATA). I.e. at least it checks, whether for its ElementFqId the expected control/data artefact exists in shared-memory ... so if in the interVM use case, the shm, which we opened would be a wrong one, Skeleton::RegisterGeneric() would fail.
  • do you really check much more here, than what is implicitly checked in Skeleton::RegisterGeneric()?

You are even hyper-strict here - as you check, that the shm conains exactly the number of events/fields as you have here with events/ fields params ... if the shm-object would contain additional ones ... that would not even be a real problem/error. The Skeleton::RegisterGeneric() is more "flexible" ... it just checks, that the things at least exist in shm, which we expect ... if there is even more ... no problem.

My proposal:

  • remove ValidateDataShmObject and ValidateControlShmObject
  • if you feel that some consistency checks are missing within Skeleton::RegisterGeneric() ... add them there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right i feel Skeleton::RegisterGeneric() is enough to verify, removed both functions, Thanks

const size_t sample_alignment) noexcept -> GenericRegistrationResult
{
if (was_old_shm_region_reopened_)
if (gateway_shm_ready_)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be optimized:
the if/else branch basically just differ regarding rollback! Only in one case a rollback is done - in the other not.

if (use_gateway_forwarded_shm_ || was_old_shm_region_reopened_)
{
   auto [event_data_control_qm, event_data_control_asil_b] =
            memory_manager_.RetrieveEventControlsFromOpenedSharedMemory(element_fq_id);

   auto& event_data_storage = memory_manager_.RetrieveEventDataFromOpenedSharedMemory<std::uint8_t>(element_fq_id);
 if (!use_gateway_forwarded_shm_)
 {
        memory_manager_.RollbackSkeletonTracingTransactions(event_data_control_qm);
        if (event_data_control_asil_b != nullptr)
        {
            memory_manager_.RollbackSkeletonTracingTransactions(*event_data_control_asil_b);
        }
   }
   return {static_cast<void*>(&event_data_storage), event_data_control_qm, event_data_control_asil_b};
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimized the code, Thanks

@Rahul-Sutariya Rahul-Sutariya force-pushed the extend_genericSkeleton_to_open_non_owned_shared_mem_obj branch from 84454fd to 22b416d Compare June 1, 2026 10:50
@Rahul-Sutariya Rahul-Sutariya force-pushed the extend_genericSkeleton_to_open_non_owned_shared_mem_obj branch from 22b416d to ed155b6 Compare June 2, 2026 05:25
@Rahul-Sutariya Rahul-Sutariya changed the title Extend the generic skeleton to opening non-owned shared memory objects and add ShmPathBuilder extension for inter-VM shm path construction. Extend the generic skeleton to opening non-owned shared memory objects. Jun 2, 2026
@Rahul-Sutariya Rahul-Sutariya requested a review from crimson11 June 2, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants