Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jan 2002 09:29:56 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Alfred Perlstein <bright@mu.org>
Cc:        dillon@freebsd.org, smp@freebsd.org
Subject:   RE: making malloc(9) smp safe?
Message-ID:  <XFMail.020113092956.jhb@FreeBSD.org>
In-Reply-To: <20020113050836.Q7984@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On 13-Jan-02 Alfred Perlstein wrote:
> Malloc has its own mutex, however when it needs to do page allocations
> via kmem_malloc() it drops the mutex and calls it.
> 
> kmem_malloc() needs giant.
> 
> what do I do?
> 
> Do I grab giant before calling malloc(9)?

For now, yes.  Hmm, let me think though.  Can you get away with doing it for
malloc but not free?  People call free with locks held, but they don't call
malloc with locks held, so...

> Do I make malloc(9) aquire or recurse on giant automatically?
>   (basically grab giant around kmem_malloc() call in malloc(9))

This might be ok, just don't go calling malloc with locks held still. :)

> ?

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

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




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