[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1290177306.3034.129.camel@edumazet-laptop>
Date: Fri, 19 Nov 2010 15:35:06 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Cc: xiaosuo@...il.com, davem@...emloft.net, hagen@...u.net,
netdev@...r.kernel.org
Subject: Re: [PATCH net-next-2.6 v2] filter: optimize sk_run_filter
Le vendredi 19 novembre 2010 à 23:17 +0900, Tetsuo Handa a écrit :
> Just my thought again...
>
> Eric Dumazet wrote:
> > @@ -167,34 +168,36 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int
> > unsigned long memvalid = 0;
> > u32 tmp;
> > int k;
>
> Is this 'k' useful?
>
Yes this is useful, please read later we have :
k = X + K;
goto load_w;
K is readonly, k is a rw temp variable (on stack)
> > - int pc;
> >
> > BUILD_BUG_ON(BPF_MEMWORDS > BITS_PER_LONG);
> > /*
> > * Process array of filter instructions.
> > */
> > - for (pc = 0; pc < flen; pc++) {
> > - const struct sock_filter *fentry = &filter[pc];
> > - u32 f_k = fentry->k;
> > + for (;; fentry++) {
> > +#if defined(CONFIG_X86_32)
> > +#define K (fentry->k)
> > +#else
> > + const u32 K = fentry->k;
>
> What happens if we use
>
> u32 f_k = fentry->k;
>
> and
>
> > case BPF_S_LD_W_ABS:
> > - k = f_k;
> > + k = K;
>
> remove this assignment and
>
> > load_w:
> > ptr = load_pointer(skb, k, 4, &tmp);
>
> change to
>
> ptr = load_pointer(skb, (int) f_k, 4, &tmp);
>
> and
>
> > case BPF_S_LD_W_IND:
> > - k = X + f_k;
> > + k = X + K;
>
> change to
>
> f_k += X;
>
> ?
> > goto load_w;
This wont work, K is really a constant, part of the filter program,
while k is the (existing) temp variable.
--
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