[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.13] lz4: pull out constant tables



commit 8ba4cd953c193957d51b9ff24ffa5c891e8de0fe
Author:     Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
AuthorDate: Mon Dec 9 15:08:30 2019 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Dec 9 15:08:30 2019 +0100

    lz4: pull out constant tables
    
    There's no reason to allocate the dec{32,64}table on the stack; it
    just wastes a bunch of instructions setting them up and, of course,
    also consumes quite a bit of stack. Using size_t for such small
    integers is a little excessive.
    
    $ scripts/bloat-o-meter /tmp/built-in.o lib/built-in.o
    add/remove: 2/2 grow/shrink: 2/0 up/down: 1304/-1548 (-244)
    function                                     old     new   delta
    lz4_decompress_unknownoutputsize              55     718    +663
    lz4_decompress                                55     632    +577
    dec64table                                     -      32     +32
    dec32table                                     -      32     +32
    lz4_uncompress                               747       -    -747
    lz4_uncompress_unknownoutputsize             801       -    -801
    
    The now inlined lz4_uncompress functions used to have a stack
    footprint of 176 bytes (according to -fstack-usage); their inlinees
    have increased their stack use from 32 bytes to 48 and 80 bytes,
    respectively.
    
    Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
    [Linux commit bea2b592fd18eb8ffa3fc4ad380610632d03a38f]
    
    Use {,u}int8_t instead of plain "int" for the tables.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Release-acked-by: Juergen Gross <jgross@xxxxxxxx>
    master commit: fef4eb01bc53f0d44dff44579b7a6bbc31d3ff5d
    master date: 2019-12-09 14:01:56 +0100
---
 xen/common/lz4/decompress.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/xen/common/lz4/decompress.c b/xen/common/lz4/decompress.c
index e8636e193a..938c7009ad 100644
--- a/xen/common/lz4/decompress.c
+++ b/xen/common/lz4/decompress.c
@@ -39,6 +39,11 @@
 
 #include "defs.h"
 
+static const uint8_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0};
+#if LZ4_ARCH64
+static const int8_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3};
+#endif
+
 #if defined(__XEN__) || defined(__MINIOS__)
 
 static int INIT lz4_uncompress(const unsigned char *source, unsigned char 
*dest,
@@ -51,10 +56,6 @@ static int INIT lz4_uncompress(const unsigned char *source, 
unsigned char *dest,
        BYTE *cpy;
        unsigned token;
        size_t length;
-       size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0};
-#if LZ4_ARCH64
-       size_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3};
-#endif
 
        while (1) {
 
@@ -109,7 +110,7 @@ static int INIT lz4_uncompress(const unsigned char *source, 
unsigned char *dest,
                /* copy repeated sequence */
                if (unlikely((op - ref) < STEPSIZE)) {
 #if LZ4_ARCH64
-                       size_t dec64 = dec64table[op - ref];
+                       int dec64 = dec64table[op - ref];
 #else
                        const int dec64 = 0;
 #endif
@@ -175,11 +176,6 @@ static int lz4_uncompress_unknownoutputsize(const unsigned 
char *source,
        BYTE * const oend = op + maxoutputsize;
        BYTE *cpy;
 
-       size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0};
-#if LZ4_ARCH64
-       size_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3};
-#endif
-
        /* Main Loop */
        while (ip < iend) {
 
@@ -245,7 +241,7 @@ static int lz4_uncompress_unknownoutputsize(const unsigned 
char *source,
                /* copy repeated sequence */
                if (unlikely((op - ref) < STEPSIZE)) {
 #if LZ4_ARCH64
-                       size_t dec64 = dec64table[op - ref];
+                       int dec64 = dec64table[op - ref];
 #else
                        const int dec64 = 0;
 #endif
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.13

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.