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

allow callers to allocate and provide the abd_t struct #11439

Merged
merged 1 commit into from
Jan 20, 2021

Conversation

ahrens
Copy link
Member

@ahrens ahrens commented Jan 7, 2021

Motivation and Context

The abd_get_offset_*() routines create an abd_t that references
another abd_t, and doesn't allocate any pages/buffers of its own. In
some workloads, these routines may be called frequently, to create many
abd_t's representing small pieces of a single large abd_t. In
particular, the upcoming RAIDZ Expansion project makes heavy use of
these routines.

Description

This commit adds the ability for the caller to allocate and provide the
abd_t struct to a variant of abd_get_offset_*(). This eliminates the
cost of allocating the abd_t and performing the accounting associated
with it (abdstat_struct_size). The RAIDZ/DRAID code uses this for the
rc_abd, which references the zio's abd. The upcoming RAIDZ Expansion
project will leverage this infrastructure to increase performance of
reads post-expansion by around 50%.

Additionally, some of the interfaces around creating and destroying
abd_t's are cleaned up. Most significantly, the distinction between
abd_put() and abd_free() is eliminated; all types of abd_t's are now
disposed of with abd_free().

How Has This Been Tested?

ZTS, zloop, and perf testing with RAIDZ Expansion code (#8853).

Note: I haven't tested the FreeBSD changes. We'll see how it does with buildbot.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@ahrens ahrens requested a review from behlendorf January 7, 2021 03:49
@ahrens
Copy link
Member Author

ahrens commented Jan 7, 2021

cc @fuporovvStack

@behlendorf
Copy link
Contributor

This is a nice improvement to the interface! I'm still working my way through it but a few quick comments.

PR #11397 has just been merged so you can rebase and drop it form the patch stack here. Which you're at it I'd suggest squashing the two remaining commits and adding the following line to the commit comment to additionally request the "coverage" builder. By default we stopped running it for every PR a little while back and have only been running it for merged commits. But in this case I think we need to run the kmemleak checker to ensure no abds are ever getting leaked.

Requires-builders: arch,centos7,centos8,centosstream8,debian10,fedora33,ubuntu18,ubuntu20,builtin,freebsd12,freebsd13,coverage

Note: I haven't tested the FreeBSD changes. We'll see how it does with buildbot.

FYI, just in the last day or so we've seen some instability in the FreeBSD head builder. But since both the head and stable/12 builders failed right away when starting the ZTS odds are something still isn't quite right in the FreeBSD code modified by this PR. I'd have expected the stable/12 builder to pass.

cc: @bwatkinson

@codecov
Copy link

codecov bot commented Jan 12, 2021

Codecov Report

Merging #11439 (399ea4c) into master (a9eaae0) will increase coverage by 0.01%.
The diff coverage is 87.80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11439      +/-   ##
==========================================
+ Coverage   76.74%   76.76%   +0.01%     
==========================================
  Files         400      400              
  Lines      127851   127816      -35     
==========================================
- Hits        98118    98114       -4     
+ Misses      29733    29702      -31     
Flag Coverage Δ
kernel 80.59% <87.39%> (-0.03%) ⬇️
user 47.76% <73.77%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
include/sys/vdev_raidz_impl.h 100.00% <ø> (ø)
module/zfs/zio.c 84.95% <50.00%> (ø)
module/zfs/vdev_raidz.c 90.90% <73.33%> (+2.67%) ⬆️
module/zfs/vdev_draid.c 86.76% <76.92%> (-0.22%) ⬇️
module/zfs/abd.c 95.17% <90.47%> (+1.13%) ⬆️
cmd/raidz_test/raidz_test.c 82.69% <100.00%> (-0.23%) ⬇️
include/sys/abd.h 100.00% <100.00%> (ø)
module/os/linux/zfs/abd_os.c 97.53% <100.00%> (-0.10%) ⬇️
module/zfs/arc.c 86.32% <100.00%> (-0.08%) ⬇️
module/zfs/dbuf.c 92.19% <100.00%> (-0.06%) ⬇️
... and 50 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9eaae0...399ea4c. Read the comment docs.

Copy link
Contributor

@bwatkinson bwatkinson left a comment

Choose a reason for hiding this comment

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

Overall, this is pretty cool.

include/sys/abd.h Outdated Show resolved Hide resolved
Comment on lines +196 to +197
static inline uint_t
abd_get_size(abd_t *abd)
{
return (abd->abd_size);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I originally created this function because we hid the definition on the ABD struct in abd_impl.h. Technically we don't need this anymore, but it can stay if everyone wants to keep it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I could go either way but I figured keeping it as an accessor doesn't hurt.

@bwatkinson
Copy link
Contributor

@ahrens this has nothing to do with your PR, but could you possibly update line 775 in abd.c in this PR? I meant to update this from abd_multi -> abd_is_gang_abd in previous ABD update PR's and I just missed it... This is a lingering artifact from when I originally had gang ABD's named as multi ABD's and it has been driving me crazy. Going ahead and approving this PR.

The `abd_get_offset_*()` routines create an abd_t that references
another abd_t, and doesn't allocate any pages/buffers of its own.  In
some workloads, these routines may be called frequently, to create many
abd_t's representing small pieces of a single large abd_t.  In
particular, the upcoming RAIDZ Expansion project makes heavy use of
these routines.

This commit adds the ability for the caller to allocate and provide the
abd_t struct to a variant of `abd_get_offset_*()`.  This eliminates the
cost of allocating the abd_t and performing the accounting associated
with it (`abdstat_struct_size`).  The RAIDZ/DRAID code uses this for the
`rc_abd`, which references the zio's abd.  The upcoming RAIDZ Expansion
project will leverage this infrastructure to increase performance of
reads post-expansion by around 50%.

Additionally, some of the interfaces around creating and destroying
abd_t's are cleaned up.  Most significantly, the distinction between
`abd_put()` and `abd_free()` is eliminated; all types of abd_t's are now
disposed of with `abd_free()`.

Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Requires-builders: arch,centos7,centos8,centosstream8,debian10,fedora33,ubuntu18,ubuntu20,builtin,freebsd12,freebsd13,coverage
@ahrens
Copy link
Member Author

ahrens commented Jan 15, 2021

@bwatkinson Sure thing.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jan 20, 2021
@behlendorf behlendorf merged commit e2af2ac into openzfs:master Jan 20, 2021
@ahrens ahrens deleted the abdstruct2 branch January 20, 2021 19:53
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
The `abd_get_offset_*()` routines create an abd_t that references
another abd_t, and doesn't allocate any pages/buffers of its own.  In
some workloads, these routines may be called frequently, to create many
abd_t's representing small pieces of a single large abd_t.  In
particular, the upcoming RAIDZ Expansion project makes heavy use of
these routines.

This commit adds the ability for the caller to allocate and provide the
abd_t struct to a variant of `abd_get_offset_*()`.  This eliminates the
cost of allocating the abd_t and performing the accounting associated
with it (`abdstat_struct_size`).  The RAIDZ/DRAID code uses this for
the `rc_abd`, which references the zio's abd.  The upcoming RAIDZ
Expansion project will leverage this infrastructure to increase
performance of reads post-expansion by around 50%.

Additionally, some of the interfaces around creating and destroying
abd_t's are cleaned up.  Most significantly, the distinction between
`abd_put()` and `abd_free()` is eliminated; all types of abd_t's are
now disposed of with `abd_free()`.

Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Issue openzfs#8853 
Closes openzfs#11439
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
The `abd_get_offset_*()` routines create an abd_t that references
another abd_t, and doesn't allocate any pages/buffers of its own.  In
some workloads, these routines may be called frequently, to create many
abd_t's representing small pieces of a single large abd_t.  In
particular, the upcoming RAIDZ Expansion project makes heavy use of
these routines.

This commit adds the ability for the caller to allocate and provide the
abd_t struct to a variant of `abd_get_offset_*()`.  This eliminates the
cost of allocating the abd_t and performing the accounting associated
with it (`abdstat_struct_size`).  The RAIDZ/DRAID code uses this for
the `rc_abd`, which references the zio's abd.  The upcoming RAIDZ
Expansion project will leverage this infrastructure to increase
performance of reads post-expansion by around 50%.

Additionally, some of the interfaces around creating and destroying
abd_t's are cleaned up.  Most significantly, the distinction between
`abd_put()` and `abd_free()` is eliminated; all types of abd_t's are
now disposed of with `abd_free()`.

Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Issue openzfs#8853 
Closes openzfs#11439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants