Messages in this thread | | | Date | Fri, 16 Jul 2004 21:20:49 +0530 | From | Ravikiran G Thirumalai <> | Subject | Re: [RFC] Refcounting of objects part of a lockfree collection |
| |
On Fri, Jul 16, 2004 at 07:32:35AM -0700, Greg KH wrote: >... > > We (Dipankar and myslef) had a discussion > > and decided: > > 1. I will make a patch to shrink kref and feed it to Greg > > 2. Add new set kref api for lockfree refcounting -- > > kref_lf_xxx. (kref_lf_get, kref_lf_get_rcu etc.,) > > kref_*_rcu() as Dipankar noted is much nicer.
Do you mean Dipankar had noted as in:
<Dipankar's earlier post> > Would this work - > > kref_get - just atomic inc > kref_put - just atomic dec > kref_get_rcu - cmpxchg if arch has or hashed spinlock > kref_put_rcu - dec if has cmpxchg else hashed spinlock
> If the object has lock-free look-up, it must use kref_get_rcu. > You can use kref_get on such an object if the look-up is being > done with lock. Is there a situation that is not covered by this ?
</>
If that is what you want, the api cannot work well. The problem with this case is I cannot use hashed spinlock _just_ for kref_get_rcu as Dipankar mentions above. If I do that the atomic_inc s in kref_get will race with the 'hashed spinlock' kref_get_rcu when both have to be used on the same refcounter. (I mentioned this in an earlier post). So I have to take the same hashed spinlock for kref_gets as well to maintain correctness -- obviously not a good thing for arches with no cmpxchg which use krefs for non lock free purposes only. Hence, the proposal now is to add kref_lf_get, kref_lf_put, kref_lf_get_rcu to the kref api. kref_lf_xxx is to be used when the kref refcounter is used atleast one place lock free -- that is kref_lf_get_rcu is used at atleast once on the struct kref. Does that sound ok?
Thanks, Kiran - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |