diff options
author | Zheng Da <zhengda1936@gmail.com> | 2010-05-28 12:20:06 +0200 |
---|---|---|
committer | Zheng Da <zhengda1936@gmail.com> | 2010-05-28 12:20:06 +0200 |
commit | ff4ec384e4688dfb09286eef763a173ef54ce80a (patch) | |
tree | a04da170fe5bea86d3e03d51fa09849a82dfbfab /libddekit | |
parent | c49105c8dca3328f6d01c43f7ed2fc654782d492 (diff) |
memory from linux_kmalloc is aligned with cache line size.
It's an ugly fix.
Diffstat (limited to 'libddekit')
-rw-r--r-- | libddekit/kmem.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libddekit/kmem.c b/libddekit/kmem.c index cea4d370..570c1f53 100644 --- a/libddekit/kmem.c +++ b/libddekit/kmem.c @@ -49,8 +49,9 @@ extern int printf (const char *, ...); /* round up the size at alignment of page size. */ #define ROUND_UP(size) ((size) + __vm_page_size - 1) & (~(__vm_page_size - 1)) +#define CACHE_LINE 32 /* Mininum amount that linux_kmalloc will allocate. */ -#define MIN_ALLOC 12 +#define MIN_ALLOC CACHE_LINE #ifndef NBPW #define NBPW 32 @@ -61,6 +62,7 @@ struct blkhdr { unsigned short free; /* 1 if block is free */ unsigned short size; /* size of block */ + char stuffing[28]; }; /* This structure heads a page allocated by linux_kmalloc. */ @@ -68,6 +70,7 @@ struct pagehdr { unsigned size; /* size (multiple of PAGE_SIZE) */ struct pagehdr *next; /* next header in list */ + char stuffing[24]; }; /* This structure describes a memory chunk. */ @@ -263,7 +266,7 @@ linux_kmalloc (unsigned int size, int priority) if (size < MIN_ALLOC) size = MIN_ALLOC; else - size = (size + sizeof (int) - 1) & ~(sizeof (int) - 1); + size = (size + CACHE_LINE - 1) & ~(CACHE_LINE - 1); mutex_lock (&mem_lock); |