public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Gregory Haskins <ghaskins@novell.com>
Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org,
	mst@redhat.com, swhiteho@redhat.com
Subject: Re: [PATCH v4] slow-work: add (module*)work->ops->owner to fix races with module clients
Date: Tue, 07 Jul 2009 14:21:33 +0100	[thread overview]
Message-ID: <15258.1246972893@redhat.com> (raw)
In-Reply-To: <20090629191653.14240.44995.stgit@dev.haskins.net>

Gregory Haskins <ghaskins@novell.com> wrote:

> +	struct module *owner = work->ops->owner;
> +
> +	work->ops->put_ref(work);
> +	module_put(owner);

Hmmm...  There needs to be an smp_mb() between the read of the module owner
and the call to put_ref(), lest the CPU reorder things...  However, if
put_ref(), say, calls atomic_dec_and_test(), then inserting one here would be
superfluous.

I think documenting this will be enough - perhaps something like:

 (*) Release a reference on an item:

	void (*put_ref)(struct slow_work *work);

     This allows the thread pool to unpin an item by releasing the reference on
     it.  The thread pool will not touch the item again once this has been
     called.

     This function must interpolate a general SMP memory barrier before freeing
     or re-using the work struct as the caller may have read the module
     pointer.  Implying a barrier with something like atomic_dec_and_test() is
     sufficient.

Do you agree?

David

  parent reply	other threads:[~2009-07-07 13:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-29 19:24 [PATCH v4] slow-work: add (module*)work->ops->owner to fix races with module clients Gregory Haskins
2009-06-29 19:30 ` Gregory Haskins
2009-06-30  8:43 ` Steven Whitehouse
2009-06-30  9:07   ` Michael S. Tsirkin
2009-06-30  9:18     ` steve
2009-06-30 10:30       ` Michael S. Tsirkin
2009-06-30 12:09         ` Gregory Haskins
2009-07-07 13:21 ` David Howells [this message]
2009-07-07 13:29   ` Gregory Haskins
2009-07-07 16:52     ` David Howells

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=15258.1246972893@redhat.com \
    --to=dhowells@redhat.com \
    --cc=ghaskins@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=swhiteho@redhat.com \
    /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