Skip to content
Snippets Groups Projects
  • Vladimir Davydov's avatar
    ccfef5fd
    memtx: ignore slab_alloc_granularity < machine word size · ccfef5fd
    Vladimir Davydov authored
    box.cfg.slab_alloc_granularity sets the min alignment used for struct
    memtx_tuple. By default, it's set to the machine word size (8 bytes
    typically), but it can be set to 4 bytes to reduce memory usage.
    
    The problem is that we add memtx tuples to a garbage collection list
    using the intrusive list pattern (basically, store a pointer to the next
    entry in the first 8 bytes of the `memtx_tuple` struct). If
    `box.cfg.slab_alloc_factor` is set to 4, the pointer will be unaligned
    while the compiler will generate the machine code assuming it is
    naturally aligned. For some architectures (x86), this works fine, but
    for others (ARM), this may result in a runtime failure.
    
    To fix this issue, we need to instruct the compiler that the list
    pointer stored in `memtx_tuple` may be unaligned.
    
    For now, let's silently ignore granularity < the machine word size,
    because we're planning to switch from lifo to stailq for memtx garbage
    collection lists, which would result in explicit compiler warnings.
    
    See #7422
    Needed for #7185
    
    NO_DOC=invisible to the user
    NO_CHANGELOG=invisible to the user
    NO_TEST=will be added later when the bug is fixed
    ccfef5fd
    History
    memtx: ignore slab_alloc_granularity < machine word size
    Vladimir Davydov authored
    box.cfg.slab_alloc_granularity sets the min alignment used for struct
    memtx_tuple. By default, it's set to the machine word size (8 bytes
    typically), but it can be set to 4 bytes to reduce memory usage.
    
    The problem is that we add memtx tuples to a garbage collection list
    using the intrusive list pattern (basically, store a pointer to the next
    entry in the first 8 bytes of the `memtx_tuple` struct). If
    `box.cfg.slab_alloc_factor` is set to 4, the pointer will be unaligned
    while the compiler will generate the machine code assuming it is
    naturally aligned. For some architectures (x86), this works fine, but
    for others (ARM), this may result in a runtime failure.
    
    To fix this issue, we need to instruct the compiler that the list
    pointer stored in `memtx_tuple` may be unaligned.
    
    For now, let's silently ignore granularity < the machine word size,
    because we're planning to switch from lifo to stailq for memtx garbage
    collection lists, which would result in explicit compiler warnings.
    
    See #7422
    Needed for #7185
    
    NO_DOC=invisible to the user
    NO_CHANGELOG=invisible to the user
    NO_TEST=will be added later when the bug is fixed