From c812fe09484ec6d61b35350f06a51ecd34db5f69 Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Thu, 9 Mar 2023 12:43:26 +0100 Subject: [PATCH] bdev/malloc: report accel sequence support This actually allows malloc bdev to chain multiple accel operations together. And, since the last operation will always be a copy, accel should remove that copy by modifying previous operation's dst/src. On my system, it improved bdevperf performance (single core, qd=4, bs=128k, bdev_crypto on top of bdev_malloc, crypto_sw): randread: 5668M/s -> 8201M/s randwrite: 5148M/s -> 7856M/s Signed-off-by: Konrad Sztyber Change-Id: I5b9173fa70a42ee56f56c496a34037d46d2f420f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17202 Reviewed-by: Changpeng Liu Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- module/bdev/malloc/bdev_malloc.c | 31 +++++++++++++++++++++++++------ test/bdev/chaining.sh | 19 ++++++++++--------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/module/bdev/malloc/bdev_malloc.c b/module/bdev/malloc/bdev_malloc.c index ee45a3f13..7da754ddc 100644 --- a/module/bdev/malloc/bdev_malloc.c +++ b/module/bdev/malloc/bdev_malloc.c @@ -534,13 +534,32 @@ bdev_malloc_get_memory_domains(void *ctx, struct spdk_memory_domain **domains, i return num_domains; } +static bool +bdev_malloc_accel_sequence_supported(void *ctx, enum spdk_bdev_io_type type) +{ + struct malloc_disk *malloc_disk = ctx; + + if (malloc_disk->disk.dif_type != SPDK_DIF_DISABLE) { + return false; + } + + switch (type) { + case SPDK_BDEV_IO_TYPE_READ: + case SPDK_BDEV_IO_TYPE_WRITE: + return true; + default: + return false; + } +} + static const struct spdk_bdev_fn_table malloc_fn_table = { - .destruct = bdev_malloc_destruct, - .submit_request = bdev_malloc_submit_request, - .io_type_supported = bdev_malloc_io_type_supported, - .get_io_channel = bdev_malloc_get_io_channel, - .write_config_json = bdev_malloc_write_json_config, - .get_memory_domains = bdev_malloc_get_memory_domains, + .destruct = bdev_malloc_destruct, + .submit_request = bdev_malloc_submit_request, + .io_type_supported = bdev_malloc_io_type_supported, + .get_io_channel = bdev_malloc_get_io_channel, + .write_config_json = bdev_malloc_write_json_config, + .get_memory_domains = bdev_malloc_get_memory_domains, + .accel_sequence_supported = bdev_malloc_accel_sequence_supported, }; static int diff --git a/test/bdev/chaining.sh b/test/bdev/chaining.sh index 4fe02ff8a..990faf1cf 100755 --- a/test/bdev/chaining.sh +++ b/test/bdev/chaining.sh @@ -79,38 +79,39 @@ update_stats # Write a single 64K request and check the stats dd if=/dev/urandom of="$input" bs=1K count=64 spdk_dd --if "$input" --ob Nvme0n1 --bs $((64 * 1024)) --count 1 -(($(get_stat sequence_executed) == stats[sequence_executed] + 2)) +(($(get_stat sequence_executed) == stats[sequence_executed] + 1)) (($(get_stat executed encrypt) == stats[encrypt_executed] + 2)) (($(get_stat executed decrypt) == stats[decrypt_executed])) -# There's still one copy performed by the malloc bdev -(($(get_stat executed copy) == stats[copy_executed] + 1)) +# No copies should be done - the copy from the malloc should translate to changing encrypt's +# destination buffer +(($(get_stat executed copy) == stats[copy_executed])) update_stats # Now read that 64K, verify the stats and check that it matches what was written spdk_dd --of "$output" --ib Nvme0n1 --bs $((64 * 1024)) --count 1 -(($(get_stat sequence_executed) == stats[sequence_executed] + 2)) +(($(get_stat sequence_executed) == stats[sequence_executed] + 1)) (($(get_stat executed encrypt) == stats[encrypt_executed])) (($(get_stat executed decrypt) == stats[decrypt_executed] + 2)) -(($(get_stat executed copy) == stats[copy_executed] + 1)) +(($(get_stat executed copy) == stats[copy_executed])) cmp "$input" "$output" spdk_dd --if /dev/zero --ob Nvme0n1 --bs $((64 * 1024)) --count 1 update_stats # Now do the same using 4K requests spdk_dd --if "$input" --ob Nvme0n1 --bs 4096 --count 16 -(($(get_stat sequence_executed) == stats[sequence_executed] + 32)) +(($(get_stat sequence_executed) == stats[sequence_executed] + 16)) (($(get_stat executed encrypt) == stats[encrypt_executed] + 32)) (($(get_stat executed decrypt) == stats[decrypt_executed])) -(($(get_stat executed copy) == stats[copy_executed] + 16)) +(($(get_stat executed copy) == stats[copy_executed])) update_stats # Check the reads : > "$output" spdk_dd --of "$output" --ib Nvme0n1 --bs 4096 --count 16 -(($(get_stat sequence_executed) == stats[sequence_executed] + 32)) +(($(get_stat sequence_executed) == stats[sequence_executed] + 16)) (($(get_stat executed encrypt) == stats[encrypt_executed])) (($(get_stat executed decrypt) == stats[decrypt_executed] + 32)) -(($(get_stat executed copy) == stats[copy_executed] + 16)) +(($(get_stat executed copy) == stats[copy_executed])) cmp "$input" "$output" trap - SIGINT SIGTERM EXIT