diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-04-11 22:58:40 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-04-11 22:58:40 -0700 |
| commit | b9e55f3d300af426885d7b0a13e45cd2841118a2 (patch) | |
| tree | 730db82aac3577239f75077f47274fd274ecba12 /kernel | |
| parent | 1aa6c0d1cbfcd0608a029a805952a2ecae0794da (diff) | |
[PATCH] slab: updates for per-arch alignments
From: Manfred Spraul <manfred@colorfullife.com>
Description:
Right now kmem_cache_create automatically decides about the alignment of
allocated objects. The automatic decisions are sometimes wrong:
- for some objects, it's better to keep them as small as possible to
reduce the memory usage. Ingo already added a parameter to
kmem_cache_create for the sigqueue cache, but it wasn't implemented.
- for s390, normal kmalloc must be 8-byte aligned. With debugging
enabled, the default allocation was 4-bytes. This means that s390 cannot
enable slab debugging.
- arm26 needs 1 kB aligned objects. Previously this was impossible to
generate, therefore arm has its own allocator in
arm26/machine/small_page.c
- most objects should be cache line aligned, to avoid false sharing. But
the cache line size was set at compile time, often to 128 bytes for
generic kernels. This wastes memory. The new code uses the runtime
determined cache line size instead.
- some caches want an explicit alignment. One example are the pte_chain
objects: they must find the start of the object with addr&mask. Right
now pte_chain objects are scaled to the cache line size, because that was
the only alignment that could be generated reliably.
The implementation reuses the "offset" parameter of kmem_cache_create and
now uses it to pass in the requested alignment. offset was ignored by the
current implementation, and the only user I found is sigqueue, which
intended to set the alignment.
In the long run, it might be interesting for the main tree: due to the 128
byte alignment, only 7 inodes fit into one page, with 64-byte alignment, 9
inodes - 20% memory recovered for Athlon systems.
For generic kernels running on P6 cpus (i.e. 32 byte cachelines), it means
Number of objects per page:
ext2_inode_cache: 8 instead of 7
ext3_inode_cache: 8 instead of 7
fat_inode_cache: 9 instead of 7
rpc_tasks: 24 instead of 15
tcp_tw_bucket: 40 instead of 30
arp_cache: 40 instead of 30
nfs_write_data: 9 instead of 7
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/fork.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index d2dd97e866bb..315a06125e65 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -207,11 +207,14 @@ EXPORT_SYMBOL(autoremove_wake_function); void __init fork_init(unsigned long mempages) { #ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR +#ifndef ARCH_MIN_TASKALIGN +#define ARCH_MIN_TASKALIGN 0 +#endif /* create a slab on which task_structs can be allocated */ task_struct_cachep = kmem_cache_create("task_struct", - sizeof(struct task_struct),0, - SLAB_MUST_HWCACHE_ALIGN, NULL, NULL); + sizeof(struct task_struct),ARCH_MIN_TASKALIGN, + 0, NULL, NULL); if (!task_struct_cachep) panic("fork_init(): cannot create task_struct SLAB cache"); #endif |
