From: Ingo Molnar <mingo@elte.hu>
To: Pekka Enberg <penberg@kernel.org>
Cc: kvm@vger.kernel.org, Asias He <asias.hejun@gmail.com>,
Cyrill Gorcunov <gorcunov@gmail.com>
Subject: Re: [PATCH] kvm tools: Fix pthread mutex error checks
Date: Sat, 9 Apr 2011 15:15:47 +0200 [thread overview]
Message-ID: <20110409131547.GA12997@elte.hu> (raw)
In-Reply-To: <1302350278-5478-1-git-send-email-penberg@kernel.org>
* Pekka Enberg <penberg@kernel.org> wrote:
> The pthread_mutex_{lock|unlock} functions return non-zero, not negative number
> upon error. Fix that wrong assumption in the code.
glibc/pthreads mutex API semantics are pretty silly IMO.
I *think* it would be better to try to match the kernel API here, and provide
trivial wrappers around mutex_lock()/mutex_unlock(). We wont ever bring down
threads in a hostile way, so we wont actually need the error returns. CPU
threads should probably only exit once the kvm process exits, after all cleanup
has been done.
So mutex_lock() could be implemented as something like:
void mutex_lock(pthread_mutex_t mutex)
{
if (pthread_mutex_lock(mutex) != 0)
die("unexpected pthread_mutex_lock() failure!");
}
That way usage would be more obvious and more familar to kernel developers :-)
[ It would also open up the possibility, in the far future, to bring lockdep to
user-space ;-) ]
What do you think?
Thanks,
Ingo
prev parent reply other threads:[~2011-04-09 13:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-09 11:57 [PATCH] kvm tools: Fix pthread mutex error checks Pekka Enberg
2011-04-09 13:15 ` Ingo Molnar [this message]
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=20110409131547.GA12997@elte.hu \
--to=mingo@elte.hu \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=penberg@kernel.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