From: Eric Dumazet <eric.dumazet@gmail.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: xiaosuo@gmail.com, davem@davemloft.net, hagen@jauu.net,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next-2.6 v2] filter: optimize sk_run_filter
Date: Fri, 19 Nov 2010 15:35:06 +0100 [thread overview]
Message-ID: <1290177306.3034.129.camel@edumazet-laptop> (raw)
In-Reply-To: <201011192317.CFB48465.OtLFOJOMHQSFFV@I-love.SAKURA.ne.jp>
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.
next prev parent reply other threads:[~2010-11-19 14:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-19 2:04 [PATCH] net: reduce the lines of code Changli Gao
2010-11-19 6:35 ` Hagen Paul Pfeifer
2010-11-19 7:17 ` Changli Gao
2010-11-19 7:51 ` Eric Dumazet
2010-11-19 7:56 ` [PATCH net-next-2.6] filter: cleanup codes[] init Eric Dumazet
2010-11-19 8:04 ` [PATCH net-next-2.6] filter: use reciprocal divide Eric Dumazet
2010-11-19 8:18 ` Changli Gao
2010-11-19 18:07 ` David Miller
2010-11-19 8:38 ` [PATCH net-next-2.6] filter: cleanup codes[] init Changli Gao
2010-11-19 9:54 ` Eric Dumazet
2010-11-19 11:17 ` [PATCH net-next-2.6] filter: optimize sk_run_filter Eric Dumazet
2010-11-19 12:32 ` Changli Gao
2010-11-19 12:57 ` Changli Gao
2010-11-19 13:16 ` [PATCH net-next-2.6 v2] " Eric Dumazet
2010-11-19 14:13 ` Changli Gao
2010-11-19 17:52 ` David Miller
2010-11-19 14:17 ` Tetsuo Handa
2010-11-19 14:35 ` Eric Dumazet [this message]
2010-11-19 16:21 ` [PATCH net-next-2.6] " David Miller
2010-11-19 16:55 ` Eric Dumazet
2010-11-19 17:05 ` David Miller
2010-11-19 17:15 ` Stephen Hemminger
2010-11-19 17:21 ` David Miller
2010-11-19 17:16 ` Eric Dumazet
2010-11-19 17:25 ` David Miller
2010-11-19 12:21 ` [PATCH net-next-2.6] filter: cleanup codes[] init Changli Gao
2010-11-19 18:07 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290177306.3034.129.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=hagen@jauu.net \
--cc=netdev@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=xiaosuo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox