From: Steven Rostedt <rostedt@goodmis.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, Linus Torvalds <torvalds@osdl.org>,
Andrew Morton <akpm@osdl.org>,
Arjan van de Ven <arjanv@infradead.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Christoph Hellwig <hch@infradead.org>, Andi Kleen <ak@suse.de>,
David Howells <dhowells@redhat.com>,
Alexander Viro <viro@ftp.linux.org.uk>,
Oleg Nesterov <oleg@tv-sign.ru>, Paul Jackson <pj@sgi.com>
Subject: Re: [patch 05/15] Generic Mutex Subsystem, mutex-core.patch
Date: Mon, 19 Dec 2005 00:00:06 -0500 [thread overview]
Message-ID: <1134968406.13138.235.camel@localhost.localdomain> (raw)
In-Reply-To: <20051219013718.GA28038@elte.hu>
On Mon, 2005-12-19 at 02:37 +0100, Ingo Molnar wrote:
> +static inline int
> +__mutex_lock_common(struct mutex *lock, struct mutex_waiter *waiter,
> + struct thread_info *ti, struct task_struct *task,
> + unsigned long *flags, unsigned long task_state
> __IP_DECL__)
> +{
> + unsigned int old_val;
> +
> + debug_lock_irqsave(&debug_lock, *flags, ti);
> + DEBUG_WARN_ON(lock->magic != lock);
> +
How expensive is the xchg? Since __mutex_lock_common is called even
when it's going to wake up. Maybe it might be more efficient to add
something like:
if (atomic_cmpxchg(&lock->count, 1, 0) {
debug_set_owner(lock, ti __IP__);
debug_unlock_irqrestore(&debug_lock, *flags, ti);
return 1;
}
This way we save the overhead of grabbing another spinlock, adding the
task to the wait_list and changing it's state.
> + spin_lock(&lock->wait_lock);
> + __add_waiter(lock, waiter, ti, task __IP__);
> + set_task_state(task, task_state);
> +
> + /*
> + * Lets try to take the lock again - this is needed even if
> + * we get here for the first time (shortly after failing to
> + * acquire the lock), to make sure that we get a wakeup once
> + * it's unlocked. Later on this is the operation that gives
> + * us the lock. We need to xchg it to -1, so that when we
> + * release the lock, we properly wake up other waiters!
> + */
> + old_val = atomic_xchg(&lock->count, -1);
> +
> + if (old_val == 1) {
-- Steve
next prev parent reply other threads:[~2005-12-19 5:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-19 1:37 Ingo Molnar
2005-12-19 3:56 ` Steven Rostedt
2005-12-19 4:15 ` Steven Rostedt
2005-12-19 4:21 ` Steven Rostedt
2005-12-19 4:43 ` Steven Rostedt
2005-12-19 5:00 ` Steven Rostedt [this message]
2005-12-19 5:09 ` Steven Rostedt
2005-12-19 16:51 ` Ingo Molnar
2005-12-19 5:12 ` Steven Rostedt
2005-12-19 16:43 ` Ingo Molnar
2005-12-19 5:16 ` Steven Rostedt
2005-12-21 16:21 ` Oleg Nesterov
2005-12-21 15:57 ` Ingo Molnar
2005-12-21 17:51 ` Oleg Nesterov
2005-12-21 18:26 ` Ingo Molnar
2005-12-21 15:59 ` Ingo Molnar
2005-12-21 16:02 ` Ingo Molnar
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=1134968406.13138.235.camel@localhost.localdomain \
--to=rostedt@goodmis.org \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arjanv@infradead.org \
--cc=dhowells@redhat.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=pj@sgi.com \
--cc=torvalds@osdl.org \
--cc=viro@ftp.linux.org.uk \
/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
Powered by JetHome