Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jul 2003 19:05:58 +0200 (CEST)
From:      Harti Brandt <brandt@fokus.fraunhofer.de>
To:        hackers@freebsd.org
Subject:   SMP problem with uma_zalloc
Message-ID:  <20030718185122.N14232@beagle.fokus.fraunhofer.de>

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

Hi all,

it seems there is a problem with the zone allocator in SMP systems.

I have a zone, that has an upper limit on items that resolves to an
upper limit of pages of 1. It turns out, that allocations from this
zone get stuck from time to time. It seems to me, that the following
happens:

- on the first call to uma_zalloc a page is allocated and all the free
items are put into the cache of the CPU. uz_free of the zone is 0 and
uz_cachefree holds all the free items.

- when the next call to uma_zalloc occurs on the same CPU, everything is
fine. uma_zalloc just gets the next item from the cache.

- when the call happens on another CPU, the code finds uz_free to be 0 and
checks the page limit (uma_core.c:1492). It finds the limit already
reached and puts the process to sleep (uma_zalloc was called with
M_WAITOK).

- the process may sleep there forever (depending on circumstances).

If M_WAITOK is not set, the code will falsely return NULL while there
are still free items (albeight in the cache of another CPU).

I wonder whether this is intended behaviour. If yes, this should be
definitely documented. uma_zone_set_max() seems to be documented only in
the header file and it does not mention, that free items may not actually
be allocatable because they happen to sit in another CPU's cache.

If it is not intended (I would prefer this), I wonder how one can get the
items out of another's CPU cache. I'm not too familiar with this code.
I suppose this should be done somewhere around uma_core.c:1485?

Regards,
harti
-- 
harti brandt,
http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private
brandt@fokus.fraunhofer.de, harti@freebsd.org



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