-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fixing ABD struct allocation for FreeBSD #10431
Conversation
ea0bb10
to
b3855ed
Compare
A bit of clarification. This issue is never hit on FreeBSD under normal circumstances because kernel malloc will round up to the nearest power of two for sub page allocations (and thus 192 bytes actually translated to a 256 byte allocation). There is a purify / ElectricFence like debugging facility called memguard which will put new allocations size offset from the end of the page and, not map the adjacent pages, and then unmap the page that the allocation was on when the object was freed. This means that with memguard a 192 byte allocation is at page boundary + 3904, so when abd gang initialization tried to initailize the |
Sure did;
Thanks for looking into this, I will give this commit a test without mine. |
I applied this with my abd patch
Running
So it does not fix everything for macOS. |
I applied the same size math to |
If it helps:
|
b3855ed
to
8e5ad55
Compare
What is strange to be about this is somehow on OSX the ABD's Also, I wound up pushing up a change to |
8e5ad55
to
e740557
Compare
In the event we are allocating a gang ABD in FreeBSD we are passsing 0 to abd_alloc_struct(); however, this led to an allocation of ABD scatter with 0 chunks. This left the gang ABD allocation 24 bytes smaller than it should have been. Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
I copied over the freebsd
From the logs I pasted, it seems that |
Codecov Report
@@ Coverage Diff @@
## master #10431 +/- ##
=======================================
Coverage 79.54% 79.55%
=======================================
Files 391 391
Lines 123866 123866
=======================================
+ Hits 98531 98543 +12
+ Misses 25335 25323 -12
Continue to review full report at Codecov.
|
So each of the abd_os.c files has their own definition of |
@bwatkinson maybe we can go ahead and fix the FreeBSD bug and file a PR for the OSX one? |
@mattmacy I agree. This fixes the FreeBSD issue as it was intended to do. @lundman, it seems that the issue you are seeing in OSX has to do with scatter ABDs, so this PR is not related to that issue. We can create another PR for that, and I can assist you in tracing down the issue in OSX separate from this PR. |
That sounds great. |
In the event we are allocating a gang ABD in FreeBSD we are passing 0 to abd_alloc_struct(); however, this led to an allocation of ABD scatter with 0 chunks. This left the gang ABD allocation 24 bytes smaller than it should have been. Reviewed-by: Matt Macy <mmacy@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Co-authored-by: Matt Macy <mmacy@FreeBSD.org> Signed-off-by: Brian Atkinson <batkinson@lanl.gov> Closes #10431
In the event we are allocating a gang ABD in FreeBSD we are passing 0 to abd_alloc_struct(); however, this led to an allocation of ABD scatter with 0 chunks. This left the gang ABD allocation 24 bytes smaller than it should have been. Reviewed-by: Matt Macy <mmacy@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Co-authored-by: Matt Macy <mmacy@FreeBSD.org> Signed-off-by: Brian Atkinson <batkinson@lanl.gov> Closes openzfs#10431
In the event we are allocating a gang ABD in FreeBSD we are passing 0 to abd_alloc_struct(); however, this led to an allocation of ABD scatter with 0 chunks. This left the gang ABD allocation 24 bytes smaller than it should have been. Reviewed-by: Matt Macy <mmacy@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Co-authored-by: Matt Macy <mmacy@FreeBSD.org> Signed-off-by: Brian Atkinson <batkinson@lanl.gov> Closes openzfs#10431
In the event we are allocating a gang ABD in FreeBSD we are passsing 0
to abd_alloc_struct(); however, this led to an allocation of ABD scatter
with 0 chunks. This left the gang ABD allocation 24 bytes smaller than
it should have been.
Signed-off-by: Brian Atkinson batkinson@lanl.gov
Fix ABD allocation bug in FreeBSD for allocating a gang ABD.
Motivation and Context
Currently if a gang ABD is allocated in FreeBSD the allocation size (abd_size) was incorrect.
Description
When a gang ABD is allocated the size passed into abd_alloc_struct() is 0. This leads to an ABD allocation based on a 0 chunk count scatter ABD. This is incorrect and leads 24 unallocated bytes in the case of gang ABD's. We want the allocation to be based on the ABD struct size with the union accounted for for gang ABDs. FreeBSD was rounding this up to 32 (using a power of two), but Matt Macy was able to capture this issue with his async work. We now do an allocation in abd_struct_alloc() base on the MAX of the chunkcnt or the size of an ADB struct.
How Has This Been Tested?
Ran zloop.sh (30 mins) and ZTS tests.
FreeBSD 12.1 STABLE
Types of changes
Checklist:
Signed-off-by
.