lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Tue, 14 Oct 2014 14:51:43 -0700
From:	Jim Kukunas <james.t.kukunas@...ux.intel.com>
To:	Linux Kernel <linux-kernel@...r.kernel.org>
Subject: [PATCH] lib/deflate: Replace UNALIGNED_OK w/ HAVE_EFFICIENT_UNALIGNED_ACCESS

Zlib implements a byte-by-byte and a word-by-word longest_match() string
comparision function. This implementation defaults to the slower byte-by-byte
version unless the preprocessor macro UNALIGNED_OK is defined.
Currently, nothing is hooked up to define this macro, but we do have
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, which serves the same purpose.

The exact performance improvement of the word-by-word implementation is data
dependant, but on x86 it is typically in the range of a 5-10% cycle reduction.

The code is already there, might as well use it ...

Signed-off-by: Jim Kukunas <james.t.kukunas@...ux.intel.com>
---
 lib/zlib_deflate/deflate.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c
index d20ef45..4920e51 100644
--- a/lib/zlib_deflate/deflate.c
+++ b/lib/zlib_deflate/deflate.c
@@ -570,9 +570,9 @@ static uInt longest_match(
     Pos *prev = s->prev;
     uInt wmask = s->w_mask;
 
-#ifdef UNALIGNED_OK
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
     /* Compare two bytes at a time. Note: this is not always beneficial.
-     * Try with and without -DUNALIGNED_OK to check.
+     * Try with and without -DCONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS to check.
      */
     register Byte *strend = s->window + s->strstart + MAX_MATCH - 1;
     register ush scan_start = *(ush*)scan;
@@ -606,9 +606,10 @@ static uInt longest_match(
         /* Skip to next match if the match length cannot increase
          * or if the match length is less than 2:
          */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
+#if (defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && MAX_MATCH == 258)
         /* This code assumes sizeof(unsigned short) == 2. Do not use
-         * UNALIGNED_OK if your compiler uses a different size.
+	 * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS if your compiler uses a
+	 * different size.
          */
         if (*(ush*)(match+best_len-1) != scan_end ||
             *(ush*)match != scan_start) continue;
@@ -639,7 +640,7 @@ static uInt longest_match(
         len = (MAX_MATCH - 1) - (int)(strend-scan);
         scan = strend - (MAX_MATCH-1);
 
-#else /* UNALIGNED_OK */
+#else /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
 
         if (match[best_len]   != scan_end  ||
             match[best_len-1] != scan_end1 ||
@@ -670,13 +671,13 @@ static uInt longest_match(
         len = MAX_MATCH - (int)(strend - scan);
         scan = strend - MAX_MATCH;
 
-#endif /* UNALIGNED_OK */
+#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
 
         if (len > best_len) {
             s->match_start = cur_match;
             best_len = len;
             if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
             scan_end = *(ush*)(scan+best_len-1);
 #else
             scan_end1  = scan[best_len-1];
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ