Re: Lockless uidinfo.
- From: Alfred Perlstein <alfred@xxxxxxxxxxx>
- Date: Sat, 18 Aug 2007 10:17:38 -0700
* Pawel Jakub Dawidek <pjd@xxxxxxxxxxx> [070818 09:14] wrote:
On Sat, Aug 18, 2007 at 08:50:41AM -0700, Alfred Perlstein wrote:
* Pawel Jakub Dawidek <pjd@xxxxxxxxxxx> [070818 07:59] wrote:
Yes, to lookup uidinfo you need to hold uihashtbl_mtx mutex, so once you
hold it and ui_ref is 0, noone will be able to reference it, because it
has to wait to look it up.
And the field doesn't need to be volatile to prevent cached/opportunitic
reads?
The only chance of something like this will be the scenario below:
thread1 (uifind) thread2 (uifree)
---------------- ----------------
refcount_release(&uip->ui_ref))
/* ui_ref == 0 */
mtx_lock(&uihashtbl_mtx);
refcount_acquire(&uip->ui_ref);
/* ui_ref == 1 */
mtx_unlock(&uihashtbl_mtx);
mtx_lock(&uihashtbl_mtx);
if (uip->ui_ref > 0) {
mtx_unlock(&uihashtbl_mtx);
return;
}
Now, you suggest that ui_ref in 'if (uip->ui_ref > 0)' may still have
cached 0? I don't think it is possible, first refcount_acquire() uses
read memory bariers (but we may still need ui_ref to volatile for this
to make any difference) and second, think of ui_ref as a field protected
by uihashtbl_mtx mutex in this very case.
Is my thinking correct?
I don't know, that's why I was asking you. :)
--
- Alfred Perlstein
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Lockless uidinfo.
- From: Pawel Jakub Dawidek
- Re: Lockless uidinfo.
- References:
- Lockless uidinfo.
- From: Pawel Jakub Dawidek
- Re: Lockless uidinfo.
- From: Alfred Perlstein
- Re: Lockless uidinfo.
- From: Pawel Jakub Dawidek
- Re: Lockless uidinfo.
- From: Alfred Perlstein
- Re: Lockless uidinfo.
- From: Pawel Jakub Dawidek
- Lockless uidinfo.
- Prev by Date: Re: Lockless uidinfo.
- Next by Date: Re: Lockless uidinfo.
- Previous by thread: Re: Lockless uidinfo.
- Next by thread: Re: Lockless uidinfo.
- Index(es):
Relevant Pages
|
|