Skip to content
Snippets Groups Projects
Commit e428b5a8 authored by alex's avatar alex
Browse files

- several asserts in dynlocks have been added to assist 3772 debuggin

parent 5e610513
No related branches found
No related tags found
No related merge requests found
...@@ -6,15 +6,19 @@ ...@@ -6,15 +6,19 @@
Index: linux-2.4.24/include/linux/dynlocks.h Index: linux-2.4.24/include/linux/dynlocks.h
=================================================================== ===================================================================
--- linux-2.4.24.orig/include/linux/dynlocks.h 2003-01-30 13:24:37.000000000 +0300 --- linux-2.4.24.orig/include/linux/dynlocks.h 2003-01-30 13:24:37.000000000 +0300
+++ linux-2.4.24/include/linux/dynlocks.h 2004-03-01 19:29:53.000000000 +0300 +++ linux-2.4.24/include/linux/dynlocks.h 2004-07-06 19:14:17.000000000 +0400
@@ -0,0 +1,33 @@ @@ -0,0 +1,41 @@
+#ifndef _LINUX_DYNLOCKS_H +#ifndef _LINUX_DYNLOCKS_H
+#define _LINUX_DYNLOCKS_H +#define _LINUX_DYNLOCKS_H
+ +
+#include <linux/list.h> +#include <linux/list.h>
+#include <linux/wait.h> +#include <linux/wait.h>
+ +
+#define DYNLOCK_MAGIC 0xd19a10c
+#define DYNLOCK_MAGIC2 0xd1956ee
+
+struct dynlock_member { +struct dynlock_member {
+ unsigned dl_magic;
+ struct list_head dl_list; + struct list_head dl_list;
+ unsigned long dl_value; /* lock value */ + unsigned long dl_value; /* lock value */
+ int dl_refcount; /* number of users */ + int dl_refcount; /* number of users */
...@@ -29,7 +33,11 @@ Index: linux-2.4.24/include/linux/dynlocks.h ...@@ -29,7 +33,11 @@ Index: linux-2.4.24/include/linux/dynlocks.h
+ * - list of locks + * - list of locks
+ * - lock to protect this list + * - lock to protect this list
+ */ + */
+
+#define DYNLOCK_LIST_MAGIC 0x11ee91e6
+
+struct dynlock { +struct dynlock {
+ unsigned dl_magic;
+ struct list_head dl_list; + struct list_head dl_list;
+ spinlock_t dl_list_lock; + spinlock_t dl_list_lock;
+}; +};
...@@ -44,8 +52,8 @@ Index: linux-2.4.24/include/linux/dynlocks.h ...@@ -44,8 +52,8 @@ Index: linux-2.4.24/include/linux/dynlocks.h
Index: linux-2.4.24/lib/dynlocks.c Index: linux-2.4.24/lib/dynlocks.c
=================================================================== ===================================================================
--- linux-2.4.24.orig/lib/dynlocks.c 2003-01-30 13:24:37.000000000 +0300 --- linux-2.4.24.orig/lib/dynlocks.c 2003-01-30 13:24:37.000000000 +0300
+++ linux-2.4.24/lib/dynlocks.c 2004-03-01 19:29:53.000000000 +0300 +++ linux-2.4.24/lib/dynlocks.c 2004-07-06 19:14:40.000000000 +0400
@@ -0,0 +1,152 @@ @@ -0,0 +1,173 @@
+/* +/*
+ * Dynamic Locks + * Dynamic Locks
+ * + *
...@@ -70,6 +78,7 @@ Index: linux-2.4.24/lib/dynlocks.c ...@@ -70,6 +78,7 @@ Index: linux-2.4.24/lib/dynlocks.c
+{ +{
+ spin_lock_init(&dl->dl_list_lock); + spin_lock_init(&dl->dl_list_lock);
+ INIT_LIST_HEAD(&dl->dl_list); + INIT_LIST_HEAD(&dl->dl_list);
+ dl->dl_magic = DYNLOCK_LIST_MAGIC;
+} +}
+ +
+/* +/*
...@@ -88,11 +97,18 @@ Index: linux-2.4.24/lib/dynlocks.c ...@@ -88,11 +97,18 @@ Index: linux-2.4.24/lib/dynlocks.c
+ struct dynlock_member *hl; + struct dynlock_member *hl;
+ struct list_head *cur; + struct list_head *cur;
+ +
+ BUG_ON(dl == NULL);
+ BUG_ON(dl->dl_magic != DYNLOCK_LIST_MAGIC);
+repeat: +repeat:
+ /* find requested lock in lockspace */ + /* find requested lock in lockspace */
+ spin_lock(&dl->dl_list_lock); + spin_lock(&dl->dl_list_lock);
+ BUG_ON(dl->dl_list.next == NULL);
+ BUG_ON(dl->dl_list.prev == NULL);
+ list_for_each(cur, &dl->dl_list) { + list_for_each(cur, &dl->dl_list) {
+ BUG_ON(cur->next == NULL);
+ BUG_ON(cur->prev == NULL);
+ hl = list_entry(cur, struct dynlock_member, dl_list); + hl = list_entry(cur, struct dynlock_member, dl_list);
+ BUG_ON(hl->dl_magic != DYNLOCK_MAGIC);
+ if (hl->dl_value == value) { + if (hl->dl_value == value) {
+ /* lock is found */ + /* lock is found */
+ if (nhl) { + if (nhl) {
...@@ -125,6 +141,7 @@ Index: linux-2.4.24/lib/dynlocks.c ...@@ -125,6 +141,7 @@ Index: linux-2.4.24/lib/dynlocks.c
+ nhl->dl_value = value; + nhl->dl_value = value;
+ nhl->dl_readers = 0; + nhl->dl_readers = 0;
+ nhl->dl_writers = 0; + nhl->dl_writers = 0;
+ nhl->dl_magic = DYNLOCK_MAGIC;
+ init_waitqueue_head(&nhl->dl_wait); + init_waitqueue_head(&nhl->dl_wait);
+ +
+ /* while lock is being allocated, someone else may allocate it + /* while lock is being allocated, someone else may allocate it
...@@ -157,6 +174,7 @@ Index: linux-2.4.24/lib/dynlocks.c ...@@ -157,6 +174,7 @@ Index: linux-2.4.24/lib/dynlocks.c
+ hl->dl_pid = current->pid; + hl->dl_pid = current->pid;
+ spin_unlock(&dl->dl_list_lock); + spin_unlock(&dl->dl_list_lock);
+ +
+ BUG_ON(hl->dl_magic != DYNLOCK_MAGIC);
+ return hl; + return hl;
+} +}
+ +
...@@ -173,22 +191,33 @@ Index: linux-2.4.24/lib/dynlocks.c ...@@ -173,22 +191,33 @@ Index: linux-2.4.24/lib/dynlocks.c
+ struct dynlock_member *hl = lock; + struct dynlock_member *hl = lock;
+ int wakeup = 0; + int wakeup = 0;
+ +
+ BUG_ON(dl == NULL);
+ BUG_ON(hl == NULL);
+ BUG_ON(dl->dl_magic != DYNLOCK_LIST_MAGIC);
+ BUG_ON(hl->dl_magic != DYNLOCK_MAGIC);
+ BUG_ON(current->pid != hl->dl_pid);
+
+ spin_lock(&dl->dl_list_lock); + spin_lock(&dl->dl_list_lock);
+ if (hl->dl_writers) { + if (hl->dl_writers) {
+ BUG_ON(hl->dl_readers > 0 || hl->dl_readers < 0);
+ hl->dl_writers--; + hl->dl_writers--;
+ if (hl->dl_writers == 0) + if (hl->dl_writers == 0)
+ wakeup = 1; + wakeup = 1;
+ } else { + } else if (hl->dl_readers) {
+ hl->dl_readers--; + hl->dl_readers--;
+ if (hl->dl_readers == 0) + if (hl->dl_readers == 0)
+ wakeup = 1; + wakeup = 1;
+ } else {
+ BUG_ON(1);
+ } + }
+ if (wakeup) { + if (wakeup) {
+ hl->dl_pid = 0; + hl->dl_pid = 0;
+ wake_up(&hl->dl_wait); + wake_up(&hl->dl_wait);
+ } + }
+ if (--(hl->dl_refcount) == 0) + if (--(hl->dl_refcount) == 0) {
+ hl->dl_magic = DYNLOCK_MAGIC2;
+ list_del(&hl->dl_list); + list_del(&hl->dl_list);
+ }
+ spin_unlock(&dl->dl_list_lock); + spin_unlock(&dl->dl_list_lock);
+ if (hl->dl_refcount == 0) + if (hl->dl_refcount == 0)
+ kfree(hl); + kfree(hl);
...@@ -200,8 +229,8 @@ Index: linux-2.4.24/lib/dynlocks.c ...@@ -200,8 +229,8 @@ Index: linux-2.4.24/lib/dynlocks.c
+ +
Index: linux-2.4.24/lib/Makefile Index: linux-2.4.24/lib/Makefile
=================================================================== ===================================================================
--- linux-2.4.24.orig/lib/Makefile 2004-02-02 21:52:31.000000000 +0300 --- linux-2.4.24.orig/lib/Makefile 2004-06-24 09:06:32.000000000 +0400
+++ linux-2.4.24/lib/Makefile 2004-03-01 19:30:25.000000000 +0300 +++ linux-2.4.24/lib/Makefile 2004-07-06 19:14:17.000000000 +0400
@@ -9,10 +9,10 @@ @@ -9,10 +9,10 @@
L_TARGET := lib.a L_TARGET := lib.a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment