aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug12
-rw-r--r--lib/idr.c43
2 files changed, 53 insertions, 2 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index ccb0c1fdf1b5..8bab0102ac73 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -188,14 +188,22 @@ config FRAME_POINTER
188 188
189config UNWIND_INFO 189config UNWIND_INFO
190 bool "Compile the kernel with frame unwind information" 190 bool "Compile the kernel with frame unwind information"
191 depends on !IA64 191 depends on !IA64 && !PARISC
192 depends on !MODULES || !(MIPS || PARISC || PPC || SUPERH || V850) 192 depends on !MODULES || !(MIPS || PPC || SUPERH || V850)
193 help 193 help
194 If you say Y here the resulting kernel image will be slightly larger 194 If you say Y here the resulting kernel image will be slightly larger
195 but not slower, and it will give very useful debugging information. 195 but not slower, and it will give very useful debugging information.
196 If you don't debug the kernel, you can say N, but we may not be able 196 If you don't debug the kernel, you can say N, but we may not be able
197 to solve problems without frame unwind information or frame pointers. 197 to solve problems without frame unwind information or frame pointers.
198 198
199config STACK_UNWIND
200 bool "Stack unwind support"
201 depends on UNWIND_INFO
202 depends on X86
203 help
204 This enables more precise stack traces, omitting all unrelated
205 occurrences of pointers into kernel code from the dump.
206
199config FORCED_INLINING 207config FORCED_INLINING
200 bool "Force gcc to inline functions marked 'inline'" 208 bool "Force gcc to inline functions marked 'inline'"
201 depends on DEBUG_KERNEL 209 depends on DEBUG_KERNEL
diff --git a/lib/idr.c b/lib/idr.c
index de19030a999b..4d096819511a 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#endif 31#endif
32#include <linux/err.h>
32#include <linux/string.h> 33#include <linux/string.h>
33#include <linux/idr.h> 34#include <linux/idr.h>
34 35
@@ -398,6 +399,48 @@ void *idr_find(struct idr *idp, int id)
398} 399}
399EXPORT_SYMBOL(idr_find); 400EXPORT_SYMBOL(idr_find);
400 401
402/**
403 * idr_replace - replace pointer for given id
404 * @idp: idr handle
405 * @ptr: pointer you want associated with the id
406 * @id: lookup key
407 *
408 * Replace the pointer registered with an id and return the old value.
409 * A -ENOENT return indicates that @id was not found.
410 * A -EINVAL return indicates that @id was not within valid constraints.
411 *
412 * The caller must serialize vs idr_find(), idr_get_new(), and idr_remove().
413 */
414void *idr_replace(struct idr *idp, void *ptr, int id)
415{
416 int n;
417 struct idr_layer *p, *old_p;
418
419 n = idp->layers * IDR_BITS;
420 p = idp->top;
421
422 id &= MAX_ID_MASK;
423
424 if (id >= (1 << n))
425 return ERR_PTR(-EINVAL);
426
427 n -= IDR_BITS;
428 while ((n > 0) && p) {
429 p = p->ary[(id >> n) & IDR_MASK];
430 n -= IDR_BITS;
431 }
432
433 n = id & IDR_MASK;
434 if (unlikely(p == NULL || !test_bit(n, &p->bitmap)))
435 return ERR_PTR(-ENOENT);
436
437 old_p = p->ary[n];
438 p->ary[n] = ptr;
439
440 return old_p;
441}
442EXPORT_SYMBOL(idr_replace);
443
401static void idr_cache_ctor(void * idr_layer, kmem_cache_t *idr_layer_cache, 444static void idr_cache_ctor(void * idr_layer, kmem_cache_t *idr_layer_cache,
402 unsigned long flags) 445 unsigned long flags)
403{ 446{