-
Notifications
You must be signed in to change notification settings - Fork 403
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
util/bufpool: Do not zero newly allocated buf pool memory when init f… #10846
base: main
Are you sure you want to change the base?
Conversation
…unction is present. When a buf pool allocates a new chunk of memory, the entire memory chunk is zeroed out via a call to memset. This can be quite costly, occur at inconvenient times, and end up being wasteful when buf pool users initialize their own entries. This change skips the memset when the buf pool has an init function specified. For users who want no initialization to take place in the buf pool code at all, a new ofi_bufpool_init_none() function is available to specify as the init function to use. Signed-off-by: Ben Lynam <[email protected]>
prov/util/src/util_buf.c
Outdated
@@ -269,8 +270,7 @@ int ofi_bufpool_create_attr(struct ofi_bufpool_attr *attr, | |||
pool->region_size = pool->alloc_size - pool->entry_size; | |||
|
|||
FI_DBG(&core_prov, FI_LOG_CORE, | |||
"%s alloc_size %zu region_size %zu align_entry %zu " | |||
"entry_size %zu chuck_cnt %ld pool %p (%p)\n", | |||
"%s alloc_size %zu region_size %zu align_entry %zu entry_size %zu chunk_cnt %ld pool %p (%p)\n", |
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.
line length is too long, please revert change
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.
(Note this change also corrects a typo, chuck_cnt
-> chunk_cnt
)
According to the Linux kernel coding style guidelines:
However, never break user-visible strings such as printk messages because that breaks the ability to grep for them.
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.
Yes, I know the kernel guidelines. The print includes the file and line number anyway, so grep isn't needed. Besides, it's not like someone can take the print output and toss it into grep anyway. They have to know how and where to convert portions of the output into a regular expression.
Please keep the typo fix, but not make me need to scroll left/right in my editor. My eyeballs hate that.
{ | ||
/* This function is purposely empty */ | ||
} | ||
|
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.
This won't be a static inline function. The function is passed by referenced, so actually needs to live somewhere. I'd call this 'noop' instead of 'none'.
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.
Good point, I'll move the function definition to util_buf.c and update the declaration here w/ the name change.
Signed-off-by: Ben Lynam <[email protected]>
Please squash the commits. |
…unction is present.
When a buf pool allocates a new chunk of memory, the entire memory chunk is zeroed out via a call to memset. This can be quite costly, occur at inconvenient times, and end up being wasteful when buf pool users initialize their own entries.
This change skips the memset when the buf pool has an init function specified. For users who want no initialization to take place in the buf pool code at all, a new ofi_bufpool_init_none() function is available to specify as the init function to use.