crct10: use isa-l for crc if available
authorAnkit Kumar <ankit.kumar@samsung.com>
Tue, 31 Oct 2023 18:45:40 +0000 (00:15 +0530)
committerAnkit Kumar <ankit.kumar@samsung.com>
Tue, 31 Oct 2023 23:05:54 +0000 (04:35 +0530)
isa-l provides fast implementation for various polynomials.
This will be only used for end to end data protection, and has
a significant impact on performance.

See: https://github.com/intel/isa-l

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
HOWTO.rst
configure
crc/crct10dif_common.c
fio.1

index 6a8fb3e375b719c2c4e2f5effcef694763764495..34d6afdf6e6e4f87df0f5db29f1a8df34ba32207 100644 (file)
--- a/HOWTO.rst
+++ b/HOWTO.rst
@@ -2507,6 +2507,10 @@ with the caveat that when used on the command line, they must come after the
        If this is set to 0, fio generates protection information for
        write case and verifies for read case. Default: 1.
 
+       For 16 bit CRC generation fio will use isa-l if available otherwise
+       it will use the default slower generator.
+       (see: https://github.com/intel/isa-l)
+
 .. option:: pi_chk=str[,str][,str] : [io_uring_cmd]
 
        Controls the protection information check. This can take one or more
index 3e3f8132a31c4a92929bbbc373e455fb6f813cd7..420d97dbe64a457a0613d6d5b984b9c6154f1779 100755 (executable)
--- a/configure
+++ b/configure
@@ -189,6 +189,7 @@ libiscsi="no"
 libnbd="no"
 libnfs=""
 xnvme=""
+isal=""
 libblkio=""
 libzbc=""
 dfs=""
@@ -262,6 +263,8 @@ for opt do
   ;;
   --disable-xnvme) xnvme="no"
   ;;
+  --disable-isal) isal="no"
+  ;;
   --disable-libblkio) libblkio="no"
   ;;
   --disable-tcmalloc) disable_tcmalloc="yes"
@@ -322,6 +325,7 @@ if test "$show_help" = "yes" ; then
   echo "--enable-libiscsi       Enable iscsi support"
   echo "--enable-libnbd         Enable libnbd (NBD engine) support"
   echo "--disable-xnvme         Disable xnvme support even if found"
+  echo "--disable-isal          Disable isal support even if found"
   echo "--disable-libblkio      Disable libblkio support even if found"
   echo "--disable-libzbc        Disable libzbc even if found"
   echo "--disable-tcmalloc      Disable tcmalloc support"
@@ -2684,6 +2688,28 @@ if test "$xnvme" != "no" ; then
 fi
 print_config "xnvme engine" "$xnvme"
 
+if test "$targetos" = "Linux" ; then
+##########################################
+# Check ISA-L support
+cat > $TMPC << EOF
+#include <isa-l/crc.h>
+#include <stddef.h>
+int main(void)
+{
+  return crc16_t10dif(0, NULL, 4096);
+}
+EOF
+if test "$isal" != "no" ; then
+  if compile_prog "" "-lisal" "ISAL"; then
+    isal="yes"
+    LIBS="-lisal $LIBS"
+  else
+    isal="no"
+  fi
+fi
+print_config "isal" "$isal"
+fi
+
 ##########################################
 # Check if we have libblkio
 if test "$libblkio" != "no" ; then
@@ -3334,6 +3360,9 @@ if test "$xnvme" = "yes" ; then
   echo "LIBXNVME_CFLAGS=$xnvme_cflags" >> $config_host_mak
   echo "LIBXNVME_LIBS=$xnvme_libs" >> $config_host_mak
 fi
+if test "$isal" = "yes" ; then
+  output_sym "CONFIG_LIBISAL"
+fi
 if test "$libblkio" = "yes" ; then
   output_sym "CONFIG_LIBBLKIO"
   echo "LIBBLKIO_CFLAGS=$libblkio_cflags" >> $config_host_mak
index cfb2a1b18d981d2881913aa6b9550d5644d8d730..1763b1c66bce668e8f9bba1525be9932b0061e92 100644 (file)
  *
  */
 
+#ifdef CONFIG_LIBISAL
+#include <isa-l/crc.h>
+
+extern unsigned short fio_crc_t10dif(unsigned short crc,
+                                    const unsigned char *buffer,
+                                    unsigned int len)
+{
+       return crc16_t10dif(crc, buffer, len);
+}
+
+#else
 #include "crc-t10dif.h"
 
 /* Table generated using the following polynomium:
@@ -76,3 +87,5 @@ extern unsigned short fio_crc_t10dif(unsigned short crc,
 
        return crc;
 }
+
+#endif
diff --git a/fio.1 b/fio.1
index a8dc8f6c510a2563a5d01d144b1acf8c052ec6a8..c4742aa92536cee09dc6c988bef220ad3f3c2cf9 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -2263,6 +2263,10 @@ size greater than protection information size, fio will not generate or verify
 the protection information portion of metadata for write or read case
 respectively. If this is set to 0, fio generates protection information for
 write case and verifies for read case. Default: 1.
+
+For 16 bit CRC generation fio will use isa-l if available otherwise it will
+use the default slower generator.
+(see: https://github.com/intel/isa-l)
 .TP
 .BI (io_uring_cmd)pi_chk \fR=\fPstr[,str][,str]
 Controls the protection information check. This can take one or more of these