From owner-freebsd-geom@FreeBSD.ORG Sat Dec 30 21:29:28 2006 Return-Path: X-Original-To: freebsd-geom@freebsd.org Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A017D16A403 for ; Sat, 30 Dec 2006 21:29:28 +0000 (UTC) (envelope-from arne_woerner@yahoo.com) Received: from web30308.mail.mud.yahoo.com (web30308.mail.mud.yahoo.com [209.191.69.70]) by mx1.freebsd.org (Postfix) with SMTP id 6A96713C44B for ; Sat, 30 Dec 2006 21:29:28 +0000 (UTC) (envelope-from arne_woerner@yahoo.com) Received: (qmail 34904 invoked by uid 60001); 30 Dec 2006 21:29:27 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=teH+4rBWtjaTfb06MP7YGy1w5u/zYskXDqLcBOrXmH+g0af4/bf2zQVIKBNgDGgCGWBqHLB7RKzG3SPQq8nxPBi0LeJQydZQdVJgnczcWnRrOBkmJLM432MwtmIFMwIPzXlye2V0ZuFK44wE9WeMykTtcBB2/YFfgXTrRgQERvY=; X-YMail-OSG: 8osjnPIVM1k.UKGwuE0Ysq_eW1qcvkqlURcmhaTGIb0hKxwJ.D4Rmqlz84Gseuv7YmmHdUx6wRcaooTvWvbSoNiyAHFW8kteHStQxIQdYHpMfVMMuk6yRfat5GFupiDDTXdkkvYJ3.t0L0ow5PJyjmKcHeWmGqCWuozYUgUVZ2t2yFi6qfjIz6rSinbDwpHjZU1pxcvYc.pyq_k- Received: from [85.212.9.158] by web30308.mail.mud.yahoo.com via HTTP; Sat, 30 Dec 2006 13:29:27 PST Date: Sat, 30 Dec 2006 13:29:27 -0800 (PST) From: "R. B. Riddick" To: Marius Nuennerich , freebsd-geom@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <876806.34709.qm@web30308.mail.mud.yahoo.com> Cc: Subject: Re: GEOM_AES using malloc with M_WAITOK X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Dec 2006 21:29:28 -0000 --- "R. B. Riddick" wrote: > --- Marius Nuennerich 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