vm: add alignment parameter to cache allocator
caches with object size N, where N is a power of two, will naturally align their objects on N-byte boundaries. all other caches will align to an 8-byte boundary by default.
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
#define SOCKS_UTIL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern void data_size_to_string(size_t value, char *out, size_t outsz);
|
||||
static inline bool power_of_2(size_t x) { return (x > 0 && (x & (x - 1)) == 0); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -137,9 +137,11 @@ typedef struct vm_cache {
|
||||
unsigned int c_obj_size;
|
||||
/* combined size of vm_slab_t and the freelist */
|
||||
unsigned int c_hdr_size;
|
||||
/* power of 2 alignment for objects returned from the cache */
|
||||
unsigned int c_align;
|
||||
/* offset from one object to the next in a slab.
|
||||
this may be different from c_obj_size as
|
||||
we enforce a 16-byte alignment on allocated objects */
|
||||
this may be different from c_obj_size depending
|
||||
on the alignment settings for this cache. */
|
||||
unsigned int c_stride;
|
||||
/* size of page used for slabs */
|
||||
unsigned int c_page_order;
|
||||
|
||||
Reference in New Issue
Block a user