Date: Tue, 2 Apr 2002 14:13:22 -0800 (PST) From: Matthew Dillon <dillon@apollo.backplane.com> To: Alfred Perlstein <bright@mu.org> Cc: hackers@FreeBSD.ORG, jeffr@FreeBSD.ORG Subject: Re: mpsafe malloc Message-ID: <200204022213.g32MDM517925@apollo.backplane.com> References: <20020402212646.GV93885@elvis.mu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Well, if UMA is going to eventually remove kmem_map and
just use kernel_map (or vise-versa), then the issue comes
down to why kernel_map->lock is lockmgr lock in the
first place, instead of a mutex.
I think the reason is historical. Basically kernel_map was
originally a struct vm_map just like the vm_map's used
everywhere else in the system. But then all sorts of
problems cropped up and it had to be special cased...
but what REALLY should have happened is that we should
have stopped using the stupid struct lock for kernel_map.
Perhaps for the case of kernel_map and only kernel_map,
the 'lock' field should be ignored entirely (1) and a
kernel_map_mtx (a global mutex) be used instead.
Then we don't have to screw around with it at all, we would
not have to worry about 'blocking' situations in the sturct lock
sense, only in the mtx_lock() sense.
Am I making any sense here?
-
note (1): In fact, the kernel_map->lock should be initialized such
that the system panics if anyone tries to play with it.
-Matt
:Started looking at making malloc mpsafe.
:
:First issue I came across was this brokenish code in
:uma_core.c:page_alloc():
:
: if (lockstatus(&kernel_map->lock, NULL)) {
: *pflag = UMA_SLAB_KMEM;
: p = (void *) kmem_malloc(kmem_map, bytes, wait);
: } else {
: *pflag = UMA_SLAB_KMAP;
: p = (void *) kmem_alloc(kernel_map, bytes);
: }
:
:using lockstatus won't work for smp.
:
:I think a solution is to do a trylock on the kmem_map, then have
:kmem_malloc either recurse on the lock, or take a flag to tell it
:not to bother locking.
:
:?
:--
:-Alfred Perlstein [alfred@freebsd.org]
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204022213.g32MDM517925>
