filter: optimize sk_run_filter
Remove pc variable to avoid arithmetic to compute fentry at each filter
instruction. Jumps directly manipulate fentry pointer.
As the last instruction of filter[] is guaranteed to be a RETURN, and
all jumps are before the last instruction, we dont need to check filter
bounds (number of instructions in filter array) at each iteration, so we
remove it from sk_run_filter() params.
On x86_32 remove f_k var introduced in commit 57fe93b374
(filter: make sure filters dont read uninitialized memory)
Note : We could use a CONFIG_ARCH_HAS_{FEW|MANY}_REGISTERS in order to
avoid too many ifdefs in this code.
This helps compiler to use cpu registers to hold fentry and A
accumulator.
On x86_32, this saves 401 bytes, and more important, sk_run_filter()
runs much faster because less register pressure (One less conditional
branch per BPF instruction)
# size net/core/filter.o net/core/filter_pre.o
text data bss dec hex filename
2948 0 0 2948 b84 net/core/filter.o
3349 0 0 3349 d15 net/core/filter_pre.o
on x86_64 :
# size net/core/filter.o net/core/filter_pre.o
text data bss dec hex filename
5173 0 0 5173 1435 net/core/filter.o
5224 0 0 5224 1468 net/core/filter_pre.o
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Esse commit está contido em:
@@ -1147,15 +1147,14 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff
|
||||
}
|
||||
|
||||
if (is->pass_filter
|
||||
&& sk_run_filter(skb, is->pass_filter, is->pass_len) == 0) {
|
||||
&& sk_run_filter(skb, is->pass_filter) == 0) {
|
||||
if (is->debug & 0x2)
|
||||
printk(KERN_DEBUG "IPPP: inbound frame filtered.\n");
|
||||
kfree_skb(skb);
|
||||
return;
|
||||
}
|
||||
if (!(is->active_filter
|
||||
&& sk_run_filter(skb, is->active_filter,
|
||||
is->active_len) == 0)) {
|
||||
&& sk_run_filter(skb, is->active_filter) == 0)) {
|
||||
if (is->debug & 0x2)
|
||||
printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n");
|
||||
lp->huptimer = 0;
|
||||
@@ -1294,15 +1293,14 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
|
||||
}
|
||||
|
||||
if (ipt->pass_filter
|
||||
&& sk_run_filter(skb, ipt->pass_filter, ipt->pass_len) == 0) {
|
||||
&& sk_run_filter(skb, ipt->pass_filter) == 0) {
|
||||
if (ipt->debug & 0x4)
|
||||
printk(KERN_DEBUG "IPPP: outbound frame filtered.\n");
|
||||
kfree_skb(skb);
|
||||
goto unlock;
|
||||
}
|
||||
if (!(ipt->active_filter
|
||||
&& sk_run_filter(skb, ipt->active_filter,
|
||||
ipt->active_len) == 0)) {
|
||||
&& sk_run_filter(skb, ipt->active_filter) == 0)) {
|
||||
if (ipt->debug & 0x4)
|
||||
printk(KERN_DEBUG "IPPP: link-active filter: reseting huptimer.\n");
|
||||
lp->huptimer = 0;
|
||||
@@ -1492,9 +1490,9 @@ int isdn_ppp_autodial_filter(struct sk_buff *skb, isdn_net_local *lp)
|
||||
}
|
||||
|
||||
drop |= is->pass_filter
|
||||
&& sk_run_filter(skb, is->pass_filter, is->pass_len) == 0;
|
||||
&& sk_run_filter(skb, is->pass_filter) == 0;
|
||||
drop |= is->active_filter
|
||||
&& sk_run_filter(skb, is->active_filter, is->active_len) == 0;
|
||||
&& sk_run_filter(skb, is->active_filter) == 0;
|
||||
|
||||
skb_push(skb, IPPP_MAX_HEADER - 4);
|
||||
return drop;
|
||||
|
Referência em uma nova issue
Block a user