Re: Patch: linux-2.5.29 __downgrade_write() for CONFIG_RWSEM_GENERIC_SPINLOCK

Roman Zippel (zippel@linux-m68k.org)
Mon, 29 Jul 2002 00:55:26 +0200 (CEST)


Hi,

On Sun, 28 Jul 2002, Christoph Hellwig wrote:

> -static inline struct rw_semaphore *__rwsem_do_wake(struct rw_semaphore *sem)
> +static inline struct rw_semaphore *__rwsem_do_wake(struct rw_semaphore *sem, int wakewrite)
> {
> struct rwsem_waiter *waiter;
> int woken;
> @@ -56,7 +57,14 @@ static inline struct rw_semaphore *__rws
>
> 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
> + if (!wakewrite) {
> + if (waiter->flags & RWSEM_WAITING_FOR_WRITE)
> + goto out;
> + goto dont_wake_writers;
> + }
> +
> + /* if we are allowed to wake writers try to grant a single write lock if there's a
> + * writer at the front of the queue
> * - we leave the 'waiting count' incremented to signify potential contention
> */
> if (waiter->flags & RWSEM_WAITING_FOR_WRITE) {

You don't really need that extra argument, testing sem->activity should do
the same job.
If you exchange the wakewrite (or sem->activity) test and the
waiter->flags you can fold it into the next test (this means all the extra
work would only be done, if we have a writer waiting at the top).

bye, Roman

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