summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ecryptfs/main.c2
-rw-r--r--fs/xfs/kmem.h2
-rw-r--r--include/linux/kasan.h4
-rw-r--r--include/linux/kmemleak.h8
-rw-r--r--include/linux/slab.h60
-rw-r--r--include/linux/slab_def.h2
-rw-r--r--include/linux/slub_def.h2
-rw-r--r--include/linux/types.h1
-rw-r--r--include/net/sock.h2
-rw-r--r--mm/kasan/kasan.c2
-rw-r--r--mm/slab.c23
-rw-r--r--mm/slab.h26
-rw-r--r--mm/slab_common.c16
-rw-r--r--mm/slob.c2
-rw-r--r--mm/slub.c26
15 files changed, 97 insertions, 81 deletions
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 6b801186baa5..25aeaa7328ba 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -660,7 +660,7 @@ static struct ecryptfs_cache_info {
660 struct kmem_cache **cache; 660 struct kmem_cache **cache;
661 const char *name; 661 const char *name;
662 size_t size; 662 size_t size;
663 unsigned long flags; 663 slab_flags_t flags;
664 void (*ctor)(void *obj); 664 void (*ctor)(void *obj);
665} ecryptfs_cache_infos[] = { 665} ecryptfs_cache_infos[] = {
666 { 666 {
diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
index 758f37ac5ad3..4b87472f35bc 100644
--- a/fs/xfs/kmem.h
+++ b/fs/xfs/kmem.h
@@ -104,7 +104,7 @@ kmem_zone_init(int size, char *zone_name)
104} 104}
105 105
106static inline kmem_zone_t * 106static inline kmem_zone_t *
107kmem_zone_init_flags(int size, char *zone_name, unsigned long flags, 107kmem_zone_init_flags(int size, char *zone_name, slab_flags_t flags,
108 void (*construct)(void *)) 108 void (*construct)(void *))
109{ 109{
110 return kmem_cache_create(zone_name, size, 0, flags, construct); 110 return kmem_cache_create(zone_name, size, 0, flags, construct);
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index 5017269e3f04..e3eb834c9a35 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -46,7 +46,7 @@ void kasan_alloc_pages(struct page *page, unsigned int order);
46void kasan_free_pages(struct page *page, unsigned int order); 46void kasan_free_pages(struct page *page, unsigned int order);
47 47
48void kasan_cache_create(struct kmem_cache *cache, size_t *size, 48void kasan_cache_create(struct kmem_cache *cache, size_t *size,
49 unsigned long *flags); 49 slab_flags_t *flags);
50void kasan_cache_shrink(struct kmem_cache *cache); 50void kasan_cache_shrink(struct kmem_cache *cache);
51void kasan_cache_shutdown(struct kmem_cache *cache); 51void kasan_cache_shutdown(struct kmem_cache *cache);
52 52
@@ -95,7 +95,7 @@ static inline void kasan_free_pages(struct page *page, unsigned int order) {}
95 95
96static inline void kasan_cache_create(struct kmem_cache *cache, 96static inline void kasan_cache_create(struct kmem_cache *cache,
97 size_t *size, 97 size_t *size,
98 unsigned long *flags) {} 98 slab_flags_t *flags) {}
99static inline void kasan_cache_shrink(struct kmem_cache *cache) {} 99static inline void kasan_cache_shrink(struct kmem_cache *cache) {}
100static inline void kasan_cache_shutdown(struct kmem_cache *cache) {} 100static inline void kasan_cache_shutdown(struct kmem_cache *cache) {}
101 101
diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
index 590343f6c1b1..5ac416e2d339 100644
--- a/include/linux/kmemleak.h
+++ b/include/linux/kmemleak.h
@@ -48,14 +48,14 @@ extern void kmemleak_not_leak_phys(phys_addr_t phys) __ref;
48extern void kmemleak_ignore_phys(phys_addr_t phys) __ref; 48extern void kmemleak_ignore_phys(phys_addr_t phys) __ref;
49 49
50static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, 50static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
51 int min_count, unsigned long flags, 51 int min_count, slab_flags_t flags,
52 gfp_t gfp) 52 gfp_t gfp)
53{ 53{
54 if (!(flags & SLAB_NOLEAKTRACE)) 54 if (!(flags & SLAB_NOLEAKTRACE))
55 kmemleak_alloc(ptr, size, min_count, gfp); 55 kmemleak_alloc(ptr, size, min_count, gfp);
56} 56}
57 57
58static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags) 58static inline void kmemleak_free_recursive(const void *ptr, slab_flags_t flags)
59{ 59{
60 if (!(flags & SLAB_NOLEAKTRACE)) 60 if (!(flags & SLAB_NOLEAKTRACE))
61 kmemleak_free(ptr); 61 kmemleak_free(ptr);
@@ -76,7 +76,7 @@ static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count,
76{ 76{
77} 77}
78static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, 78static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
79 int min_count, unsigned long flags, 79 int min_count, slab_flags_t flags,
80 gfp_t gfp) 80 gfp_t gfp)
81{ 81{
82} 82}
@@ -94,7 +94,7 @@ static inline void kmemleak_free(const void *ptr)
94static inline void kmemleak_free_part(const void *ptr, size_t size) 94static inline void kmemleak_free_part(const void *ptr, size_t size)
95{ 95{
96} 96}
97static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags) 97static inline void kmemleak_free_recursive(const void *ptr, slab_flags_t flags)
98{ 98{
99} 99}
100static inline void kmemleak_free_percpu(const void __percpu *ptr) 100static inline void kmemleak_free_percpu(const void __percpu *ptr)
diff --git a/include/linux/slab.h b/include/linux/slab.h
index af5aa65c7c18..0c4c579f52ed 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -21,13 +21,20 @@
21 * Flags to pass to kmem_cache_create(). 21 * Flags to pass to kmem_cache_create().
22 * The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set. 22 * The ones marked DEBUG are only valid if CONFIG_DEBUG_SLAB is set.
23 */ 23 */
24#define SLAB_CONSISTENCY_CHECKS 0x00000100UL /* DEBUG: Perform (expensive) checks on alloc/free */ 24/* DEBUG: Perform (expensive) checks on alloc/free */
25#define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */ 25#define SLAB_CONSISTENCY_CHECKS ((slab_flags_t __force)0x00000100UL)
26#define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */ 26/* DEBUG: Red zone objs in a cache */
27#define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */ 27#define SLAB_RED_ZONE ((slab_flags_t __force)0x00000400UL)
28#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ 28/* DEBUG: Poison objects */
29#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ 29#define SLAB_POISON ((slab_flags_t __force)0x00000800UL)
30#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ 30/* Align objs on cache lines */
31#define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000UL)
32/* Use GFP_DMA memory */
33#define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000UL)
34/* DEBUG: Store the last owner for bug hunting */
35#define SLAB_STORE_USER ((slab_flags_t __force)0x00010000UL)
36/* Panic if kmem_cache_create() fails */
37#define SLAB_PANIC ((slab_flags_t __force)0x00040000UL)
31/* 38/*
32 * SLAB_TYPESAFE_BY_RCU - **WARNING** READ THIS! 39 * SLAB_TYPESAFE_BY_RCU - **WARNING** READ THIS!
33 * 40 *
@@ -65,44 +72,51 @@
65 * 72 *
66 * Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU. 73 * Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU.
67 */ 74 */
68#define SLAB_TYPESAFE_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ 75/* Defer freeing slabs to RCU */
69#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ 76#define SLAB_TYPESAFE_BY_RCU ((slab_flags_t __force)0x00080000UL)
70#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ 77/* Spread some memory over cpuset */
78#define SLAB_MEM_SPREAD ((slab_flags_t __force)0x00100000UL)
79/* Trace allocations and frees */
80#define SLAB_TRACE ((slab_flags_t __force)0x00200000UL)
71 81
72/* Flag to prevent checks on free */ 82/* Flag to prevent checks on free */
73#ifdef CONFIG_DEBUG_OBJECTS 83#ifdef CONFIG_DEBUG_OBJECTS
74# define SLAB_DEBUG_OBJECTS 0x00400000UL 84# define SLAB_DEBUG_OBJECTS ((slab_flags_t __force)0x00400000UL)
75#else 85#else
76# define SLAB_DEBUG_OBJECTS 0x00000000UL 86# define SLAB_DEBUG_OBJECTS ((slab_flags_t __force)0x00000000UL)
77#endif 87#endif
78 88
79#define SLAB_NOLEAKTRACE 0x00800000UL /* Avoid kmemleak tracing */ 89/* Avoid kmemleak tracing */
90#define SLAB_NOLEAKTRACE ((slab_flags_t __force)0x00800000UL)
80 91
81/* Don't track use of uninitialized memory */ 92/* Don't track use of uninitialized memory */
82#ifdef CONFIG_KMEMCHECK 93#ifdef CONFIG_KMEMCHECK
83# define SLAB_NOTRACK 0x01000000UL 94# define SLAB_NOTRACK ((slab_flags_t __force)0x01000000UL)
84#else 95#else
85# define SLAB_NOTRACK 0x00000000UL 96# define SLAB_NOTRACK ((slab_flags_t __force)0x00000000UL)
86#endif 97#endif
98/* Fault injection mark */
87#ifdef CONFIG_FAILSLAB 99#ifdef CONFIG_FAILSLAB
88# define SLAB_FAILSLAB 0x02000000UL /* Fault injection mark */ 100# define SLAB_FAILSLAB ((slab_flags_t __force)0x02000000UL)
89#else 101#else
90# define SLAB_FAILSLAB 0x00000000UL 102# define SLAB_FAILSLAB ((slab_flags_t __force)0x00000000UL)
91#endif 103#endif
104/* Account to memcg */
92#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) 105#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
93# define SLAB_ACCOUNT 0x04000000UL /* Account to memcg */ 106# define SLAB_ACCOUNT ((slab_flags_t __force)0x04000000UL)
94#else 107#else
95# define SLAB_ACCOUNT 0x00000000UL 108# define SLAB_ACCOUNT ((slab_flags_t __force)0x00000000UL)
96#endif 109#endif
97 110
98#ifdef CONFIG_KASAN 111#ifdef CONFIG_KASAN
99#define SLAB_KASAN 0x08000000UL 112#define SLAB_KASAN ((slab_flags_t __force)0x08000000UL)
100#else 113#else
101#define SLAB_KASAN 0x00000000UL 114#define SLAB_KASAN ((slab_flags_t __force)0x00000000UL)
102#endif 115#endif
103 116
104/* The following flags affect the page allocator grouping pages by mobility */ 117/* The following flags affect the page allocator grouping pages by mobility */
105#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ 118/* Objects are reclaimable */
119#define SLAB_RECLAIM_ACCOUNT ((slab_flags_t __force)0x00020000UL)
106#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ 120#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */
107/* 121/*
108 * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. 122 * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
@@ -128,7 +142,7 @@ void __init kmem_cache_init(void);
128bool slab_is_available(void); 142bool slab_is_available(void);
129 143
130struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, 144struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
131 unsigned long, 145 slab_flags_t,
132 void (*)(void *)); 146 void (*)(void *));
133void kmem_cache_destroy(struct kmem_cache *); 147void kmem_cache_destroy(struct kmem_cache *);
134int kmem_cache_shrink(struct kmem_cache *); 148int kmem_cache_shrink(struct kmem_cache *);
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 8f7d2b1656d2..072e46e9e1d5 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -20,7 +20,7 @@ struct kmem_cache {
20 struct reciprocal_value reciprocal_buffer_size; 20 struct reciprocal_value reciprocal_buffer_size;
21/* 2) touched by every alloc & free from the backend */ 21/* 2) touched by every alloc & free from the backend */
22 22
23 unsigned int flags; /* constant flags */ 23 slab_flags_t flags; /* constant flags */
24 unsigned int num; /* # of objs per slab */ 24 unsigned int num; /* # of objs per slab */
25 25
26/* 3) cache_grow/shrink */ 26/* 3) cache_grow/shrink */
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 39fa09bcde23..0adae162dc8f 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -82,7 +82,7 @@ struct kmem_cache_order_objects {
82struct kmem_cache { 82struct kmem_cache {
83 struct kmem_cache_cpu __percpu *cpu_slab; 83 struct kmem_cache_cpu __percpu *cpu_slab;
84 /* Used for retriving partial slabs etc */ 84 /* Used for retriving partial slabs etc */
85 unsigned long flags; 85 slab_flags_t flags;
86 unsigned long min_partial; 86 unsigned long min_partial;
87 int size; /* The size of an object including meta data */ 87 int size; /* The size of an object including meta data */
88 int object_size; /* The size of an object without meta data */ 88 int object_size; /* The size of an object without meta data */
diff --git a/include/linux/types.h b/include/linux/types.h
index 34fce54e4f1b..732b52c2eae4 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -156,6 +156,7 @@ typedef u32 dma_addr_t;
156#endif 156#endif
157 157
158typedef unsigned __bitwise gfp_t; 158typedef unsigned __bitwise gfp_t;
159typedef unsigned long __bitwise slab_flags_t;
159typedef unsigned __bitwise fmode_t; 160typedef unsigned __bitwise fmode_t;
160 161
161#ifdef CONFIG_PHYS_ADDR_T_64BIT 162#ifdef CONFIG_PHYS_ADDR_T_64BIT
diff --git a/include/net/sock.h b/include/net/sock.h
index a6b9a8d1a6df..c577286dbffb 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1105,7 +1105,7 @@ struct proto {
1105 1105
1106 struct kmem_cache *slab; 1106 struct kmem_cache *slab;
1107 unsigned int obj_size; 1107 unsigned int obj_size;
1108 int slab_flags; 1108 slab_flags_t slab_flags;
1109 1109
1110 struct percpu_counter *orphan_count; 1110 struct percpu_counter *orphan_count;
1111 1111
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 6f319fb81718..405bba487df5 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -337,7 +337,7 @@ static size_t optimal_redzone(size_t object_size)
337} 337}
338 338
339void kasan_cache_create(struct kmem_cache *cache, size_t *size, 339void kasan_cache_create(struct kmem_cache *cache, size_t *size,
340 unsigned long *flags) 340 slab_flags_t *flags)
341{ 341{
342 int redzone_adjust; 342 int redzone_adjust;
343 int orig_size = *size; 343 int orig_size = *size;
diff --git a/mm/slab.c b/mm/slab.c
index 0c6468c07b01..19b1b9f99819 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -252,8 +252,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
252 MAKE_LIST((cachep), (&(ptr)->slabs_free), slabs_free, nodeid); \ 252 MAKE_LIST((cachep), (&(ptr)->slabs_free), slabs_free, nodeid); \
253 } while (0) 253 } while (0)
254 254
255#define CFLGS_OBJFREELIST_SLAB (0x40000000UL) 255#define CFLGS_OBJFREELIST_SLAB ((slab_flags_t __force)0x40000000UL)
256#define CFLGS_OFF_SLAB (0x80000000UL) 256#define CFLGS_OFF_SLAB ((slab_flags_t __force)0x80000000UL)
257#define OBJFREELIST_SLAB(x) ((x)->flags & CFLGS_OBJFREELIST_SLAB) 257#define OBJFREELIST_SLAB(x) ((x)->flags & CFLGS_OBJFREELIST_SLAB)
258#define OFF_SLAB(x) ((x)->flags & CFLGS_OFF_SLAB) 258#define OFF_SLAB(x) ((x)->flags & CFLGS_OFF_SLAB)
259 259
@@ -441,7 +441,7 @@ static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep)
441 * Calculate the number of objects and left-over bytes for a given buffer size. 441 * Calculate the number of objects and left-over bytes for a given buffer size.
442 */ 442 */
443static unsigned int cache_estimate(unsigned long gfporder, size_t buffer_size, 443static unsigned int cache_estimate(unsigned long gfporder, size_t buffer_size,
444 unsigned long flags, size_t *left_over) 444 slab_flags_t flags, size_t *left_over)
445{ 445{
446 unsigned int num; 446 unsigned int num;
447 size_t slab_size = PAGE_SIZE << gfporder; 447 size_t slab_size = PAGE_SIZE << gfporder;
@@ -1759,7 +1759,7 @@ static void slabs_destroy(struct kmem_cache *cachep, struct list_head *list)
1759 * towards high-order requests, this should be changed. 1759 * towards high-order requests, this should be changed.
1760 */ 1760 */
1761static size_t calculate_slab_order(struct kmem_cache *cachep, 1761static size_t calculate_slab_order(struct kmem_cache *cachep,
1762 size_t size, unsigned long flags) 1762 size_t size, slab_flags_t flags)
1763{ 1763{
1764 size_t left_over = 0; 1764 size_t left_over = 0;
1765 int gfporder; 1765 int gfporder;
@@ -1886,8 +1886,8 @@ static int __ref setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
1886 return 0; 1886 return 0;
1887} 1887}
1888 1888
1889unsigned long kmem_cache_flags(unsigned long object_size, 1889slab_flags_t kmem_cache_flags(unsigned long object_size,
1890 unsigned long flags, const char *name, 1890 slab_flags_t flags, const char *name,
1891 void (*ctor)(void *)) 1891 void (*ctor)(void *))
1892{ 1892{
1893 return flags; 1893 return flags;
@@ -1895,7 +1895,7 @@ unsigned long kmem_cache_flags(unsigned long object_size,
1895 1895
1896struct kmem_cache * 1896struct kmem_cache *
1897__kmem_cache_alias(const char *name, size_t size, size_t align, 1897__kmem_cache_alias(const char *name, size_t size, size_t align,
1898 unsigned long flags, void (*ctor)(void *)) 1898 slab_flags_t flags, void (*ctor)(void *))
1899{ 1899{
1900 struct kmem_cache *cachep; 1900 struct kmem_cache *cachep;
1901 1901
@@ -1913,7 +1913,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
1913} 1913}
1914 1914
1915static bool set_objfreelist_slab_cache(struct kmem_cache *cachep, 1915static bool set_objfreelist_slab_cache(struct kmem_cache *cachep,
1916 size_t size, unsigned long flags) 1916 size_t size, slab_flags_t flags)
1917{ 1917{
1918 size_t left; 1918 size_t left;
1919 1919
@@ -1936,7 +1936,7 @@ static bool set_objfreelist_slab_cache(struct kmem_cache *cachep,
1936} 1936}
1937 1937
1938static bool set_off_slab_cache(struct kmem_cache *cachep, 1938static bool set_off_slab_cache(struct kmem_cache *cachep,
1939 size_t size, unsigned long flags) 1939 size_t size, slab_flags_t flags)
1940{ 1940{
1941 size_t left; 1941 size_t left;
1942 1942
@@ -1970,7 +1970,7 @@ static bool set_off_slab_cache(struct kmem_cache *cachep,
1970} 1970}
1971 1971
1972static bool set_on_slab_cache(struct kmem_cache *cachep, 1972static bool set_on_slab_cache(struct kmem_cache *cachep,
1973 size_t size, unsigned long flags) 1973 size_t size, slab_flags_t flags)
1974{ 1974{
1975 size_t left; 1975 size_t left;
1976 1976
@@ -2006,8 +2006,7 @@ static bool set_on_slab_cache(struct kmem_cache *cachep,
2006 * cacheline. This can be beneficial if you're counting cycles as closely 2006 * cacheline. This can be beneficial if you're counting cycles as closely
2007 * as davem. 2007 * as davem.
2008 */ 2008 */
2009int 2009int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags)
2010__kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
2011{ 2010{
2012 size_t ralign = BYTES_PER_WORD; 2011 size_t ralign = BYTES_PER_WORD;
2013 gfp_t gfp; 2012 gfp_t gfp;
diff --git a/mm/slab.h b/mm/slab.h
index 45c586cefc11..e19255638cb6 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -21,7 +21,7 @@ struct kmem_cache {
21 unsigned int object_size;/* The original size of the object */ 21 unsigned int object_size;/* The original size of the object */
22 unsigned int size; /* The aligned/padded/added on size */ 22 unsigned int size; /* The aligned/padded/added on size */
23 unsigned int align; /* Alignment as calculated */ 23 unsigned int align; /* Alignment as calculated */
24 unsigned long flags; /* Active flags on the slab */ 24 slab_flags_t flags; /* Active flags on the slab */
25 const char *name; /* Slab name for sysfs */ 25 const char *name; /* Slab name for sysfs */
26 int refcount; /* Use counter */ 26 int refcount; /* Use counter */
27 void (*ctor)(void *); /* Called on object slot creation */ 27 void (*ctor)(void *); /* Called on object slot creation */
@@ -79,13 +79,13 @@ extern const struct kmalloc_info_struct {
79 unsigned long size; 79 unsigned long size;
80} kmalloc_info[]; 80} kmalloc_info[];
81 81
82unsigned long calculate_alignment(unsigned long flags, 82unsigned long calculate_alignment(slab_flags_t flags,
83 unsigned long align, unsigned long size); 83 unsigned long align, unsigned long size);
84 84
85#ifndef CONFIG_SLOB 85#ifndef CONFIG_SLOB
86/* Kmalloc array related functions */ 86/* Kmalloc array related functions */
87void setup_kmalloc_cache_index_table(void); 87void setup_kmalloc_cache_index_table(void);
88void create_kmalloc_caches(unsigned long); 88void create_kmalloc_caches(slab_flags_t);
89 89
90/* Find the kmalloc slab corresponding for a certain size */ 90/* Find the kmalloc slab corresponding for a certain size */
91struct kmem_cache *kmalloc_slab(size_t, gfp_t); 91struct kmem_cache *kmalloc_slab(size_t, gfp_t);
@@ -93,32 +93,32 @@ struct kmem_cache *kmalloc_slab(size_t, gfp_t);
93 93
94 94
95/* Functions provided by the slab allocators */ 95/* Functions provided by the slab allocators */
96extern int __kmem_cache_create(struct kmem_cache *, unsigned long flags); 96int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags);
97 97
98extern struct kmem_cache *create_kmalloc_cache(const char *name, size_t size, 98extern struct kmem_cache *create_kmalloc_cache(const char *name, size_t size,
99 unsigned long flags); 99 slab_flags_t flags);
100extern void create_boot_cache(struct kmem_cache *, const char *name, 100extern void create_boot_cache(struct kmem_cache *, const char *name,
101 size_t size, unsigned long flags); 101 size_t size, slab_flags_t flags);
102 102
103int slab_unmergeable(struct kmem_cache *s); 103int slab_unmergeable(struct kmem_cache *s);
104struct kmem_cache *find_mergeable(size_t size, size_t align, 104struct kmem_cache *find_mergeable(size_t size, size_t align,
105 unsigned long flags, const char *name, void (*ctor)(void *)); 105 slab_flags_t flags, const char *name, void (*ctor)(void *));
106#ifndef CONFIG_SLOB 106#ifndef CONFIG_SLOB
107struct kmem_cache * 107struct kmem_cache *
108__kmem_cache_alias(const char *name, size_t size, size_t align, 108__kmem_cache_alias(const char *name, size_t size, size_t align,
109 unsigned long flags, void (*ctor)(void *)); 109 slab_flags_t flags, void (*ctor)(void *));
110 110
111unsigned long kmem_cache_flags(unsigned long object_size, 111slab_flags_t kmem_cache_flags(unsigned long object_size,
112 unsigned long flags, const char *name, 112 slab_flags_t flags, const char *name,
113 void (*ctor)(void *)); 113 void (*ctor)(void *));
114#else 114#else
115static inline struct kmem_cache * 115static inline struct kmem_cache *
116__kmem_cache_alias(const char *name, size_t size, size_t align, 116__kmem_cache_alias(const char *name, size_t size, size_t align,
117 unsigned long flags, void (*ctor)(void *)) 117 slab_flags_t flags, void (*ctor)(void *))
118{ return NULL; } 118{ return NULL; }
119 119
120static inline unsigned long kmem_cache_flags(unsigned long object_size, 120static inline slab_flags_t kmem_cache_flags(unsigned long object_size,
121 unsigned long flags, const char *name, 121 slab_flags_t flags, const char *name,
122 void (*ctor)(void *)) 122 void (*ctor)(void *))
123{ 123{
124 return flags; 124 return flags;
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 8f7f9f75d7ea..175e86637afd 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -291,7 +291,7 @@ int slab_unmergeable(struct kmem_cache *s)
291} 291}
292 292
293struct kmem_cache *find_mergeable(size_t size, size_t align, 293struct kmem_cache *find_mergeable(size_t size, size_t align,
294 unsigned long flags, const char *name, void (*ctor)(void *)) 294 slab_flags_t flags, const char *name, void (*ctor)(void *))
295{ 295{
296 struct kmem_cache *s; 296 struct kmem_cache *s;
297 297
@@ -341,7 +341,7 @@ struct kmem_cache *find_mergeable(size_t size, size_t align,
341 * Figure out what the alignment of the objects will be given a set of 341 * Figure out what the alignment of the objects will be given a set of
342 * flags, a user specified alignment and the size of the objects. 342 * flags, a user specified alignment and the size of the objects.
343 */ 343 */
344unsigned long calculate_alignment(unsigned long flags, 344unsigned long calculate_alignment(slab_flags_t flags,
345 unsigned long align, unsigned long size) 345 unsigned long align, unsigned long size)
346{ 346{
347 /* 347 /*
@@ -366,7 +366,7 @@ unsigned long calculate_alignment(unsigned long flags,
366 366
367static struct kmem_cache *create_cache(const char *name, 367static struct kmem_cache *create_cache(const char *name,
368 size_t object_size, size_t size, size_t align, 368 size_t object_size, size_t size, size_t align,
369 unsigned long flags, void (*ctor)(void *), 369 slab_flags_t flags, void (*ctor)(void *),
370 struct mem_cgroup *memcg, struct kmem_cache *root_cache) 370 struct mem_cgroup *memcg, struct kmem_cache *root_cache)
371{ 371{
372 struct kmem_cache *s; 372 struct kmem_cache *s;
@@ -431,7 +431,7 @@ out_free_cache:
431 */ 431 */
432struct kmem_cache * 432struct kmem_cache *
433kmem_cache_create(const char *name, size_t size, size_t align, 433kmem_cache_create(const char *name, size_t size, size_t align,
434 unsigned long flags, void (*ctor)(void *)) 434 slab_flags_t flags, void (*ctor)(void *))
435{ 435{
436 struct kmem_cache *s = NULL; 436 struct kmem_cache *s = NULL;
437 const char *cache_name; 437 const char *cache_name;
@@ -879,7 +879,7 @@ bool slab_is_available(void)
879#ifndef CONFIG_SLOB 879#ifndef CONFIG_SLOB
880/* Create a cache during boot when no slab services are available yet */ 880/* Create a cache during boot when no slab services are available yet */
881void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t size, 881void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t size,
882 unsigned long flags) 882 slab_flags_t flags)
883{ 883{
884 int err; 884 int err;
885 885
@@ -899,7 +899,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
899} 899}
900 900
901struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size, 901struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
902 unsigned long flags) 902 slab_flags_t flags)
903{ 903{
904 struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT); 904 struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT);
905 905
@@ -1057,7 +1057,7 @@ void __init setup_kmalloc_cache_index_table(void)
1057 } 1057 }
1058} 1058}
1059 1059
1060static void __init new_kmalloc_cache(int idx, unsigned long flags) 1060static void __init new_kmalloc_cache(int idx, slab_flags_t flags)
1061{ 1061{
1062 kmalloc_caches[idx] = create_kmalloc_cache(kmalloc_info[idx].name, 1062 kmalloc_caches[idx] = create_kmalloc_cache(kmalloc_info[idx].name,
1063 kmalloc_info[idx].size, flags); 1063 kmalloc_info[idx].size, flags);
@@ -1068,7 +1068,7 @@ static void __init new_kmalloc_cache(int idx, unsigned long flags)
1068 * may already have been created because they were needed to 1068 * may already have been created because they were needed to
1069 * enable allocations for slab creation. 1069 * enable allocations for slab creation.
1070 */ 1070 */
1071void __init create_kmalloc_caches(unsigned long flags) 1071void __init create_kmalloc_caches(slab_flags_t flags)
1072{ 1072{
1073 int i; 1073 int i;
1074 1074
diff --git a/mm/slob.c b/mm/slob.c
index 3451ecad8e35..623e8a5c46ce 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -524,7 +524,7 @@ size_t ksize(const void *block)
524} 524}
525EXPORT_SYMBOL(ksize); 525EXPORT_SYMBOL(ksize);
526 526
527int __kmem_cache_create(struct kmem_cache *c, unsigned long flags) 527int __kmem_cache_create(struct kmem_cache *c, slab_flags_t flags)
528{ 528{
529 if (flags & SLAB_TYPESAFE_BY_RCU) { 529 if (flags & SLAB_TYPESAFE_BY_RCU) {
530 /* leave room for rcu footer at the end of object */ 530 /* leave room for rcu footer at the end of object */
diff --git a/mm/slub.c b/mm/slub.c
index 025bbb540f3d..482d1daa9088 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -193,8 +193,10 @@ static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s)
193#define MAX_OBJS_PER_PAGE 32767 /* since page.objects is u15 */ 193#define MAX_OBJS_PER_PAGE 32767 /* since page.objects is u15 */
194 194
195/* Internal SLUB flags */ 195/* Internal SLUB flags */
196#define __OBJECT_POISON 0x80000000UL /* Poison object */ 196/* Poison object */
197#define __CMPXCHG_DOUBLE 0x40000000UL /* Use cmpxchg_double */ 197#define __OBJECT_POISON ((slab_flags_t __force)0x80000000UL)
198/* Use cmpxchg_double */
199#define __CMPXCHG_DOUBLE ((slab_flags_t __force)0x40000000UL)
198 200
199/* 201/*
200 * Tracking user of a slab. 202 * Tracking user of a slab.
@@ -485,9 +487,9 @@ static inline void *restore_red_left(struct kmem_cache *s, void *p)
485 * Debug settings: 487 * Debug settings:
486 */ 488 */
487#if defined(CONFIG_SLUB_DEBUG_ON) 489#if defined(CONFIG_SLUB_DEBUG_ON)
488static int slub_debug = DEBUG_DEFAULT_FLAGS; 490static slab_flags_t slub_debug = DEBUG_DEFAULT_FLAGS;
489#else 491#else
490static int slub_debug; 492static slab_flags_t slub_debug;
491#endif 493#endif
492 494
493static char *slub_debug_slabs; 495static char *slub_debug_slabs;
@@ -1289,8 +1291,8 @@ out:
1289 1291
1290__setup("slub_debug", setup_slub_debug); 1292__setup("slub_debug", setup_slub_debug);
1291 1293
1292unsigned long kmem_cache_flags(unsigned long object_size, 1294slab_flags_t kmem_cache_flags(unsigned long object_size,
1293 unsigned long flags, const char *name, 1295 slab_flags_t flags, const char *name,
1294 void (*ctor)(void *)) 1296 void (*ctor)(void *))
1295{ 1297{
1296 /* 1298 /*
@@ -1322,8 +1324,8 @@ static inline void add_full(struct kmem_cache *s, struct kmem_cache_node *n,
1322 struct page *page) {} 1324 struct page *page) {}
1323static inline void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, 1325static inline void remove_full(struct kmem_cache *s, struct kmem_cache_node *n,
1324 struct page *page) {} 1326 struct page *page) {}
1325unsigned long kmem_cache_flags(unsigned long object_size, 1327slab_flags_t kmem_cache_flags(unsigned long object_size,
1326 unsigned long flags, const char *name, 1328 slab_flags_t flags, const char *name,
1327 void (*ctor)(void *)) 1329 void (*ctor)(void *))
1328{ 1330{
1329 return flags; 1331 return flags;
@@ -3477,7 +3479,7 @@ static void set_cpu_partial(struct kmem_cache *s)
3477 */ 3479 */
3478static int calculate_sizes(struct kmem_cache *s, int forced_order) 3480static int calculate_sizes(struct kmem_cache *s, int forced_order)
3479{ 3481{
3480 unsigned long flags = s->flags; 3482 slab_flags_t flags = s->flags;
3481 size_t size = s->object_size; 3483 size_t size = s->object_size;
3482 int order; 3484 int order;
3483 3485
@@ -3593,7 +3595,7 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
3593 return !!oo_objects(s->oo); 3595 return !!oo_objects(s->oo);
3594} 3596}
3595 3597
3596static int kmem_cache_open(struct kmem_cache *s, unsigned long flags) 3598static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags)
3597{ 3599{
3598 s->flags = kmem_cache_flags(s->size, flags, s->name, s->ctor); 3600 s->flags = kmem_cache_flags(s->size, flags, s->name, s->ctor);
3599 s->reserved = 0; 3601 s->reserved = 0;
@@ -4245,7 +4247,7 @@ void __init kmem_cache_init_late(void)
4245 4247
4246struct kmem_cache * 4248struct kmem_cache *
4247__kmem_cache_alias(const char *name, size_t size, size_t align, 4249__kmem_cache_alias(const char *name, size_t size, size_t align,
4248 unsigned long flags, void (*ctor)(void *)) 4250 slab_flags_t flags, void (*ctor)(void *))
4249{ 4251{
4250 struct kmem_cache *s, *c; 4252 struct kmem_cache *s, *c;
4251 4253
@@ -4275,7 +4277,7 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
4275 return s; 4277 return s;
4276} 4278}
4277 4279
4278int __kmem_cache_create(struct kmem_cache *s, unsigned long flags) 4280int __kmem_cache_create(struct kmem_cache *s, slab_flags_t flags)
4279{ 4281{
4280 int err; 4282 int err;
4281 4283