Re: [PATCH 1/2] kref: add kref_test_and_get

From: Jerome Marchand
Date: Wed Jan 05 2011 - 08:35:27 EST


On 01/04/2011 09:57 PM, Greg KH wrote:
> On Tue, Jan 04, 2011 at 04:52:26PM +0100, Jerome Marchand wrote:
>>
>> Add kref_test_and_get() function, which atomically add a reference only if
>> refcount is not zero. This prevent to add a reference to an object that is
>> already being removed.
>
> We just removed a function like this recently as it really isn't the
> solution for what you need here at all.

What function are you talking about? kref_set? If yes, I don't see the
similarity between this function and mine.

Regards
Jerome

>
> Please use a lock that protects the desctruction of the kref, like the
> rest of the kernel, to keep someone from grabing a reference while the
> device could be going away. That's the only way to safely do this.
>
> See the archives for why this overall, isn't a good idea for a kref to
> have this type of function.
>
> thanks,
>
> greg k-h

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/