]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common: add an aligned buffer with less alignment than a page
authorLoic Dachary <loic-201408@dachary.org>
Mon, 13 Oct 2014 14:32:18 +0000 (16:32 +0200)
committerLoic Dachary <loic-201408@dachary.org>
Tue, 21 Oct 2014 17:33:43 +0000 (10:33 -0700)
commit61543394b243a1ef4b4689ef510c77d7002d0113
tree49daa15983ac06814f724d8f085a60669ce6894f
parent681dad8907754a60e6c8d6e6608079768954a6a5
common: add an aligned buffer with less alignment than a page

SIMD optimized erasure code computation needs aligned memory. Buffers
aligned to a page boundary are not needed though. The buffers used
for the erasure code computation are typical smaller than a page.

The typical alignment requirements SIMD operations are 16 bytes for
SSE2 and NEON and 32 bytes for AVX/AVX2.

Add new prototypes with an align argument, similar to the one enforcing
page alignment. The implementation is exactly the same, except for the
align parameter. The page alignment method are then implemented as calls
to the more generic methods.

The align parameter is an unsigned (same type as CEPH_PAGE_SIZE). The
CEPH_PAGE_MASK value ( ~(CEPH_PAGE_SIZE - 1) ) was only used as
~CEPH_PAGE_MASK, i.e. equivalent of (CEPH_PAGE_SIZE - 1) once the double
~~ is reduced. These occurrence are replaced with (align - 1). The type
of CEPH_PAGE_MASK is an unsigned long which probably because it was
~(CEPH_PAGE_SIZE). When using (align - 1) as a mask for both
CEPH_PAGE_SIZE and SIMD alignment there is no need to use an unsigned
long because there is no risk of overflowing the unsigned value.

The CYGWIN specific code is also modified but not tested.

Unit tests are added for the new methods.

Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Loic Dachary <loic-201408@dachary.org>
src/common/buffer.cc
src/include/buffer.h
src/test/bufferlist.cc