Skip to content

Commit

Permalink
cause a layer violation to try to prevent unnecessary memcpys
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Lee <jasonlee@lanl.gov>
  • Loading branch information
calccrypto committed Jul 23, 2024
1 parent 52e3432 commit 2d4e356
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions module/zfs-qat-provider/provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,43 @@ zfs_qat_provider_free(void *handle)
static int
zfs_qat_provider_copy_from_generic(dpusm_mv_t *mv, const void *buf, size_t size)
{
memcpy(ptr_start(mv->handle, mv->offset), buf, size);
zqh_t *dst = (zqh_t *)mv->handle;
/*
* If the handle points to a real buffer, free it,
* and convert the handle to a reference to the
* user's pointer.
*
* This is a layer violation, but is done to prevent
* unnecessary copies of the data due to the QAT using
* in-memory addresses.
*/
if ((dst->type == ZQH_REAL) &&
(mv->offset == 0)) {
kfree(dst->ptr);

dst->type = ZQH_REF;
dst->ptr = (void *) buf;
dst->size = size;
}
else
{
memcpy(ptr_start(dst, mv->offset), buf, size);
}
return (DPUSM_OK);
}

static int
zfs_qat_provider_copy_to_generic(dpusm_mv_t *mv, void *buf, size_t size)
{
memcpy(buf, ptr_start(mv->handle, mv->offset), size);
zqh_t *src = (zqh_t *)mv->handle;
/*
* if the handle is still a real buffer, it is not
* the same as buf, so the contents have to be copied
* into buf.
*/
if (src->type == ZQH_REAL) {
memcpy(buf, ptr_start(src, mv->offset), size);
}
return (DPUSM_OK);
}

Expand Down

0 comments on commit 2d4e356

Please sign in to comment.