Fix memory allocation for the checksum benchmark

Allocation via kmem_cache_alloc() is limited to less then 4m for
some architectures.

This commit limits the benchmarks with the linear abd cache to 1m
on all architectures and adds 4m + 16m benchmarks via non-linear
abd_alloc().

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Co-authored-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Closes #13669
Closes #13670
This commit is contained in:
Tino Reichardt 2022-07-21 02:01:32 +02:00 committed by GitHub
parent f371cc18f8
commit 97fd1ea42a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 6 deletions

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2021 Tino Reichardt <milky-zfs@mcmilk.de>
* Copyright (c) 2021-2022 Tino Reichardt <milky-zfs@mcmilk.de>
*/
#include <sys/types.h>
@ -43,6 +43,7 @@ typedef struct {
uint64_t bs256k;
uint64_t bs1m;
uint64_t bs4m;
uint64_t bs16m;
zio_cksum_salt_t salt;
zio_checksum_t *(func);
zio_checksum_tmpl_init_t *(init);
@ -85,7 +86,8 @@ chksum_stat_kstat_headers(char *buf, size_t size)
off += snprintf(buf + off, size - off, "%8s", "64k");
off += snprintf(buf + off, size - off, "%8s", "256k");
off += snprintf(buf + off, size - off, "%8s", "1m");
(void) snprintf(buf + off, size - off, "%8s\n", "4m");
off += snprintf(buf + off, size - off, "%8s", "4m");
(void) snprintf(buf + off, size - off, "%8s\n", "16m");
return (0);
}
@ -112,8 +114,10 @@ chksum_stat_kstat_data(char *buf, size_t size, void *data)
(u_longlong_t)cs->bs256k);
off += snprintf(buf + off, size - off, "%8llu",
(u_longlong_t)cs->bs1m);
(void) snprintf(buf + off, size - off, "%8llu\n",
off += snprintf(buf + off, size - off, "%8llu",
(u_longlong_t)cs->bs4m);
(void) snprintf(buf + off, size - off, "%8llu\n",
(u_longlong_t)cs->bs16m);
return (0);
}
@ -153,6 +157,8 @@ chksum_run(chksum_stat_t *cs, abd_t *abd, void *ctx, int round,
size = 1<<20; loops = 4; break;
case 7: /* 4m */
size = 1<<22; loops = 1; break;
case 8: /* 16m */
size = 1<<24; loops = 1; break;
}
kpreempt_disable();
@ -177,26 +183,31 @@ chksum_benchit(chksum_stat_t *cs)
void *ctx = 0;
void *salt = &cs->salt.zcs_bytes;
/* allocate test memory via default abd interface */
abd = abd_alloc_linear(1<<22, B_FALSE);
memset(salt, 0, sizeof (cs->salt.zcs_bytes));
if (cs->init) {
ctx = cs->init(&cs->salt);
}
/* allocate test memory via abd linear interface */
abd = abd_alloc_linear(1<<20, B_FALSE);
chksum_run(cs, abd, ctx, 1, &cs->bs1k);
chksum_run(cs, abd, ctx, 2, &cs->bs4k);
chksum_run(cs, abd, ctx, 3, &cs->bs16k);
chksum_run(cs, abd, ctx, 4, &cs->bs64k);
chksum_run(cs, abd, ctx, 5, &cs->bs256k);
chksum_run(cs, abd, ctx, 6, &cs->bs1m);
abd_free(abd);
/* allocate test memory via abd non linear interface */
abd = abd_alloc(1<<24, B_FALSE);
chksum_run(cs, abd, ctx, 7, &cs->bs4m);
chksum_run(cs, abd, ctx, 8, &cs->bs16m);
abd_free(abd);
/* free up temp memory */
if (cs->free) {
cs->free(ctx);
}
abd_free(abd);
}
/*