On Wed, Jul 07, 2021 at 10:20:01AM +0200, Alexandr Nedvedicky wrote:
>     we still need to agree on whether pf_test() can sleep (give up CPU),
>     when processing packet. I don't mind if pf_test() gives up CPU (sleeps),
>     when waiting for other packets to finish their business in pf(4).

I think pf should not sleep.  Network stack historically never
slept.  My guess is that best performance is achieved when each CPU
processes one packet from beginning to the end.  But we should run
many such CPUs in parallel.

But we should make progress in parallelizing the network stack.
Optimizations must be discussed later.

>     diff below makes sure all bridges call pf_test() _outside_ of smr_read()
>     section. Hrvoje successfully tested the diff with tpmr/veb bridges.

This looks like a quick fix for the problem.  One nit below.

OK bluhm@

>     this should be the only stopper I'm aware of.

Hrvoje found a panic in IPsec.  Without parallel diff it is broken
in a different way.  So more to fix...

> +static void
> +tpmr_p_take(void *p)
> +{
> +     struct tpmr_port *port = p;
> +
> +     atomic_inc_int((int *)(&port->p_refcnt));
> +}
> +
> +static void
> +tpmr_p_rele(void *p)
> +{
> +     struct tpmr_port *port = p;
> +     struct ifnet *ifp0 = port->p_ifp0;
> +
> +     if (atomic_dec_int_nv((int *)(&port->p_refcnt)) == 0) {
> +             if_put(ifp0);
> +             free(port, M_DEVBUF, sizeof(*port));
> +     }
> +}

Could you avoid the (int *) cast by choosing a consistent type?

Reply via email to