public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: David Howells <dhowells@redhat.com>,
	Christoph Hellwig <hch@infradead.org>,
	"Adam J. Richter" <adam@yggdrasil.com>,
	linux-kernel@vger.kernel.org
Subject: Re: Patch: linux-2.5.29 __downgrade_write() for CONFIG_RWSEM_GENERIC_SPINLOCK
Date: Mon, 29 Jul 2002 09:31:55 +0100	[thread overview]
Message-ID: <20869.1027931515@warthog.cambridge.redhat.com> (raw)
In-Reply-To: Message from Roman Zippel <zippel@linux-m68k.org>  of "Mon, 29 Jul 2002 10:01:26 +0200." <Pine.LNX.4.44.0207290958010.28515-100000@serv>


Roman Zippel <zippel@linux-m68k.org> wrote:
> Did you look at the code? gcc should be able to optimize that itself.

Maybe... gcc should also optimise my version to the same extent, I think (the
result of one of the additional tests is known at compile time, and the other
one is the same as the next test down). What I'm unsure about is how gcc will
handle the variable being stored in memory not marked volatile and then
retrieved again; whether it'll actually issue a read, or just assume it's got
it cached.

However, I've changed it to your suggestion, and I'm compiling it to have a
look. I've attached the changed C file for your perusal.

David


static inline struct rw_semaphore *__rwsem_do_wake(struct rw_semaphore *sem)
{
	struct rwsem_waiter *waiter;
	int woken;

	rwsemtrace(sem,"Entering __rwsem_do_wake");

	waiter = list_entry(sem->wait_list.next,struct rwsem_waiter,list);

	/* 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) {
		if (!sem->activity) {
			sem->activity = -1;
			list_del(&waiter->list);
			waiter->flags = 0;
			wake_up_process(waiter->task);
		}
		goto out;
	}

	/* grant an infinite number of read locks to the readers at the front of the queue */
	woken = 0;
	while (waiter->flags&RWSEM_WAITING_FOR_READ) {
		struct list_head *next = waiter->list.next;

		list_del(&waiter->list);
		waiter->flags = 0;
		wake_up_process(waiter->task);
		woken++;
		if (list_empty(&sem->wait_list))
			break;
		waiter = list_entry(next,struct rwsem_waiter,list);
	}

	sem->activity += woken;

 out:
	rwsemtrace(sem,"Leaving __rwsem_do_wake");
	return sem;
}

  reply	other threads:[~2002-07-29  8:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-28 17:50 Patch: linux-2.5.29 __downgrade_write() for CONFIG_RWSEM_GENERIC_SPINLOCK Adam J. Richter
2002-07-28 18:07 ` Roman Zippel
2002-07-28 18:08 ` Christoph Hellwig
2002-07-28 22:55   ` Roman Zippel
2002-07-29  7:42     ` David Howells
2002-07-29  8:01       ` Roman Zippel
2002-07-29  8:31         ` David Howells [this message]
2002-07-29  9:13           ` David Howells
2002-07-29 11:42             ` Roman Zippel
2002-07-29 12:08               ` David Howells
2002-07-29 12:46                 ` Roman Zippel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20869.1027931515@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=adam@yggdrasil.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox