Date: Tue, 16 Nov 2004 07:41:31 +0800 From: David Xu <davidxu@freebsd.org> To: John Baldwin <jhb@freebsd.org> Cc: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 65074 for review Message-ID: <41993EAB.3030108@freebsd.org> In-Reply-To: <200411151318.49415.jhb@FreeBSD.org> References: <200411140513.iAE5DOTv056478@repoman.freebsd.org> <200411151318.49415.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin wrote: >On Sunday 14 November 2004 12:13 am, David Xu wrote: > > >>http://perforce.freebsd.org/chv.cgi?CH=65074 >> >>Change 65074 by davidxu@davidxu_alona on 2004/11/14 05:12:40 >> >> 1. Fix a race between signal and umtx_unlock. a waiter >> may be resumed by signal and left or exited, heavily >> loaded test causes kernel to crash. >> 2. Use distributed queue locks instead of single giant >> lock. >> >>Affected files ... >> >>.. //depot/projects/davidxu_ksedbg/src/sys/kern/kern_umtx.c#4 edit >> >>Differences ... >> >>==== //depot/projects/davidxu_ksedbg/src/sys/kern/kern_umtx.c#4 (text+ko) >>==== >> >>@@ -49,25 +49,48 @@ >> pid_t uq_pid; /* Pid key component. */ >> }; >> >> #define UMTX_QUEUES 128 >> #define UMTX_HASH(pid, umtx) \ >>- (((uintptr_t)pid + ((uintptr_t)umtx & ~65535)) % UMTX_QUEUES) >>+ ((((uintptr_t)pid << 16) + ((uintptr_t)umtx & 65535)) % UMTX_QUEUES) >> >> > >I'm curious why you changed the hash macro here? Low order bits of pointers >tend to be zero due to alignment, so I think this will result in fewer >"useful" bits and more collisions and longer chains. > > > FYI, I changed back to original hash code: I simulate it under userland: printf("thread lock: %p hash=%d\n", &thread->lock, ((getpid() + ((unsigned)(&thread->lock) & ~0xFFFF))) % 128); get result: thread lock: 0x804e014 hash=39 thread lock: 0x8053014 hash=39 thread lock: 0x8056014 hash=39 thread lock: 0x805a014 hash=39 thread lock: 0x805d014 hash=39 thread lock: 0x8060014 hash=39 thread lock: 0x8063014 hash=39 thread lock: 0x8067014 hash=39 thread lock: 0x806a014 hash=39 thread lock: 0x806d014 hash=39 thread lock: 0x8070014 hash=39 So my version put all locks on chain 0, the orignal version put all locks on chain 39. :( Both seem bad algorithm. Note it is my private version of libpthread using thr and umtx, 1:1 only. David
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41993EAB.3030108>