Re: [PATCH 1/3] sysfs: simplify handling for s_active refcount

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Neil Brown
Date: Thursday, March 25, 2010 - 10:32 pm

On Thu, 25 Mar 2010 21:24:43 -0700
ebiederm@xmission.com (Eric W. Biederman) wrote:


As you say, this is only a liveness issue.  The atomic_inc_not_zero
guarantees that we don't take a new reference after the last one is gone.
The test on SYSFS_FLAG_REMOVED is only there to ensure that the count does
eventually get to zero.
There could only be a problem here if the change to s_flags was not
propagated to all CPUs in some reasonably small time.

I'm not expert on these things but it was my understanding that interesting
cache architectures could arbitrarily re-order accesses, but does not delay
them indefinitely.
Inserting barriers could possibly make this more predictable, but that would
just delay certain loads/stores until a known state was reached - it would
not make the data visible at another CPU any faster (or would it?).

So unless there is no cache-coherency protocol at all, I think that
SYSFS_FLAG_REMOVED will be seen promptly and that s_active will drop to zero
and quickly as it does today.


I'm pleased you find it attractive - I certainly think the
"atomic_inc_not_zero" is much more readable than the code it replaces.
Hopefully if there are really problems (maybe I've fundamentally
misunderstood caches) they can be easily resolved (a couple of memory
barriers at worst?).

Thanks for the review,
NeilBrown
--
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 1/3] sysfs: simplify handling for s_active refcount, Neil Brown, (Thu Mar 25, 10:32 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)