[ovs-dev] [PATCH] util: Add PADDED_MEMBERS_CACHELINE_MARKER macro to mark cachelines.

Ben Pfaff blp at ovn.org
Thu Aug 3 18:34:57 UTC 2017


On Tue, Jul 25, 2017 at 05:14:43AM +0100, Bhanuprakash Bodireddy wrote:
> PADDED_MEMBERS_CACHELINE_MARKER macro introduces a way to mark
> cachelines.
> 
> This macro expands to an anonymous union containing cacheline marker,
> members in nested anonymous structure, followed by array of bytes that
> is multiple of UNIT bytes.
> 
> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy at intel.com>

Applied, thanks!  I had to add a C++ acceptable alternative but it was
not difficult:

#ifndef __cplusplus
#define PADDED_MEMBERS_CACHELINE_MARKER(UNIT, CACHELINE, MEMBERS)   \
    union {                                                         \
        OVS_CACHE_LINE_MARKER CACHELINE;                            \
        struct { MEMBERS };                                         \
        uint8_t PAD_ID[ROUND_UP(sizeof(struct { MEMBERS }), UNIT)]; \
    }
#else
#define PADDED_MEMBERS_CACHELINE_MARKER(UNIT, CACHELINE, MEMBERS)   \
    union {                                                         \
        OVS_CACHE_LINE_MARKER CACHELINE;                            \
        struct { MEMBERS };                                         \
        struct { MEMBERS } named_member__;                          \
        uint8_t PAD_ID[ROUND_UP(sizeof named_member__, UNIT)];      \
    }
#endif


More information about the dev mailing list