Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

belynam
Copy link
Contributor

@belynam belynam commented Mar 4, 2025

…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.

…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]>
@@ -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",
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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 */
}

Copy link
Member

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'.

Copy link
Contributor Author

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.

@j-xiong
Copy link
Contributor

j-xiong commented Mar 6, 2025

Please squash the commits.

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.

3 participants