Re: multi bpf filter will impact performance?

Changli Gao
2010-12-01T07:36:35Z

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

On Wed, Dec 1, 2010 at 11:48 AM, Rui <wirelesser@gmail.com> wrote:
> one more question is
>
> if  RPS can spread the load into 4 separate cpus, how about the
> "packet_rcv(or tpacket_rcv)" ? will they run in parallel?
>

You mentioned RPS. But the current bpf doesn't have an instruction to
get the current CPU number. You can try this patch attached.

Maybe we can leverage the bpf and SO_REUSEPORT to direct the traffic
to the socket instance on the local CPU.

--
Regards,
Changli Gao(xiaosuo@gmail.com)

[-- Attachment #2: bpf_cpu.diff --]
[-- Type: text/plain, Size: 728 bytes --]

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 447a775..35db44a 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -124,7 +124,8 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
#define SKF_AD_MARK 20
#define SKF_AD_QUEUE 24
#define SKF_AD_HATYPE 28
-#define SKF_AD_MAX 32
+#define SKF_AD_CPU 32
+#define SKF_AD_MAX 36
#define SKF_NET_OFF (-0x100000)
#define SKF_LL_OFF (-0x200000)

diff --git a/net/core/filter.c b/net/core/filter.c
index a44d27f..3baa3f7 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -410,6 +410,9 @@ load_b:
A = 0;
continue;
}
+ case SKF_AD_CPU:
+ A = raw_smp_processor_id();
+ continue;
default:
return 0;
}