diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-06-06 18:17:50 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-06-06 18:17:50 -0400 |
commit | 3eba148d75670f61463dd3c9ef8672da8f290f36 (patch) | |
tree | 45cb8fbda6d6ce9d73aeeac673282e37b0be2531 /mm/slub.c | |
parent | 057b0a7518e4b8fca26201715996d6d928a62300 (diff) | |
parent | 4cf563c5d97c83d4b2fb3a778dd7d5e362cc3e34 (diff) |
Merge branch 'acpi-pm' into pm-sleep
Diffstat (limited to 'mm/slub.c')
-rw-r--r-- | mm/slub.c | 41 |
1 files changed, 15 insertions, 26 deletions
@@ -210,14 +210,11 @@ enum track_item { TRACK_ALLOC, TRACK_FREE }; | |||
210 | #ifdef CONFIG_SYSFS | 210 | #ifdef CONFIG_SYSFS |
211 | static int sysfs_slab_add(struct kmem_cache *); | 211 | static int sysfs_slab_add(struct kmem_cache *); |
212 | static int sysfs_slab_alias(struct kmem_cache *, const char *); | 212 | static int sysfs_slab_alias(struct kmem_cache *, const char *); |
213 | static void sysfs_slab_remove(struct kmem_cache *); | ||
214 | static void memcg_propagate_slab_attrs(struct kmem_cache *s); | 213 | static void memcg_propagate_slab_attrs(struct kmem_cache *s); |
215 | #else | 214 | #else |
216 | static inline int sysfs_slab_add(struct kmem_cache *s) { return 0; } | 215 | static inline int sysfs_slab_add(struct kmem_cache *s) { return 0; } |
217 | static inline int sysfs_slab_alias(struct kmem_cache *s, const char *p) | 216 | static inline int sysfs_slab_alias(struct kmem_cache *s, const char *p) |
218 | { return 0; } | 217 | { return 0; } |
219 | static inline void sysfs_slab_remove(struct kmem_cache *s) { } | ||
220 | |||
221 | static inline void memcg_propagate_slab_attrs(struct kmem_cache *s) { } | 218 | static inline void memcg_propagate_slab_attrs(struct kmem_cache *s) { } |
222 | #endif | 219 | #endif |
223 | 220 | ||
@@ -3238,24 +3235,7 @@ static inline int kmem_cache_close(struct kmem_cache *s) | |||
3238 | 3235 | ||
3239 | int __kmem_cache_shutdown(struct kmem_cache *s) | 3236 | int __kmem_cache_shutdown(struct kmem_cache *s) |
3240 | { | 3237 | { |
3241 | int rc = kmem_cache_close(s); | 3238 | return kmem_cache_close(s); |
3242 | |||
3243 | if (!rc) { | ||
3244 | /* | ||
3245 | * Since slab_attr_store may take the slab_mutex, we should | ||
3246 | * release the lock while removing the sysfs entry in order to | ||
3247 | * avoid a deadlock. Because this is pretty much the last | ||
3248 | * operation we do and the lock will be released shortly after | ||
3249 | * that in slab_common.c, we could just move sysfs_slab_remove | ||
3250 | * to a later point in common code. We should do that when we | ||
3251 | * have a common sysfs framework for all allocators. | ||
3252 | */ | ||
3253 | mutex_unlock(&slab_mutex); | ||
3254 | sysfs_slab_remove(s); | ||
3255 | mutex_lock(&slab_mutex); | ||
3256 | } | ||
3257 | |||
3258 | return rc; | ||
3259 | } | 3239 | } |
3260 | 3240 | ||
3261 | /******************************************************************** | 3241 | /******************************************************************** |
@@ -5071,15 +5051,18 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) | |||
5071 | #ifdef CONFIG_MEMCG_KMEM | 5051 | #ifdef CONFIG_MEMCG_KMEM |
5072 | int i; | 5052 | int i; |
5073 | char *buffer = NULL; | 5053 | char *buffer = NULL; |
5054 | struct kmem_cache *root_cache; | ||
5074 | 5055 | ||
5075 | if (!is_root_cache(s)) | 5056 | if (is_root_cache(s)) |
5076 | return; | 5057 | return; |
5077 | 5058 | ||
5059 | root_cache = s->memcg_params->root_cache; | ||
5060 | |||
5078 | /* | 5061 | /* |
5079 | * This mean this cache had no attribute written. Therefore, no point | 5062 | * This mean this cache had no attribute written. Therefore, no point |
5080 | * in copying default values around | 5063 | * in copying default values around |
5081 | */ | 5064 | */ |
5082 | if (!s->max_attr_size) | 5065 | if (!root_cache->max_attr_size) |
5083 | return; | 5066 | return; |
5084 | 5067 | ||
5085 | for (i = 0; i < ARRAY_SIZE(slab_attrs); i++) { | 5068 | for (i = 0; i < ARRAY_SIZE(slab_attrs); i++) { |
@@ -5101,7 +5084,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) | |||
5101 | */ | 5084 | */ |
5102 | if (buffer) | 5085 | if (buffer) |
5103 | buf = buffer; | 5086 | buf = buffer; |
5104 | else if (s->max_attr_size < ARRAY_SIZE(mbuf)) | 5087 | else if (root_cache->max_attr_size < ARRAY_SIZE(mbuf)) |
5105 | buf = mbuf; | 5088 | buf = mbuf; |
5106 | else { | 5089 | else { |
5107 | buffer = (char *) get_zeroed_page(GFP_KERNEL); | 5090 | buffer = (char *) get_zeroed_page(GFP_KERNEL); |
@@ -5110,7 +5093,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) | |||
5110 | buf = buffer; | 5093 | buf = buffer; |
5111 | } | 5094 | } |
5112 | 5095 | ||
5113 | attr->show(s->memcg_params->root_cache, buf); | 5096 | attr->show(root_cache, buf); |
5114 | attr->store(s, buf, strlen(buf)); | 5097 | attr->store(s, buf, strlen(buf)); |
5115 | } | 5098 | } |
5116 | 5099 | ||
@@ -5119,6 +5102,11 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) | |||
5119 | #endif | 5102 | #endif |
5120 | } | 5103 | } |
5121 | 5104 | ||
5105 | static void kmem_cache_release(struct kobject *k) | ||
5106 | { | ||
5107 | slab_kmem_cache_release(to_slab(k)); | ||
5108 | } | ||
5109 | |||
5122 | static const struct sysfs_ops slab_sysfs_ops = { | 5110 | static const struct sysfs_ops slab_sysfs_ops = { |
5123 | .show = slab_attr_show, | 5111 | .show = slab_attr_show, |
5124 | .store = slab_attr_store, | 5112 | .store = slab_attr_store, |
@@ -5126,6 +5114,7 @@ static const struct sysfs_ops slab_sysfs_ops = { | |||
5126 | 5114 | ||
5127 | static struct kobj_type slab_ktype = { | 5115 | static struct kobj_type slab_ktype = { |
5128 | .sysfs_ops = &slab_sysfs_ops, | 5116 | .sysfs_ops = &slab_sysfs_ops, |
5117 | .release = kmem_cache_release, | ||
5129 | }; | 5118 | }; |
5130 | 5119 | ||
5131 | static int uevent_filter(struct kset *kset, struct kobject *kobj) | 5120 | static int uevent_filter(struct kset *kset, struct kobject *kobj) |
@@ -5252,7 +5241,7 @@ out_put_kobj: | |||
5252 | goto out; | 5241 | goto out; |
5253 | } | 5242 | } |
5254 | 5243 | ||
5255 | static void sysfs_slab_remove(struct kmem_cache *s) | 5244 | void sysfs_slab_remove(struct kmem_cache *s) |
5256 | { | 5245 | { |
5257 | if (slab_state < FULL) | 5246 | if (slab_state < FULL) |
5258 | /* | 5247 | /* |