kmalloc(): use macros to define size alignment
This commit is contained in:
12
kernel/mem.c
12
kernel/mem.c
@@ -1015,6 +1015,9 @@ void kmalloc_consolidate_free_list(void)
|
|||||||
ihk_mc_spinlock_unlock(&cpu_local_var(remote_free_list_lock), irqflags);
|
ihk_mc_spinlock_unlock(&cpu_local_var(remote_free_list_lock), irqflags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define KMALLOC_MIN_SHIFT (5)
|
||||||
|
#define KMALLOC_MIN_SIZE (1 << KMALLOC_TRACK_HASH_SHIFT)
|
||||||
|
#define KMALLOC_MIN_MASK (KMALLOC_MIN_SIZE - 1)
|
||||||
|
|
||||||
/* Actual low-level allocation routines */
|
/* Actual low-level allocation routines */
|
||||||
static void *___kmalloc(int size, enum ihk_mc_ap_flag flag)
|
static void *___kmalloc(int size, enum ihk_mc_ap_flag flag)
|
||||||
@@ -1024,11 +1027,10 @@ static void *___kmalloc(int size, enum ihk_mc_ap_flag flag)
|
|||||||
int npages;
|
int npages;
|
||||||
unsigned long kmalloc_irq_flags = cpu_disable_interrupt_save();
|
unsigned long kmalloc_irq_flags = cpu_disable_interrupt_save();
|
||||||
|
|
||||||
/*
|
/* KMALLOC_MIN_SIZE bytes aligned size. */
|
||||||
* 32 bytes aligned size, as this leaves us at cache line boundary
|
if (size & KMALLOC_MIN_MASK) {
|
||||||
* (including the header) even for the smallest allocations
|
size = ((size + KMALLOC_MIN_SIZE - 1) & ~(KMALLOC_MIN_MASK));
|
||||||
*/
|
}
|
||||||
if ((size % 32) != 0) size = ((size + 31) & ~((int)32-1));
|
|
||||||
|
|
||||||
chunk = NULL;
|
chunk = NULL;
|
||||||
/* Find a chunk that is big enough */
|
/* Find a chunk that is big enough */
|
||||||
|
|||||||
Reference in New Issue
Block a user