Re: kref refcnt and false positives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 13, 2006 at 04:12:46PM -0800, Greg KH wrote:
> On Wed, Dec 13, 2006 at 03:34:08PM -0800, Venkatesh Pallipadi wrote:
> > 
> > With WARN_ON addition to kobject_init()
> > [ http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.19/2.6.19-mm1/dont-use/broken-out/gregkh-driver-kobject-warn.patch ]
> > 
> > I started seeing following WARNING on CPU offline followed by online on my
> > x86_64 system.
> > 
> > WARNING at lib/kobject.c:172 kobject_init()
> > 
> > This is a false positive as mce.c is unregistering/registering sysfs
> > interfaces cleanly on hotplug.
> 
> The warning above tends to look like this is not true.
> 
> > kref_put() and conditional decrement of refcnt seems to be the root cause
> > for this and the patch below resolves the issue for me.
> 
> Why?
> 
> Are you properly initializing your kref to null before you register it
> with the driver core?  Or is it a static object?
> 

Yes. arch/x86_64/kernel/mce.c is calling sysdev_register and sysdev_unregister
for cpu hot_add and hot_remove respectively.

The problem is that due to the perf optimization, refcnt remains at 1
even after unregister (as it never gets decremented to 0 in kref_put()).

So, when we try to register next time for same sysdev (The object is percpu,
so previously set refcnt will remain 1), init sees that refcnt is already 1
and print out the WARNing.


> > Original comment seemed to indicate that this conditional thing was
> > performance related. Is it really? If not, we should consider the below patch.
> 
> Yes, it's a performance gain and I don't see how this patch would change
> the above warning.
> 

In that case, I think we should change the WARN_ON in question to check for > 1.

Thanks,
Venki
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux