Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Mar 2002 10:51:51 -0500 (EST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Maksim Yevmenkin <e.max@verizon.net>
Cc:        freebsd-current@freebsd.org
Subject:   RE: Netgraph, device drivers and mutexes
Message-ID:  <XFMail.020305105151.jhb@FreeBSD.org>
In-Reply-To: <3C827021.A7FA73A4@verizon.net>

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

On 03-Mar-02 Maksim Yevmenkin wrote:
> the same locking questions goes for the other Netgraph
> nodes that connected to the driver node. i want very 
> simple locks to do the following:
> 
> 1) handle timeouts with timeout(9)/untimeout(9) -
>    my _biggest_ concern. all i could find in -current is
>    everyone use splXXX/splx :( is it broken on SMP?
> 
> 2) modify node's internal data structure in a safe way.
>    i'm talking about things like linked lists, queues
>    etc.
> 
> since splXXX(9) functions are no longer relevant in
> -current (please correct me if i wrong), i was looking
> at mutex(9). i have noticed several device drivers that
> also use Netgraph (if_ar, if_sr, if_lmc and udbp), and 
> they use MTX_DEF mutexes and splXXX(9) functions. is that
> OK with Netgraph? the man page says that MTX_DEF mutexes
> _will_ context switch when they are already held. 

For now, I would not use any mutexes in your device driver code.
The network stack hasn't been locked so we still don't know what
actual locks will be needed in the device drivers themselves.
Netgraph has some custom reader/writer locks that you may need
to interface with.  Julian should be able to help you with that.

> can/should i use MTX_SPIN mutexes? i have tried to use
> them, but WITNESS code gets very upset (panic) unless i 
> modify "order_lists" in kern/subr_wintess.c. i would 
> rather not do it, since i'm not fully aware of what's 
> going on.

For now, avoid MTX_SPIN mutexes unless you have a fast
interrupt handler (INTR_FAST) (which you probably don't).

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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