Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Apr 2002 18:04:37 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        Maksim Yevmenkin <myevmenk@digisle.net>
Cc:        freebsd-current@freebsd.org, freebsd-net@freebsd.org
Subject:   Re: Bluetooth stack for FreeBSD
Message-ID:  <Pine.BSF.4.21.0204151646350.88655-100000@InterJet.elischer.org>
In-Reply-To: <Pine.BSF.4.21.0204151548160.88655-100000@InterJet.elischer.org>

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


On Mon, 15 Apr 2002, Julian Elischer wrote:

> 
> [out of time for now.. will read more later]
> 
> Julian
> 


ok, read a bit more:

you say:
 
2) Locking/SMP
 
        External code now uses ng_send_fn to inject data into Netgraph, so
        it should be fine as long as Netgraph is SMP safe. Just need to
        verify it.
 
yes this is correct

While Netgraph is not completely SMP safe yet, this is only because there
are several nodes that do not do what you do here. By doing it corectly
here you have ensured that this will not be one of the nodes that needs to
be reworked when this becomes important. (soon).

Any node that changes it's internal state with reception of DATA 
(as opposed to control messages) should ensure that it by doing:
NG_NODE_FORCE_WRITER(node);

This is because in the default state, multiple data messages may 
(under SMP) be transitting the node at a time, as they 
only take out READER locks. If DATA can change some state variable or
similar then this becomes unsafe, and they should be serialised.
If only SOME data can do this, you have the option to takew reader-locks
and only after confirming that a message is a writer, upgrade to a writer
lock by 'requeueing' it as such. Alternatively teh sender can mark a
packet as 'writer'.


---

NG_NODE_PRIVATE(NG_HOOK_NODE(hook))
can be saved if you store information relavant to a hook in it's own 
private data pointer..
In some nodes I store the same data in NG_HOOK_PRIVATE(hook)
as is in NG_NODE_PRIVATE(node), just to save the dereference
if it's going to be done per packet. Sometimes there are better things to
store there however..


---

        /* Detach mbuf, discard item and process data */
        NGI_GET_M(item, m);
        NG_FREE_ITEM(item);

If there is any chance that you will need a new 'item' in a function or a
child function, then it's worth keeping them around to save teh expense of
re-allocating them..

I guess I shuld make a macro NG_FWD_DATA_HOOK() to make this easier to
do..

--


> 
> 
> 
> On Mon, 15 Apr 2002, Maksim Yevmenkin wrote:
> 
> > Folks,
> > 
> > [probably should be cc'd to -mobile as well]
> > 
> > An engineering release of Bluetooth stack for -current FreeBSD
> > is available for download at
> > 
> > http://www.geocities.com/m_evmenkin/ngbt-fbsd-20020415.tar.gz
> > 
> > i'm interested to hear from people who familiar with FreeBSD
> > kernel, Netgraph and/or Bluetooth. all your questions/comments/
> > suggestions are accepted and greatly appreciated. this is my
> > first Netgraph stack, so please don't me hard :)
> > 
> > thanks,
> > max
> > 
> > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > with "unsubscribe freebsd-current" in the body of the message
> > 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-current" in the body of the message
> 


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?Pine.BSF.4.21.0204151646350.88655-100000>