From: David Howells <dhowells@redhat.com>
To: Gregory Haskins <ghaskins@novell.com>
Cc: dhowells@redhat.com,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] slow-work: add (module*)work->owner to fix races with module clients
Date: Wed, 24 Jun 2009 22:23:02 +0100 [thread overview]
Message-ID: <7230.1245878582@redhat.com> (raw)
In-Reply-To: <4A427F83.8010404@novell.com>
Gregory Haskins <ghaskins@novell.com> wrote:
> I found this while working on KVM. I actually posted this patch with
> a KVM
> series yesterday and standalone earlier today, but neither seems to have
> made it to the lists. I suspect there is an issue with git-mail/postfix
> on my system.
Also, your mail client has damaged the whitespace in the patch.
> struct slow_work {
> + struct module *owner;
Can you add it to slow_work_ops instead?
> work->ops->put_ref(work);
> + barrier(); /* ensure that put_ref is not re-ordered with module_put =
> */
> + module_put(work->owner);
Ummm... Can it be? module_put() and put_ref() are both out of line - surely
the compiler isn't allowed to reorder them? If it's the CPU doing it then
barrier() isn't going to save you.
Note, however, that work may not be dereferenced like this after put_ref() is
called, unless you're sure that there's still a reference outstanding.
> + if (!try_module_get(work->owner))
> + goto cant_get_mod;
Note that this may result in a module getting stuck in unloading. It may need
to do some work to complete the unload, and this will prevent that.
A better way might be to have put_ref() return, say, a pointer to a completion
struct, and if not NULL, have the caller of put_ref() call complete() on it.
That way you don't need to touch the module count, but can have something in
put_ref() keep track of when the last object is released and have its caller
invoke a completion to celebrate this fact.
David
next prev parent reply other threads:[~2009-06-24 21:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-24 19:33 [RFC PATCH] slow-work: add (module*)work->owner to fix races with module clients Gregory Haskins
2009-06-24 19:42 ` Gregory Haskins
2009-06-24 19:45 ` Gregory Haskins
2009-06-24 21:23 ` David Howells [this message]
2009-06-24 22:02 ` Gregory Haskins
-- strict thread matches above, loose matches on Subject: below --
2009-06-24 19:28 Gregory Haskins
2009-06-24 19:16 Gregory Haskins
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=7230.1245878582@redhat.com \
--to=dhowells@redhat.com \
--cc=ghaskins@novell.com \
--cc=linux-kernel@vger.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