From mboxrd@z Thu Jan 1 00:00:00 1970 From: greg@kroah.com ('Greg KH') Date: Wed, 23 Jul 2014 10:48:02 -0700 Subject: question about kref API In-Reply-To: <4E5779AD88B2F040B8A7E83ECF544D1A533A14@SJCPEX01CL02.citrite.net> References: <4E5779AD88B2F040B8A7E83ECF544D1A5334B6@SJCPEX01CL02.citrite.net> <20140722021819.GF19215@kroah.com> <4E5779AD88B2F040B8A7E83ECF544D1A533793@SJCPEX01CL02.citrite.net> <20140722234703.GA11148@kroah.com> <4E5779AD88B2F040B8A7E83ECF544D1A533A14@SJCPEX01CL02.citrite.net> Message-ID: <20140723174802.GD16664@kroah.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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