[RFC][PATCH 1/4] rwsem style cleanups

From: Dominik Brodowski
Date: Wed Jan 19 2005 - 16:41:40 EST


From: Nick Piggin <nickpiggin@xxxxxxxxxxxx>

Changes some coding style and formatting to match David's preference.

Signed-off-by: Nick Piggin <nickpiggin@xxxxxxxxxxxx>
Signed-off-by: Dominik Brodowski <linux@xxxxxxxx>

---

linux-2.6-npiggin/lib/rwsem-spinlock.c | 12 +++++++-----
linux-2.6-npiggin/lib/rwsem.c | 20 +++++++++++++-------
2 files changed, 20 insertions(+), 12 deletions(-)

diff -puN lib/rwsem.c~rwsem-style lib/rwsem.c
--- linux-2.6/lib/rwsem.c~rwsem-style 2005-01-19 13:34:48.000000000 +1100
+++ linux-2.6-npiggin/lib/rwsem.c 2005-01-19 13:39:06.000000000 +1100
@@ -9,9 +9,9 @@
#include <linux/module.h>

struct rwsem_waiter {
- struct list_head list;
- struct task_struct *task;
- unsigned int flags;
+ struct list_head list;
+ struct task_struct *task;
+ unsigned int flags;
#define RWSEM_WAITING_FOR_READ 0x00000001
#define RWSEM_WAITING_FOR_WRITE 0x00000002
};
@@ -28,7 +28,8 @@ void rwsemtrace(struct rw_semaphore *sem
#endif

/*
- * handle the lock release when processes blocked on it that can now run
+ * handle the lock being released whilst there are processes blocked on it
+ * that can now run.
* - if we come here from up_xxxx(), then:
* - the 'active part' of count (&0x0000ffff) reached 0 (but may have changed)
* - the 'waiting part' of count (&0xffff0000) is -ve (and will still be so)
@@ -62,8 +63,9 @@ __rwsem_do_wake(struct rw_semaphore *sem
waiter = list_entry(sem->wait_list.next, struct rwsem_waiter, list);

/* try to grant a single write lock if there's a writer at the front
- * of the queue - note we leave the 'active part' of the count
- * incremented by 1 and the waiting part incremented by 0x00010000
+ * of the queue
+ * - note we leave the 'active part' of the count
+ * incremented by 1 and the waiting part incremented by 0x00010000
*/
if (!(waiter->flags & RWSEM_WAITING_FOR_WRITE))
goto readers_only;
@@ -159,7 +161,11 @@ rwsem_down_failed_common(struct rw_semap
/* we're now waiting on the lock, but no longer actively read-locking */
count = rwsem_atomic_update(adjustment, sem);

- /* if there are no active locks, wake the front queued process(es) up */
+ /* if there are no longer active locks, wake the front queued
+ * process(es) up.
+ * - it might even be this process, since the waker takes a more
+ * active part
+ */
if (!(count & RWSEM_ACTIVE_MASK))
sem = __rwsem_do_wake(sem, 0);

diff -puN lib/rwsem-spinlock.c~rwsem-style lib/rwsem-spinlock.c
--- linux-2.6/lib/rwsem-spinlock.c~rwsem-style 2005-01-19 13:34:48.000000000 +1100
+++ linux-2.6-npiggin/lib/rwsem-spinlock.c 2005-01-19 13:39:06.000000000 +1100
@@ -10,9 +10,9 @@
#include <linux/module.h>

struct rwsem_waiter {
- struct list_head list;
- struct task_struct *task;
- unsigned int flags;
+ struct list_head list;
+ struct task_struct *task;
+ unsigned int flags;
#define RWSEM_WAITING_FOR_READ 0x00000001
#define RWSEM_WAITING_FOR_WRITE 0x00000002
};
@@ -41,7 +41,8 @@ void fastcall init_rwsem(struct rw_semap
}

/*
- * handle the lock release when processes blocked on it that can now run
+ * handle the lock being released whilst there are processes blocked on it
+ * that can now run.
* - if we come here, then:
* - the 'active count' _reached_ zero
* - the 'waiting count' is non-zero
@@ -83,7 +84,8 @@ __rwsem_do_wake(struct rw_semaphore *sem
goto out;
}

- /* grant an infinite number of read locks to the front of the queue */
+ /* grant an infinite number of read locks to the readers at the front
+ * of the queue */
dont_wake_writers:
woken = 0;
while (waiter->flags & RWSEM_WAITING_FOR_READ) {

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/