Commit a3e754c2 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] slab: allow arch override for kmem_bufctl_t

From: Manfred Spraul <manfred@colorfullife.com>

The slab allocator keeps track of the free objects in a slab with a linked
list of integers (typedef'ed to kmem_bufctl_t).  Right now unsigned int is
used for kmem_bufctl_t, i.e.  4 bytes per-object overhead.

The attached patch implements a per-arch definition of for this type:
Theoretically, unsigned short is sufficient for kmem_bufctl_t and this would
reduce the per-object overhead to 2 bytes.  But some archs cannot operate on
16-bit values efficiently, thus it's not possible to switch everyone to
ushort.

The chosen types are a result of dicussions with the various arch maintainers.
parent 897d49be
......@@ -56,6 +56,8 @@ typedef unsigned long u64;
typedef u64 dma_addr_t;
typedef u64 dma64_addr_t;
typedef unsigned short kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _ALPHA_TYPES_H */
......@@ -52,6 +52,8 @@ typedef unsigned long long u64;
typedef u32 dma_addr_t;
typedef u32 dma64_addr_t;
typedef unsigned int kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -52,6 +52,8 @@ typedef unsigned long long u64;
typedef u32 dma_addr_t;
typedef u32 dma64_addr_t;
typedef unsigned int kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -51,6 +51,8 @@ typedef unsigned long long u64;
typedef u32 dma_addr_t;
typedef unsigned int kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -58,6 +58,8 @@ typedef u32 dma_addr_t;
#define HAVE_SECTOR_T
typedef u64 sector_t;
typedef unsigned int kmem_bufctl_t;
#endif /* __KERNEL__ */
#endif /* __ASSEMBLY__ */
......
......@@ -63,6 +63,8 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
typedef unsigned short kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -67,6 +67,8 @@ typedef __u64 u64;
typedef u64 dma_addr_t;
typedef unsigned short kmem_bufctl_t;
# endif /* __KERNEL__ */
#endif /* !__ASSEMBLY__ */
......
......@@ -60,6 +60,8 @@ typedef unsigned long long u64;
typedef u32 dma_addr_t;
typedef u32 dma64_addr_t;
typedef unsigned short kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -99,6 +99,8 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
typedef unsigned short kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -56,6 +56,8 @@ typedef unsigned long long u64;
typedef u32 dma_addr_t;
typedef u64 dma64_addr_t;
typedef unsigned int kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -62,6 +62,8 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
typedef unsigned int kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -73,6 +73,8 @@ typedef struct {
} func_descr_t;
#endif /* __ASSEMBLY__ */
typedef unsigned int kmem_bufctl_t;
#endif /* __KERNEL__ */
#endif /* _PPC64_TYPES_H */
......@@ -93,6 +93,8 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
typedef unsigned int kmem_bufctl_t;
#endif /* ! __s390x__ */
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -58,6 +58,8 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
typedef unsigned int kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -54,6 +54,8 @@ typedef unsigned long long u64;
typedef u32 dma_addr_t;
typedef u32 dma64_addr_t;
typedef unsigned short kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -56,6 +56,8 @@ typedef unsigned long u64;
typedef u32 dma_addr_t;
typedef u64 dma64_addr_t;
typedef unsigned short kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -59,6 +59,8 @@ typedef unsigned long long u64;
typedef u32 dma_addr_t;
typedef unsigned int kmem_bufctl_t;
#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -51,6 +51,8 @@ typedef u64 dma_addr_t;
typedef u64 sector_t;
#define HAVE_SECTOR_T
typedef unsigned short kmem_bufctl_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
......
......@@ -161,10 +161,9 @@
* is less than 512 (PAGE_SIZE<<3), but greater than 256.
*/
#define BUFCTL_END 0xffffFFFF
#define BUFCTL_FREE 0xffffFFFE
#define SLAB_LIMIT 0xffffFFFD
typedef unsigned int kmem_bufctl_t;
#define BUFCTL_END (((kmem_bufctl_t)(~0U))-0)
#define BUFCTL_FREE (((kmem_bufctl_t)(~0U))-1)
#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-2)
/* Max number of objs-per-slab for caches which use off-slab slabs.
* Needed to avoid a possible looping condition in cache_grow().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment