Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jan 2009 01:24:51 -0800
From:      Julian Elischer <julian@elischer.org>
To:        Alfred Perlstein <alfred@freebsd.org>
Cc:        freebsd-current@freebsd.org, Hans Petter Selasky <hselasky@c2i.net>, current@freebsd.org, Maksim Yevmenkin <maksim.yevmenkin@gmail.com>
Subject:   Re: panic: mutex Giant not owned at	/usr/src/sys/kern/tty_ttydisc.c:1127
Message-ID:  <497C2FE3.6050304@elischer.org>
In-Reply-To: <20090125085405.GA87077@elvis.mu.org>
References:  <20090123154336.GJ60948@e.0x20.net>	<200901232337.05627.hselasky@c2i.net>	<bb4a86c70901231514x7696e457k3a6dc0e59d4daed7@mail.gmail.com>	<200901240952.21670.hselasky@c2i.net>	<bb4a86c70901240138g6a221fd4rbab3945193e4617@mail.gmail.com>	<20090125003010.GY87077@elvis.mu.org>	<bb4a86c70901241733x39b1a85dk3ff6531808dfae21@mail.gmail.com> <20090125085405.GA87077@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Alfred Perlstein wrote:
> * Maksim Yevmenkin <maksim.yevmenkin@gmail.com> [090124 17:33] wrote:
>> On Sat, Jan 24, 2009 at 4:30 PM, Alfred Perlstein <alfred@freebsd.org> wrote:
>>> From a purely academic standpoint... why can't netgraph use
>>> standard mutexes?
>>>
>>> Is there a pointer you can give me?
>> well, its not that netgraph can not use mutexes at all. its just that
>> there has to be an understanding between all subsystems that interact
>> with netgraph. its just like Julian said, everybody has to play nice
>> and ensure that control is given back to netgraph as soon as possible.
>> netgraph thread can not be de-scheduled for too long because the same
>> thread services other nodes. in fact, there are other netgraph nodes
>> that use mutexes, there is no way around it. the only rule is that
>> mutexes have to be used prudently. if there is a guarantee that every
>> single code path that is called from netgraph context is "safe" (i.e.
>> any mutexes that are touched in the code path are guaranteed to not
>> cause de-scheduling of netgraph thread for any significant amount of
>> time) then everything is fine.
>>
>> in any case, i really do hope that the patch that i send to Hans
>> Petter today (you were cc'd) is something that we all can agree on.
> 
> FWIW, with the exception of Giant, all normal mutexes have this
> guarantee.  Giant actually sort of has this guarantee, however it
> may be held for long periods of _activity_.
> 
> You can't "block" with a mutex, hence you'll never be behind
> a sleeping process, only a running process or tandem of running
> processes.
> 
well there is blocking and there is blocking..

if you block on a thread that is going to switch two pointers 
atomically then that is ok as this si not going to harm throughput
of netgraph as a whole. If you block for a thread that is allocating
memory, and re-arange the routing table or something large like that,
you can really screw up netgraph's thoughput as yo are blocking
a thread that ahs to do work in other places too and because your node 
has blocked it, other nodes are getting starved.

See my mail to arch on this topic.. I'm suggesting that there be
a flag for mutexes that label them as a 'leaf' mutex. By which I mean
the mutex 'call graph' will never see thes as anything as a
terminal node. Netgraph has no problems with using mutexes in this way,
but getting on a chain of mutexes some of which may take a while to 
clear ca totally screw it's usefulness.






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