]> git.ipfire.org Git - people/ms/suricata.git/commit
Replace ringbuffer in Packet Pool with a stack for better cache locality
authorKen Steele <ken@tilera.com>
Fri, 28 Mar 2014 18:51:25 +0000 (14:51 -0400)
committerKen Steele <ken@tilera.com>
Mon, 21 Jul 2014 18:48:31 +0000 (14:48 -0400)
commit3c6e01f653225de320e96f2138204a9e62a5f3d7
tree020d8e94dcea3825ab25bcdd223e811799da4167
parent94571c5dd28858ff68c44b648fd41c5d87c0e28d
Replace ringbuffer in Packet Pool with a stack for better cache locality

Using a stack for free Packet storage causes recently freed Packets to be
reused quickly, while there is more likelihood of the data still being in
cache.

The new structure has a per-thread private stack for allocating Packets
which does not need any locking. Since Packets can be freed by any thread,
there is a second stack (return stack) for freeing packets by other threads.
The return stack is protected by a mutex. Packets are moved from the return
stack to the private stack when the private stack is empty.

Returning packets back to their "home" stack keeps the stacks from getting out
of balance.

The PacketPoolInit() function is now called by each thread that will be
allocating packets. Each thread allocates max_pending_packets, which is a
change from before, where that was the total number of packets across all
threads.
15 files changed:
src/decode.c
src/decode.h
src/source-af-packet.c
src/source-erf-dag.c
src/source-erf-file.c
src/source-ipfw.c
src/source-mpipe.c
src/source-napatech.c
src/source-nfq.c
src/source-pcap-file.c
src/source-pcap.c
src/source-pfring.c
src/suricata.c
src/tmqh-packetpool.c
src/tmqh-packetpool.h