All of lore.kernel.org
 help / color / mirror / Atom feed
From: greg@kroah.com ('Greg KH')
To: kernelnewbies@lists.kernelnewbies.org
Subject: question about kref API
Date: Wed, 23 Jul 2014 10:48:02 -0700	[thread overview]
Message-ID: <20140723174802.GD16664@kroah.com> (raw)
In-Reply-To: <4E5779AD88B2F040B8A7E83ECF544D1A533A14@SJCPEX01CL02.citrite.net>

On Wed, Jul 23, 2014 at 05:33:19PM +0000, Jeff Haran wrote:
> Clearly there are potential performance benefits in not needing to take
> locks or mutexes when they are not necessary.

Of course there are.  But trust me, you need to use a lock here, as the
document tries to explain, otherwise your code is broken.

> If you could elaborate on where the race condition is here, I think
> you'd being doing both me and the community a great service.

Nice try with the "Do it for the community because I don't understand
this!" appeal, that doesn't work for me, sorry...

I think you need to go look at the code closer and not get confused with
functions like kref_sub(), which you should never use unless you know
exactly what you are doing, and even then, I strongly discourage their
use (which is why there are only 2 users in the kernel.)  Focus on the
"normal" kref functions, and again, look at in-kernel users for examples
of how to use this properly.

Also, what are you trying to gain here, do you want to use a kref in
your code?  If so, please submit patches showing your usage and I will
be glad to review them.

greg k-h

  parent reply	other threads:[~2014-07-23 17:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-22  0:27 question about kref API Jeff Haran
2014-07-22  2:18 ` Greg KH
2014-07-22 17:25   ` Jeff Haran
2014-07-22 23:47     ` Greg KH
2014-07-23 17:33       ` Jeff Haran
2014-07-23 17:38         ` Jeff Haran
2014-07-23 17:48         ` 'Greg KH' [this message]
2014-07-23 17:55           ` Jeff Haran
2014-07-23 18:32             ` 'Greg KH'
2014-07-23 21:45             ` Valdis.Kletnieks at vt.edu

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=20140723174802.GD16664@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.