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

Refactor CxPlat Pool Abstraction #4929

Merged
merged 25 commits into from
Mar 20, 2025
Merged

Refactor CxPlat Pool Abstraction #4929

merged 25 commits into from
Mar 20, 2025

Conversation

nibanks
Copy link
Member

@nibanks nibanks commented Mar 18, 2025

Description

Updates the CxPlat Pool abstraction to maintain the owning pool pointer so that free always goes back to the allocation source.

Testing

CI/CD

Documentation

N/A

@nibanks nibanks requested a review from a team as a code owner March 18, 2025 16:07
@nibanks nibanks added the Area: Core Related to the shared, core protocol logic label Mar 18, 2025
Copy link
Contributor

@guhetier guhetier left a comment

Choose a reason for hiding this comment

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

Nice to see how many paths can be simplified by no longer needing to keep a pointer to the pool around :)

Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 79.31034% with 6 lines in your changes missing coverage. Please review.

Project coverage is 86.93%. Comparing base (06d7a25) to head (5963b40).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/core/worker.c 33.33% 2 Missing ⚠️
src/core/api.c 50.00% 1 Missing ⚠️
src/core/binding.c 66.66% 1 Missing ⚠️
src/core/operation.c 75.00% 1 Missing ⚠️
src/core/stream.c 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4929      +/-   ##
==========================================
- Coverage   87.42%   86.93%   -0.50%     
==========================================
  Files          56       56              
  Lines       17726    17723       -3     
==========================================
- Hits        15497    15407      -90     
- Misses       2229     2316      +87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

CXPLAT_FRE_ASSERT(Pool->ListDepth > 0);
CXPLAT_POOL_HEADER* Header =
#if DEBUG
CxPlatGetAllocFailDenominator() ? NULL :
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this fixing a bug in the previous behavior? It looks like previously it would allocate new on true, and allocate from the pool on false. Now it's return NULL on true, and allocating from the pool or new on false.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok yeah, it's coming back to me now. The point of this was to skip the pool's lookaside list and always call CxPlatAlloc when random memory failures are enabled so that the logic in CxPlatAlloc can decide to return NULL.
The problem here is there's now a timing change where it'll always take and then drop the lock before allocating directly, when it would skip the lock before. Maybe that'll exercise new code paths.

Copy link
Contributor

Choose a reason for hiding this comment

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

The point of this was to skip the pool's lookaside list and always call CxPlatAlloc when random memory failures are enabled so that the logic in CxPlatAlloc can decide to return NULL.

It'll be nice to have this in a comment, I was wondering what this could be for.

Copy link
Member Author

Choose a reason for hiding this comment

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

This code isn't changing any behavior. It's still skipping the lookaside list when we have either random allocations or custom allocation index dropping enabled. It sets the value to NULL here, which forces the code to call alloc below. And I'd rather not change the code once more if it's only for a comment. 😄

CXPLAT_FRE_ASSERT(Pool->ListDepth > 0);
CXPLAT_POOL_HEADER* Header =
#if DEBUG
CxPlatGetAllocFailDenominator() ? NULL :
Copy link
Contributor

Choose a reason for hiding this comment

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

The point of this was to skip the pool's lookaside list and always call CxPlatAlloc when random memory failures are enabled so that the logic in CxPlatAlloc can decide to return NULL.

It'll be nice to have this in a comment, I was wondering what this could be for.

@nibanks nibanks merged commit 8976803 into main Mar 20, 2025
417 of 421 checks passed
@nibanks nibanks deleted the cxplat-pool-refactor branch March 20, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Core Related to the shared, core protocol logic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants