aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorMateusz Guzik <[email protected]>2022-05-04 20:46:37 +0200
committerGitHub <[email protected]>2022-05-04 11:46:37 -0700
commit81b8b2d004442c3e7f196d61c2ae8eed02712b6c (patch)
tree94d570e88227270cc675aab82f4041b86beb3127 /module
parenta894ae75b817631e49cf8a23f3f9b432bd31296e (diff)
FreeBSD: use zero_region instead of allocating a dedicated page
Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: Mateusz Guzik <[email protected]> Closes #13406
Diffstat (limited to 'module')
-rw-r--r--module/os/freebsd/zfs/abd_os.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/module/os/freebsd/zfs/abd_os.c b/module/os/freebsd/zfs/abd_os.c
index 5d2bae5cf..58a37df62 100644
--- a/module/os/freebsd/zfs/abd_os.c
+++ b/module/os/freebsd/zfs/abd_os.c
@@ -113,7 +113,6 @@ static kstat_t *abd_ksp;
* memory by only using a single zero buffer for the scatter chunks.
*/
abd_t *abd_zero_scatter = NULL;
-static char *abd_zero_buf = NULL;
static uint_t
abd_chunkcnt_for_bytes(size_t size)
@@ -241,18 +240,16 @@ abd_free_struct_impl(abd_t *abd)
/*
* Allocate scatter ABD of size SPA_MAXBLOCKSIZE, where
- * each chunk in the scatterlist will be set to abd_zero_buf.
+ * each chunk in the scatterlist will be set to the same area.
*/
+_Static_assert(ZERO_REGION_SIZE >= PAGE_SIZE, "zero_region too small");
static void
abd_alloc_zero_scatter(void)
{
uint_t i, n;
n = abd_chunkcnt_for_bytes(SPA_MAXBLOCKSIZE);
- abd_zero_buf = kmem_cache_alloc(abd_chunk_cache, KM_PUSHPAGE);
- memset(abd_zero_buf, 0, PAGE_SIZE);
abd_zero_scatter = abd_alloc_struct(SPA_MAXBLOCKSIZE);
-
abd_zero_scatter->abd_flags |= ABD_FLAG_OWNER | ABD_FLAG_ZEROS;
abd_zero_scatter->abd_size = SPA_MAXBLOCKSIZE;
@@ -260,7 +257,7 @@ abd_alloc_zero_scatter(void)
for (i = 0; i < n; i++) {
ABD_SCATTER(abd_zero_scatter).abd_chunks[i] =
- abd_zero_buf;
+ __DECONST(void *, zero_region);
}
ABDSTAT_BUMP(abdstat_scatter_cnt);
@@ -275,7 +272,6 @@ abd_free_zero_scatter(void)
abd_free_struct(abd_zero_scatter);
abd_zero_scatter = NULL;
- kmem_cache_free(abd_chunk_cache, abd_zero_buf);
}
static int