Skip to content
Advertisement

Is there a way to lookup refcount for a kobject?

I expected to find a function along the lines of kobject_check_refcount, that returned the current refcount without altering it, in kobject.c, but as far as I can see there isn’t one. Is there such a function existing in the kernel source somewhere? I can see it being useful for debugging purposes at points.

Edit: found kref_read which sounds like it fits the bill. Just testing to see if it works as I’m expecting.

Advertisement

Answer

Yes, looks like kref_read is the right way to go.

static inline unsigned int kref_read(const struct kref *kref)
{
    return refcount_read(&kref->refcount);
}
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement