Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Nov 2001 15:50:45 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Terry Lambert <tlambert2@mindspring.com>, Robert Watson <rwatson@FreeBSD.org>, freebsd-arch@FreeBSD.org
Subject:   Re: cur{thread/proc}, or not.
Message-ID:  <200111122350.fACNojg07127@apollo.backplane.com>
References:   <XFMail.011112153221.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
    You want to be very careful not to bloat the concept.  We
    already have severe bloatage in the mutex code and that has
    led to a lot of unnecessary complexity.  A huge amount,
    in fact.  We have so many types of mutexes it makes my
    head spin and I'm not very happy about it.  Forget about 
    'shared' verses 'exclusive'.  A reference count is a 
    reference count, that's all.  If you keep the concept
    simple you can implement more functionality horizontally
    rather then implementing more complexity vertically.

    For example, consider this API for pool mutexes.

    /*
     * obtain related pool mutex
     */
    void
    pool_mtx_lock(void *ptr);
    {
    }

    /*
     * release related pool mutex.
     */
    void
    pool_mtx_unlock(void *ptr)
    {
    }

    Now consider how this could be combined with, say,
    the zalloc() and zfree() code.  Consider how it could
    be combined with the refcount code.  It might even be
    possible to remove the stable-storage requirement.
    Consider a vnode verses its underlying VM object.
    Consider this:

    vp = vnode ... we already have a ref count on the vp.
    while ((object = vp->v_object) != NULL) {
	pool_mtx_lock(object)
	if (vp->v_object == object)
	    break;
	pool_mtx_unlock(object)
    }
    /* object guarenteed to be associated with vnode */
    ++object->ref_cnt;
    pool_mtx_unlock(object);

    ... continue working on object

    Structural overhead: 0 bytes
    Parallelism: high

    Now consider how this might be combined with the
    refcnt pool code:


    CODE PIECE 1:

    vp = vnode ... we already have a ref count on the vp.
    while ((object = vp->v_object) != NULL) {
	pool_mtx_lock(&object->ref_cnt);
	if (vp->v_object == object)
	    break;
	pool_mtx_unlock(&object->ref_cnt)
    }
    /* object guarenteed to be associated with vnode */
    ++object->ref_cnt;
    pool_mtx_unlock(&object->ref_cnt);

    CODE PIECE 2 (compatible with CODE PIECE 1):

    /* object is a known good object that will not be going away soon */
    refcnt_bump(&object->ref_cnt);
    ... use object ...
    refcnt_drop(&object->ref_cnt);


    And there you have it.  An utterly simple API of four
    routines (refcnt routines and pool routines), with a huge
    amount of capability.

					-Matt


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111122350.fACNojg07127>