Skip site navigation (1)Skip section navigation (2)
Date:      21 Jan 2001 17:41:44 +0100
From:      Dag-Erling Smorgrav <des@ofug.org>
To:        smp@freebsd.org
Subject:   MP-safing the zone allocator
Message-ID:  <xzp4rysluwn.fsf@flood.ping.uio.no>

next in thread | raw e-mail | index | archive | help
[this is my debut as SMP hacker, so I'll be grateful if you bear with
me while I think aloud on this list, and even more if you take the
time to point out flaws in my reasoning]

The zone allocator has a double set of API functions, one which is
supposedly MP-safe and one which isn't (but is slightly faster because
it doesn't grab the locks). The code is sprinkled with #ifdef SMP's so
that SMP kernels only use the MP-safe version of the API. The patch I
posted to -arch[1] removes the MP-unsafe API, which changes exactly
zilch in SMP kernels since they didn't use it to begin with. On UP
kernels, it adds the overhead of grabbing the lock, which is no big
deal - I think the reason for the MP-unsafe version was not so much to
avoid grabbing the locks as to avoid running at splvm, but that's a
no-op these days. And since the UP kernel is multithreaded, we *have*
to always use the MP-safe code anyway.

This is only the first of (as I see it) three stages in thread-safing
the zone allocator. The second stage is to convert the simplelocks to
mutices (Jason's simplelock_2.diff does most of that work). The third
stage is to add a mutex that protects zlist, and maybe convert zlist
to an SLIST or a TAILQ; when that is done, it should be possible to
call the zone allocator without holding Giant.

I'm pretty confident that the first patch is correct, so I'll commit
it once I've tested both UP and SMP kernels built with it. I'll submit
patches for the 2nd and 3rd stages for review as work progresses.

DES (feels like a newbie again)
-- 
Dag-Erling Smorgrav - des@ofug.org

[1] http://people.freebsd.org/~des/software/vm_zone-20010120.diff


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?xzp4rysluwn.fsf>