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: Add new flag to skip zeroing new memory allocations #10846

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

belynam
Copy link
Contributor

@belynam belynam commented Mar 4, 2025

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 adds a new OFI_BUFPOOL_NO_ZERO flag and will skip
the memset when that flag is set.

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

@j-xiong
Copy link
Contributor

j-xiong commented Mar 6, 2025

Please squash the commits.

@belynam belynam force-pushed the ben.lynam/bufpool_no_init branch from f003cfb to d406496 Compare March 6, 2025 15:16
@j-xiong
Copy link
Contributor

j-xiong commented Mar 6, 2025

Appveyor tests are failing. They are likely related.

@@ -317,3 +318,8 @@ int ofi_ibufpool_region_is_lower(struct dlist_entry *item, const void *arg)

return reg1->index < reg2->index;
}

void ofi_bufpool_init_noop(struct ofi_bufpool_region *region, void *buf)
Copy link
Member

Choose a reason for hiding this comment

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

The title line of the commit message is a little long and a little confusing. Maybe:

util/bufpool: Add noop init callback to skip zeroing memory

void ofi_bufpool_init_noop(struct ofi_bufpool_region *region, void *buf)
{
/* 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.

Is there a subsequent change that will use this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a subsequent change that will use this function?

There was going to be, but N/A now given the different approach I'll be pursuing.

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 adds a new OFI_BUFPOOL_NO_ZERO flag and will skip
the memset when that flag is set.

Signed-off-by: Ben Lynam <[email protected]>
@belynam belynam force-pushed the ben.lynam/bufpool_no_init branch from d406496 to a224b3e Compare March 6, 2025 22:54
@belynam belynam changed the title util/bufpool: Do not zero newly allocated buf pool memory when init f… util/bufpool: Add new flag to skip zeroing new memory allocations Mar 6, 2025
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