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

Re: [Xen-devel] [PATCH RFC 09/23] lz4: add support for OSes that don't have asm/unaligned.h



Not sure about which version of lz4 source code is used,
so my comment may be out of context,

but for your information,
the C code provided atÂhttps://code.google.com/p/lz4/
already handles unaligned access on strict align CPU.

The method is close or the same as the one described intoÂasm/unaligned.h :
typedef struct { U16 v; } Â_PACKED U16_S;
typedef struct { U32 v; } Â_PACKED U32_S;
typedef struct { U64 v; } Â_PACKED U64_S;
typedef struct {size_t v;} _PACKED size_t_S;

but directly integrated into lz4.c source file.

The method rely on the compiler to automatically determine if the target system requires extra-caution for unaligned access, but sometimes, the compiler can be over-cautious (typically for ARM target).
Therefore, a manual override is also provided, near the top of the lz4.c source file :

/*
Â* Unaligned memory access is automatically enabled for "common" CPU, such as x86.
Â* For others CPU, such as ARM, the compiler may be more cautious, inserting unnecessary extra code to ensure aligned access property
Â* If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance
Â*/
#if defined(__ARM_FEATURE_UNALIGNED)
# Âdefine LZ4_FORCE_UNALIGNED_ACCESS 1
#endif

Hope it helps.

Regards



2014-04-22 18:40 GMT+02:00 Roger Pau Monnà <roger.pau@xxxxxxxxxx>:
On 22/04/14 17:55, Ian Campbell wrote:
> On Tue, 2014-04-22 at 16:46 +0200, Roger Pau Monnà wrote:
>> Anyway, I think this patch and the preceding one are plain wrong, what
>> we should do is completely remove the bogus dependence on
>> asm/unaligned.h, which is a Linux specific header file, and open-code
>> what we need.
>
> Am I right that for libxc's lz4 support we are using the Linux kernel's
> built in decompression code, instead of the relevant userspace library
> as we do for most other compression algorithms?

No, I don't think we are using Linux kernel's built in decompression
code, but we are using some non-standard functions, like
__get_unaligned, which are only defined in Linux's asm/unaligned.h.
IMHO, we should get rid of the include of asm/unaligned.h and code
whatever functions we need from that file in a portable way.

Roger.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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