[PATCH] PM: align buffers for LZO compression

From: Markus F.X.J. Oberhumer
Date: Fri Feb 22 2013 - 02:51:05 EST


Hi,

for performance reasons I'd strongly suggest that you explicitly align all
buffers passed to the LZO compress and decompress functions.

Below is a small (and completely untested!) patch, but I think you
get the idea.

BTW, it might be even more beneficial (esp. for NUMA systems) to align *all*
individual unc/cmp/wrk pointers to a multiple of the PAGE_SIZE, but this would
require some code restructuring.

Cheers,
Markus

completely untested patch:

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 7c33ed2..7af4293 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -532,9 +532,9 @@ struct cmp_data {
wait_queue_head_t done; /* compression done */
size_t unc_len; /* uncompressed length */
size_t cmp_len; /* compressed length */
- unsigned char unc[LZO_UNC_SIZE]; /* uncompressed buffer */
- unsigned char cmp[LZO_CMP_SIZE]; /* compressed buffer */
- unsigned char wrk[LZO1X_1_MEM_COMPRESS]; /* compression workspace */
+ unsigned char unc[LZO_UNC_SIZE] ____cacheline_aligned; /* uncompressed buffer */
+ unsigned char cmp[LZO_CMP_SIZE] ____cacheline_aligned; /* compressed buffer */
+ unsigned char wrk[LZO1X_1_MEM_COMPRESS] ____cacheline_aligned; /* compression workspace */
};

/**
@@ -1021,8 +1021,8 @@ struct dec_data {
wait_queue_head_t done; /* decompression done */
size_t unc_len; /* uncompressed length */
size_t cmp_len; /* compressed length */
- unsigned char unc[LZO_UNC_SIZE]; /* uncompressed buffer */
- unsigned char cmp[LZO_CMP_SIZE]; /* compressed buffer */
+ unsigned char unc[LZO_UNC_SIZE] ____cacheline_aligned; /* uncompressed buffer */
+ unsigned char cmp[LZO_CMP_SIZE] ____cacheline_aligned; /* compressed buffer */
};

/**


Signed-off-by: Markus F.X.J. Oberhumer <markus@xxxxxxxxxxxxx>

--
Markus Oberhumer, <markus@xxxxxxxxxxxxx>, http://www.oberhumer.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/