aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-03-13 18:21:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-03-13 18:21:57 -0400
commit842d223f28c4a4a6fe34df2d613049d4e47446c1 (patch)
treefe24924112a915651eb8cc2c03836a695db6b7d7 /lib
parentad8395e149e86ca3a76b6ae300c0d0a92b7f7e17 (diff)
parent59bfbcf01967d4d3370a2b8294673dd709e732cc (diff)
Merge branch 'akpm' (fixes from Andrew)
Merge misc fixes from Andrew Morton: - A bunch of fixes - Finish off the idr API conversions before someone starts to use the old interfaces again. * emailed patches from Andrew Morton <akpm@linux-foundation.org>: idr: idr_alloc() shouldn't trigger lowmem warning when preloaded UAPI: fix endianness conditionals in M32R's asm/stat.h UAPI: fix endianness conditionals in linux/raid/md_p.h UAPI: fix endianness conditionals in linux/acct.h UAPI: fix endianness conditionals in linux/aio_abi.h decompressors: fix typo "POWERPC" mm/fremap.c: fix oops on error path idr: deprecate idr_pre_get() and idr_get_new[_above]() tidspbridge: convert to idr_alloc() zcache: convert to idr_alloc() mlx4: remove leftover idr_pre_get() call workqueue: convert to idr_alloc() nfsd: convert to idr_alloc() nfsd: remove unused get_new_stid() kernel/signal.c: use __ARCH_HAS_SA_RESTORER instead of SA_RESTORER signal: always clear sa_restorer on execve mm: remove_memory(): fix end_pfn setting include/linux/res_counter.h needs errno.h
Diffstat (limited to 'lib')
-rw-r--r--lib/idr.c79
-rw-r--r--lib/xz/Kconfig2
2 files changed, 31 insertions, 50 deletions
diff --git a/lib/idr.c b/lib/idr.c
index 4f82a284c6a2..322e2816f2fb 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -106,8 +106,14 @@ static struct idr_layer *idr_layer_alloc(gfp_t gfp_mask, struct idr *layer_idr)
106 if (layer_idr) 106 if (layer_idr)
107 return get_from_free_list(layer_idr); 107 return get_from_free_list(layer_idr);
108 108
109 /* try to allocate directly from kmem_cache */ 109 /*
110 new = kmem_cache_zalloc(idr_layer_cache, gfp_mask); 110 * Try to allocate directly from kmem_cache. We want to try this
111 * before preload buffer; otherwise, non-preloading idr_alloc()
112 * users will end up taking advantage of preloading ones. As the
113 * following is allowed to fail for preloaded cases, suppress
114 * warning this time.
115 */
116 new = kmem_cache_zalloc(idr_layer_cache, gfp_mask | __GFP_NOWARN);
111 if (new) 117 if (new)
112 return new; 118 return new;
113 119
@@ -115,18 +121,24 @@ static struct idr_layer *idr_layer_alloc(gfp_t gfp_mask, struct idr *layer_idr)
115 * Try to fetch one from the per-cpu preload buffer if in process 121 * Try to fetch one from the per-cpu preload buffer if in process
116 * context. See idr_preload() for details. 122 * context. See idr_preload() for details.
117 */ 123 */
118 if (in_interrupt()) 124 if (!in_interrupt()) {
119 return NULL; 125 preempt_disable();
120 126 new = __this_cpu_read(idr_preload_head);
121 preempt_disable(); 127 if (new) {
122 new = __this_cpu_read(idr_preload_head); 128 __this_cpu_write(idr_preload_head, new->ary[0]);
123 if (new) { 129 __this_cpu_dec(idr_preload_cnt);
124 __this_cpu_write(idr_preload_head, new->ary[0]); 130 new->ary[0] = NULL;
125 __this_cpu_dec(idr_preload_cnt); 131 }
126 new->ary[0] = NULL; 132 preempt_enable();
133 if (new)
134 return new;
127 } 135 }
128 preempt_enable(); 136
129 return new; 137 /*
138 * Both failed. Try kmem_cache again w/o adding __GFP_NOWARN so
139 * that memory allocation failure warning is printed as intended.
140 */
141 return kmem_cache_zalloc(idr_layer_cache, gfp_mask);
130} 142}
131 143
132static void idr_layer_rcu_free(struct rcu_head *head) 144static void idr_layer_rcu_free(struct rcu_head *head)
@@ -184,20 +196,7 @@ static void idr_mark_full(struct idr_layer **pa, int id)
184 } 196 }
185} 197}
186 198
187/** 199int __idr_pre_get(struct idr *idp, gfp_t gfp_mask)
188 * idr_pre_get - reserve resources for idr allocation
189 * @idp: idr handle
190 * @gfp_mask: memory allocation flags
191 *
192 * This function should be called prior to calling the idr_get_new* functions.
193 * It preallocates enough memory to satisfy the worst possible allocation. The
194 * caller should pass in GFP_KERNEL if possible. This of course requires that
195 * no spinning locks be held.
196 *
197 * If the system is REALLY out of memory this function returns %0,
198 * otherwise %1.
199 */
200int idr_pre_get(struct idr *idp, gfp_t gfp_mask)
201{ 200{
202 while (idp->id_free_cnt < MAX_IDR_FREE) { 201 while (idp->id_free_cnt < MAX_IDR_FREE) {
203 struct idr_layer *new; 202 struct idr_layer *new;
@@ -208,7 +207,7 @@ int idr_pre_get(struct idr *idp, gfp_t gfp_mask)
208 } 207 }
209 return 1; 208 return 1;
210} 209}
211EXPORT_SYMBOL(idr_pre_get); 210EXPORT_SYMBOL(__idr_pre_get);
212 211
213/** 212/**
214 * sub_alloc - try to allocate an id without growing the tree depth 213 * sub_alloc - try to allocate an id without growing the tree depth
@@ -375,25 +374,7 @@ static void idr_fill_slot(struct idr *idr, void *ptr, int id,
375 idr_mark_full(pa, id); 374 idr_mark_full(pa, id);
376} 375}
377 376
378/** 377int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
379 * idr_get_new_above - allocate new idr entry above or equal to a start id
380 * @idp: idr handle
381 * @ptr: pointer you want associated with the id
382 * @starting_id: id to start search at
383 * @id: pointer to the allocated handle
384 *
385 * This is the allocate id function. It should be called with any
386 * required locks.
387 *
388 * If allocation from IDR's private freelist fails, idr_get_new_above() will
389 * return %-EAGAIN. The caller should retry the idr_pre_get() call to refill
390 * IDR's preallocation and then retry the idr_get_new_above() call.
391 *
392 * If the idr is full idr_get_new_above() will return %-ENOSPC.
393 *
394 * @id returns a value in the range @starting_id ... %0x7fffffff
395 */
396int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
397{ 378{
398 struct idr_layer *pa[MAX_IDR_LEVEL + 1]; 379 struct idr_layer *pa[MAX_IDR_LEVEL + 1];
399 int rv; 380 int rv;
@@ -406,7 +387,7 @@ int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id)
406 *id = rv; 387 *id = rv;
407 return 0; 388 return 0;
408} 389}
409EXPORT_SYMBOL(idr_get_new_above); 390EXPORT_SYMBOL(__idr_get_new_above);
410 391
411/** 392/**
412 * idr_preload - preload for idr_alloc() 393 * idr_preload - preload for idr_alloc()
@@ -907,7 +888,7 @@ static void free_bitmap(struct ida *ida, struct ida_bitmap *bitmap)
907int ida_pre_get(struct ida *ida, gfp_t gfp_mask) 888int ida_pre_get(struct ida *ida, gfp_t gfp_mask)
908{ 889{
909 /* allocate idr_layers */ 890 /* allocate idr_layers */
910 if (!idr_pre_get(&ida->idr, gfp_mask)) 891 if (!__idr_pre_get(&ida->idr, gfp_mask))
911 return 0; 892 return 0;
912 893
913 /* allocate free_bitmap */ 894 /* allocate free_bitmap */
diff --git a/lib/xz/Kconfig b/lib/xz/Kconfig
index 82a04d7ba99e..08837db52d94 100644
--- a/lib/xz/Kconfig
+++ b/lib/xz/Kconfig
@@ -15,7 +15,7 @@ config XZ_DEC_X86
15 15
16config XZ_DEC_POWERPC 16config XZ_DEC_POWERPC
17 bool "PowerPC BCJ filter decoder" 17 bool "PowerPC BCJ filter decoder"
18 default y if POWERPC 18 default y if PPC
19 select XZ_DEC_BCJ 19 select XZ_DEC_BCJ
20 20
21config XZ_DEC_IA64 21config XZ_DEC_IA64