Re: [PATCH 0/3] refcounting improvements in sysfs.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Tejun Heo
Date: Thursday, March 25, 2010 - 9:49 pm

Hello,

On 03/24/2010 12:20 PM, NeilBrown wrote:

Nice article.  In general, yeap, I agree it would be nice to have a
working reference count abstraction.  However, kref along with kobject
is a good example of obscurity by abstraction anti pattern.  :-)

kobject API incorrectly suggests that it deals with the last put
problem.  There still are large number of code paths which do the
following,

  if (!(kob = kobject_get(kobj)))
	return;

I believe (or at least hope) the actual problem cases are mostly fixed
now but there still are a lot of misconceptions around how stuff built
on kref/kobject is synchronized and they sometimes lead to race
conditions buried deep under several layers of abstractions and it
becomes very hard to see those race conditions when they are buried
deep.

If you want to kill refcounts w/ bias based off switch, please put it
inside an abstraction which at least synchronizes itself properly.
Open coding w/ bias at least warns you that there is some complex
stuff going on and you need to trade carefully.  Putting the switch on
a separate flag - people often forget how bits in a flag field are
synchronized - and the rest of refcount in a nice looking kref bundle
is very likely to lead to subtle race conditions which are *very*
difficult to notice.

Thanks.

-- 
tejun
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 2/3] sysfs: make s_count a kref, NeilBrown, (Tue Mar 23, 8:20 pm)
[PATCH 0/3] refcounting improvements in sysfs., NeilBrown, (Tue Mar 23, 8:20 pm)
Re: [PATCH 0/3] refcounting improvements in sysfs., Eric W. Biederman, (Thu Mar 25, 8:10 pm)
Re: [PATCH 0/3] refcounting improvements in sysfs., Neil Brown, (Thu Mar 25, 8:28 pm)
Re: [PATCH 1/3] sysfs: simplify handling for s_active refcount, Eric W. Biederman, (Thu Mar 25, 9:24 pm)
Re: [PATCH 2/3] sysfs: make s_count a kref, Eric W. Biederman, (Thu Mar 25, 9:29 pm)
Re: [PATCH 0/3] refcounting improvements in sysfs., Tejun Heo, (Thu Mar 25, 9:49 pm)
Re: [PATCH 3/3] kref: create karef and use for sysfs_diren ..., Eric W. Biederman, (Thu Mar 25, 9:50 pm)
Re: [PATCH 0/3] refcounting improvements in sysfs., Tejun Heo, (Thu Mar 25, 10:10 pm)
Re: [PATCH 0/3] refcounting improvements in sysfs., Neil Brown, (Thu Mar 25, 11:02 pm)
Re: [PATCH 0/3] refcounting improvements in sysfs., Tejun Heo, (Thu Mar 25, 11:32 pm)
Re: [PATCH 1/3] sysfs: simplify handling for s_active refcount, Eric W. Biederman, (Fri Mar 26, 12:53 am)
Re: [PATCH 0/3] refcounting improvements in sysfs., Neil Brown, (Sun Mar 28, 10:10 pm)
Re: [PATCH 0/3] refcounting improvements in sysfs., Tejun Heo, (Tue Mar 30, 8:20 pm)