From owner-freebsd-arch Mon Nov 12 16:34:54 2001 Delivered-To: freebsd-arch@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 2E4B937B416; Mon, 12 Nov 2001 16:34:52 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id fAD0YqV07450; Mon, 12 Nov 2001 16:34:52 -0800 (PST) (envelope-from dillon) Date: Mon, 12 Nov 2001 16:34:52 -0800 (PST) From: Matthew Dillon Message-Id: <200111130034.fAD0YqV07450@apollo.backplane.com> To: John Baldwin Cc: freebsd-arch@FreeBSD.org, Robert Watson , Terry Lambert Subject: Re: cur{thread/proc}, or not. References: Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG :is how does your pool work? Do you pick a mutex out of the pool at init time :like the lockmgr locks work? Or do you use a hash on the object address? I was thinking non-chained hash on the object address. Real simple. (((int)ptr >> 5) ^ (int)ptr) & MASK or something like that. Or something even simpler... basically something we can play around with and optimize later without breaking the API we've constructed. :Well, there are different ways of doing lock pools. :) How about something :like this: : :/* : * Returns lock for address 'ptr'. : * :mtx_pool_find(void *ptr) :{ :} : :#define mtx_pool_lock(p) mtx_lock(mtx_pool_find((p))) :#define mtx_pool_unlock(p) mtx_unlock(mtx_pool_find((p)) : :Then if a structure (like lockmgr locks or sx locks) wants to cache the lock :pointer instead of doing the hash all the time, it can just do : : foo->f_lock = mtx_pool_find(foo); : :This actually isn't all that difficult, it just adds the ability to lookup and :cache the mutex associated with an address. I would also like it under mtx_* :so it's clear what type of locks are in the pool, but that's just me. :) Yes I think the addition of a mtx_pool_find() call is excellent! A wonderful example of horizontal expansion (rather then vertical complexity, or vertical complication if I'm being cute). -Matt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message