From: Eric Dumazet <eric.dumazet@gmail.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: mjt@tls.msk.ru, davem@davemloft.net, drosenberg@vsecurity.com,
hagen@jauu.net, xiaosuo@gmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH v3] filter: Optimize instruction revalidation code.
Date: Wed, 17 Nov 2010 08:48:57 +0100 [thread overview]
Message-ID: <1289980137.2732.280.camel@edumazet-laptop> (raw)
In-Reply-To: <201011170119.oAH1JpES011121@www262.sakura.ne.jp>
Le mercredi 17 novembre 2010 à 10:19 +0900, Tetsuo Handa a écrit :
> Eric Dumazet wrote:
> > I dont understand the problem...
> > Once translated, you have to test the translated code, not the original
> > one ;)
>
> I moved the test to after translation.
>
> > why u16 ?
> >
> > You store translated instructions, so u8 is OK
>
> I chose u16 because type of filter->code is __u16.
> But I changed to use u8 as you suggested that translated code fits in u8.
>
> > Also fix the indentation at the end of sk_chk_filter()
> >
> > You have 3 extra tabulations :
>
> Fixed.
>
> Hagen Paul Pfeifer wrote:
> > Maybe I don't get it, but you increment the opcode by one, but you never
> > increment the opcode in sk_run_filter() - do I miss something? Did you test
> > the your patch (a trivial tcpdump rule should be sufficient)?
>
> I added a comment line.
>
> Changli Gao wrote:
> > > + struct sock_filter *ftest = &filter[pc];
> >
> > Why move the define here?
>
> To suppress compiler's warning about mixed declaration.
>
> > > + u16 code = ftest->code;
> > >
> > > + if (code >= ARRAY_SIZE(codes))
> > > + return 0;
> >
> > return -EINVAL;
>
> Fixed in v2. Thanks.
>
> > But how about this:
> >
> > enum {
> > BPF_S_RET_K = 1,
>
> If BPF_S_* are only for kernel internal use, I think we don't need to translate
> from the beginning because only net/core/filter.c uses BPF_S_*.
>
> BPF_S_* are exposed to userspace via /usr/include/linux/filter.h since 2.6.36.
> Is it no problem to change?
No problem, and Changli posted patch to move them to net/core/filter.c
anyway.
>
> Filesize change (x86_32) by this patch:
> gcc 3.3.5: 7184 -> 5060
> gcc 4.4.3: 7972 -> 5588
> ----------------------------------------
> From b8777ab64bc31dbbe499eb62c2ffd29add7e79c8 Mon Sep 17 00:00:00 2001
> From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Date: Wed, 17 Nov 2010 09:46:33 +0900
> Subject: [PATCH v3] filter: Optimize instruction revalidation code.
>
> Since repeating u16 value to u8 value conversion using switch() clause's
> case statement is wasteful, this patch introduces u16 to u8 mapping table
> and removes most of case statements. As a result, the size of net/core/filter.o
> is reduced by about 29% on x86.
>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
> net/core/filter.c | 231 +++++++++++++++++------------------------------------
> 1 files changed, 72 insertions(+), 159 deletions(-)
>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Please repost it when Changli patch is accepted by David
(if accepted :)), to get rid of the "+ 1"
next prev parent reply other threads:[~2010-11-17 7:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 18:18 [PATCH] Prevent reading uninitialized memory with socketfilters Dan Rosenberg
2010-11-10 18:21 ` David Miller
2010-11-10 18:33 ` Eric Dumazet
2010-11-10 18:38 ` David Miller
2010-11-16 13:08 ` [PATCH] filter: Optimize instruction revalidation code Tetsuo Handa
2010-11-16 13:11 ` Michael Tokarev
2010-11-16 13:44 ` Eric Dumazet
2010-11-16 14:31 ` [PATCH v2] " Tetsuo Handa
2010-11-16 16:30 ` Eric Dumazet
2010-11-17 1:19 ` [PATCH v3] " Tetsuo Handa
2010-11-17 7:48 ` Eric Dumazet [this message]
2010-11-17 7:54 ` Changli Gao
2010-11-17 8:18 ` Eric Dumazet
2010-11-17 8:06 ` Tetsuo Handa
2010-11-17 9:01 ` Hagen Paul Pfeifer
2010-11-18 18:58 ` David Miller
2010-11-16 22:13 ` [PATCH] " Hagen Paul Pfeifer
2010-11-16 23:31 ` Changli Gao
2010-11-16 23:45 ` Hagen Paul Pfeifer
2010-11-16 23:24 ` Changli Gao
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=1289980137.2732.280.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=drosenberg@vsecurity.com \
--cc=hagen@jauu.net \
--cc=mjt@tls.msk.ru \
--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