From d7ba004e30589a74245fd5ecf24027d1d4561d02 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 4 Jan 2014 17:29:25 +0100 Subject: [PATCH] Some minor comment/format changes. --- raid/memory.h | 12 ++++++++---- raid/x86z.c | 9 ++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/raid/memory.h b/raid/memory.h index a92512c1..ff617a7a 100644 --- a/raid/memory.h +++ b/raid/memory.h @@ -23,13 +23,17 @@ #define RAID_MALLOC_ALIGN 256 /** - * Memory displacement to avoid cache collisions on contiguous blocks, + * Memory displacement to avoid cache address sharing on contiguous blocks, * used by raid_malloc_vector(). * * When allocating a sequence of blocks with a size of power of 2, - * there is the risk that the start of each block is mapped into the same - * cache line or prefetching prediction, resulting in collisions if you - * access all the blocks in parallel, from the start to the end. + * there is the risk that the addresses of each block are mapped into the + * same cache line and prefetching predictor, resulting in a lot of cache + * sharing if you access all the blocks in parallel, from the start to the + * end. + * + * To avoid this effect, it's better if all the blocks are allocated + * with a fixed displacement trying to reduce the cache addresses sharing. * * The selected value was choosen empirically with some speed tests * with 8/12/16/20/24 data buffers of 256 KB. diff --git a/raid/x86z.c b/raid/x86z.c index 4c8567ba..9cb1ca94 100644 --- a/raid/x86z.c +++ b/raid/x86z.c @@ -20,9 +20,12 @@ static const struct gfzconst16 { uint8_t half[16]; uint8_t low7[16]; } gfzconst16 __aligned(64) = { - { 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d }, - { 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e }, - { 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f } + { 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, + 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d }, + { 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, + 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e }, + { 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f } }; #endif