-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH v4] linux-gen: shm: make internal ishm block names unique #2174
[PATCH v4] linux-gen: shm: make internal ishm block names unique #2174
Conversation
4104c64
to
e3375e1
Compare
@@ -2045,7 +2065,7 @@ int _odp_ishm_status(const char *title) | |||
_ODP_PRINT("%2i %-*s %s%c %p-%p %-8" PRIu64 " " | |||
"%-8" PRIu64 " %-3" PRIu64 " %-3" PRIu64 " " | |||
"%-3d %s\n", | |||
i, max_name_len, ishm_tbl->block[i].name, | |||
i, max_name_len, ishm_tbl->block[i].param_name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since .name was changed to .param_name. the corresponding field width parameter max_name_len should also be calculated from param_name instead of name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in V3.
@@ -2142,7 +2162,7 @@ void _odp_ishm_print(int block_index) | |||
block = &ishm_tbl->block[block_index]; | |||
|
|||
_ODP_PRINT("\nSHM block info\n--------------\n"); | |||
_ODP_PRINT(" name: %s\n", block->name); | |||
_ODP_PRINT(" name: %s\n", block->param_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the internal unique name could still be printed too since this function appears to be meant for debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Print added in V3.
_odp_strcpy(new_block->name, name, ISHM_NAME_MAXLEN); | ||
else | ||
/* Save application given block name as-is and make internal block name used for mmap | ||
unique */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to alloc_single_va() later on in this function still uses the application given non-unique name. I did not read carefully but it looks like it would be a problem for exported memory blocks as it would cause overlapping export file names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was not a problem but logic changed in V3.
platform/linux-generic/odp_ishm.c
Outdated
else | ||
/* Save application given block name as-is and make internal block name used for mmap | ||
unique */ | ||
if (name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be simpler to always make the internal name unique, even if no name was given by the application? Now the situation is a bit weird that the internal name is unique except when it is the empty string in which case it is not unique and then the lower level code has to special case that and create a unique string using create_seq_string(). Making the name always unique would make the code more clear, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic changed in V3 to always use unique internal names.
platform/linux-generic/odp_ishm.c
Outdated
_odp_strcpy(block_name, name, sz); | ||
|
||
while (find_block_by_name(block_name, false) >= 0) | ||
_odp_snprint(block_name, sz, "%d-%s", i++, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I noticed that the create_seq_string() and ishm_tbl->dev_seq are already there, maybe (?) this could just generate the unique name using dev_seq or similar and avoid the search?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in V3.
e3375e1
to
196827a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Export behaves a bit weirdly if the application given SHM name is empty or non-unique, but that seem to have been there already before this commit and I am not sure how export with non-unique name could even be used.
Increase ODP_SHM_NAME_LEN default value to 64. It can be useful that SHM block names are longer compared to name lengths in other API modules. For example this enables easier use of SHM blocks to implement other API modules. Signed-off-by: Matias Elo <[email protected]> Reviewed-by: Janne Peltonen <[email protected]>
Check that SHM block names given as odp_shm_reserve() or odp_shm_import() arguments fit into ODP_SHM_NAME_LEN characters. Also, verify that internal ISHM_NAME_MAXLEN define is large enough to store block names from application. Signed-off-by: Matias Elo <[email protected]> Reviewed-by: Janne Peltonen <[email protected]>
Previously, if application used same name and ODP_SHM_PROC/ODP_SHM_EXPORT flag for multiple SHM reservations the memory blocks were mapped to the same file. Fix this by always using unique implementation internal names for memory block reservations. Signed-off-by: Matias Elo <[email protected]> Reviewed-by: Janne Peltonen <[email protected]>
196827a
to
d8a2f1a
Compare
No description provided.