From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: hagen@jauu.net, netdev@vger.kernel.org, xiaosuo@gmail.com
Subject: Re: [PATCH net-next-2.6] filter: optimize sk_run_filter
Date: Fri, 19 Nov 2010 17:55:59 +0100 [thread overview]
Message-ID: <1290185759.3034.179.camel@edumazet-laptop> (raw)
In-Reply-To: <20101119.082125.193710226.davem@davemloft.net>
Le vendredi 19 novembre 2010 à 08:21 -0800, David Miller a écrit :
> -EFIX_THE_DAMN_COMPILER
>
> We never make calls out of this function or touch volatile memory or
> create a full memory barrier between the assignment of f_k and it's
> uses.
>
> Therefore if common sub-expression elimination is working the compiler
> will be able to decide properly whether to access things via memory or
> use a register for the value.
>
> Remember this is why we have that ACCESS_ONCE() thing.
>
> We can't have it both ways, either ACCESS_ONCE() should be removed or
> we should never make changes like your's and instead should submit
> compiler bug reports :-)
Compiler is OK IMHO in this case. It does exactly what is required.
Compiler cannot load fentry->k before the switch() if some expression
dont use it, as it could trigger a fault.
After the "f_k = fentry->k;" commit, it was requested to do so.
Unfortunatly on x86_32 it also chose that f_k was more valuable in a cpu
register and accumulator A lost its register to get a stack slot
instead.
Not many BPF instructions use K, and if used, its used _once_ per BPF
instruction. There is no real gain to put it on a register, but code
size if (and only if) it is held in a cpu register, because each
assembler instruction using a register instead of stack is a bit
shorter.
In the end, I believe the "f_k = fentry->k;" was a good looking idea,
and good for some arches, but we forgot x86_32 (and probably some others)
have few available registers to play with.
Have a good week end !
next prev parent reply other threads:[~2010-11-19 16:56 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
2010-11-19 16:21 ` [PATCH net-next-2.6] " David Miller
2010-11-19 16:55 ` Eric Dumazet [this message]
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=1290185759.3034.179.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=hagen@jauu.net \
--cc=netdev@vger.kernel.org \
--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