[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4DA71876.803@redhat.com>
Date: Thu, 14 Apr 2011 18:53:26 +0300
From: Avi Kivity <avi@...hat.com>
To: Eric Dumazet <eric.dumazet@...il.com>
CC: Hagen Paul Pfeifer <hagen@...u.net>,
David Miller <davem@...emloft.net>,
netdev <netdev@...r.kernel.org>,
Arnaldo Carvalho de Melo <acme@...radead.org>,
Ben Hutchings <bhutchings@...arflare.com>
Subject: Re: [PATCH v2] net: filter: Just In Time compiler
On 04/14/2011 06:45 PM, Eric Dumazet wrote:
> Le jeudi 14 avril 2011 à 18:41 +0300, Avi Kivity a écrit :
>
> > I'm talking about optimizing the generated code. For example, bpf has
> > just two registers so a complex program generates a lot of loads and
> > stores. An optimizing compiler can use extra target registers to avoid
> > those spills, and doesn't need to keep A and X in fixed registers.
> >
>
> Thats not exactly true.
>
> A bpf filter also uses up to 16 mem[] 'registers'.
>
That's what I referred as loads and stores. Since you can't use mem[]
to index into a packet, you have to spill X into mem[], calculate a new
X, use it to access the packet, and reload X.
> A risc cpu (with a lot of registers) could use registers to hold part of
> the mem[] array.
An optimizing compiler will dynamically assign mem[] into registers,
even on i386. Liveness analysis means the same machine register can be
used for different mem[] locations.
> > If you translate the bpf program to C and optimize that with gcc you'll
> > probably get much better machine code that the jit in the patch.
> >
>
> Well, gcc wont optimize a lot a bpf program if you ask me.
IMO, it will. I'll try to have gcc optimize your example filter later.
> You would better make tcpdump not generate bpf but direct C code.
That involves breaking the interface (plus, we might not trust tcpdump).
--
error compiling committee.c: too many arguments to function
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists