generic: round up object allocations to possible cache lines

This commit is contained in:
Thomas Schoebel-Theuer 2022-11-28 15:45:31 +01:00
parent b05dddc640
commit b4778909a2
2 changed files with 11 additions and 1 deletions

View File

@ -367,7 +367,7 @@ struct generic_object *generic_alloc(struct generic_brick *brick, struct generic
void *data;
int object_size;
int aspect_nr_max;
int total_size;
unsigned total_size;
int hint_size;
CHECK_PTR_NULL(object_type, err);
@ -382,6 +382,7 @@ struct generic_object *generic_alloc(struct generic_brick *brick, struct generic
} else { // usually happens only at the first time
object_layout->size_hint = total_size;
}
total_size = BRICK_ALIGN(total_size);
data = brick_zmem_alloc(total_size);
if (!data)

View File

@ -48,6 +48,15 @@
#define MAX_BRICK_TYPES 64
#define BRICK_ALIGN(object_size) \
((object_size) < 32 * 2 ? \
(DIV_ROUND_UP((object_size), 32) * 32) : \
((object_size) < 128 * 2 ? \
(DIV_ROUND_UP((object_size), 128) * 128) : \
((object_size) < 512 * 2 ? \
(DIV_ROUND_UP((object_size), 512) * 512) : \
(DIV_ROUND_UP((object_size), 4096) * 4096))))
#define SAFE_STR(str) ((str) ? (str) : "NULL")
#define brick_msleep(msecs) _brick_msleep(msecs, false)