Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Dec 2006 13:29:27 -0800 (PST)
From:      "R. B. Riddick" <arne_woerner@yahoo.com>
To:        Marius Nuennerich <marius.nuennerich@gmx.net>, freebsd-geom@freebsd.org
Subject:   Re: GEOM_AES using malloc with M_WAITOK
Message-ID:  <876806.34709.qm@web30308.mail.mud.yahoo.com>

next in thread | raw e-mail | index | archive | help
--- "R. B. Riddick" <arne_woerner@yahoo.com> wrote:
> --- Marius Nuennerich <marius.nuennerich@gmx.net> wrote:
> > I'm new to geom and thought I'd take an easy class to learn. So I read
> > geom_aes.c and noticed that it uses the M_WAITOK flag with g_malloc. In
> > another place I read, that it is not OK to sleep in the g_up and g_down
> > threads. Isn't this g_malloc called in one of these threads?
> >
> In both threads geom_aes calls g_malloc with M_WAITOK.
> Both threads set the TDP_NOSLEEPING flag before they call the class'
> function.
> On the other hand side it is allowed to use mtx_lock() in those threads,
> although it can cause delays, too (maybe those delays are different from
> sleep?).
> 
> In the ..._start() function it would be easy to push back the request for
> later processing with g_io_deliver(...,ENOMEM).
> 
> In the ..._done() function it would be not so easy, so that this memory, that
> is needed for each and every read request, should be allocated somewhere else
> and should have a pointer stored in softc (e. g. in ..._create()).
>
I looked a little bit at the kernel sources and found this:
1. mtx_lock uses turnstile_wait() in /sys/kern/kern_mutex.c, which (according
to /sys/kern/subr_turnstile.c) causes a context switch (no sleep), which is
obviously allowed with flag TDP_NOSLEEPING set...

2. malloc(9) uses uma_zalloc() or uma_large_malloc() which both use
uma_zone_slab() in /sys/vm/uma_core.c which uses msleep, which might be not
allowed with TDP_NOSLEEPING set (see subr_sleepqueue.c and kern_synch.c in
/sys/kern)...

-Arne
---
from "Boston Legal": "Denny Denny Denny Denny Crane"

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



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