make all kref debugging checks new config option.
Signed-off-by: Akinobu Mita <[email protected]>
CC: Greg KH <[email protected]>
CC: Patrick Mochel <[email protected]>
lib/Kconfig.debug | 7 +++++++
lib/kref.c | 30 +++++++++++++++++++++++++-----
2 files changed, 32 insertions(+), 5 deletions(-)
Index: 2.6-git/lib/Kconfig.debug
===================================================================
--- 2.6-git.orig/lib/Kconfig.debug
+++ 2.6-git/lib/Kconfig.debug
@@ -130,6 +130,13 @@ config DEBUG_KOBJECT
If you say Y here, some extra kobject debugging messages will be sent
to the syslog.
+config DEBUG_KREF
+ bool "kref debugging"
+ depends on DEBUG_KERNEL
+ help
+ This option enables addition error checking for kref,
+ library routines for handling generic reference counted objects.
+
config DEBUG_HIGHMEM
bool "Highmem debugging"
depends on DEBUG_KERNEL && HIGHMEM
Index: 2.6-git/lib/kref.c
===================================================================
--- 2.6-git.orig/lib/kref.c
+++ 2.6-git/lib/kref.c
@@ -20,16 +20,38 @@
*/
void kref_init(struct kref *kref)
{
- atomic_set(&kref->refcount,1);
+ atomic_set(&kref->refcount, 1);
}
+#ifdef CONFIG_DEBUG_KREF
+static void kref_get_debug_check(struct kref *kref)
+{
+ WARN_ON(!atomic_read(&kref->refcount));
+}
+static void kref_put_debug_check(struct kref *kref,
+ void (*release)(struct kref *kref))
+{
+ WARN_ON(atomic_read(&kref->refcount) < 1);
+ WARN_ON(release == NULL);
+ WARN_ON(release == (void (*)(struct kref *))kfree);
+}
+#else
+static void kref_get_debug_check(struct kref *kref)
+{
+}
+static void kref_put_debug_check(struct kref *kref,
+ void (*release)(struct kref *kref))
+{
+}
+#endif
+
/**
* kref_get - increment refcount for object.
* @kref: object.
*/
void kref_get(struct kref *kref)
{
- WARN_ON(!atomic_read(&kref->refcount));
+ kref_get_debug_check(kref);
atomic_inc(&kref->refcount);
}
@@ -49,9 +71,7 @@ void kref_get(struct kref *kref)
*/
int kref_put(struct kref *kref, void (*release)(struct kref *kref))
{
- WARN_ON(atomic_read(&kref->refcount) < 1);
- WARN_ON(release == NULL);
- WARN_ON(release == (void (*)(struct kref *))kfree);
+ kref_put_debug_check(kref, release);
/*
* if current count is one, we are the last user and can release object
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]