[lkml]   [2006]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: kref refcnt and false positives
"Pallipadi, Venkatesh" <> writes:

>>But I believe Venkatesh problem comes from its release()
>>function : It is
>>supposed to free the object.
>>If not, it should properly setup it so that further uses are OK.
>>ie doing in release(kref)
>>atomic_set(&kref->count, 0);
> Agreed that setting kref refcnt to 0 in release will solve the probloem.
> But, once the optimization code is removed, we don't need to set it to
> zero as release will only be called after the count reaches zero anyway.

The primary point of the optimization is to not write allocate a cache line
unnecessarily. I don't know it's value, but it can have one especially
on big way SMP machines.

If the optimization is not performed setting the value to 0 immediately
there after has not real cost as your cpu has the dirty cache line
already. If the optimization is performed you still have to dirty
the cache line but at least you don't have to allocate it.

How that compares to the branch mispredict in cost I don't know, except
that cache line misses are the only operation that is generally
more expensive than branch misses.

So I see no virtue in avoiding the atomic_set(&kref->count, 0) if
you are about to immediately reuse the data structure.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2006-12-15 01:23    [W:0.030 / U:1.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site