aboutsummaryrefslogtreecommitdiff
path: root/sys/netpfil/pf/pf.c
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2020-12-13 16:20:02 +0000
committerKristof Provost <kp@FreeBSD.org>2021-01-05 22:35:37 +0000
commit5a3b9507d784aaa6a7ce35432b2111a7eec12cba (patch)
treecbc7f08f7b158464384abe50cebca2fb6732949f /sys/netpfil/pf/pf.c
parent26c841e2a402ed43896313d1b3f00facaa9d839f (diff)
downloadsrc-5a3b9507d784aaa6a7ce35432b2111a7eec12cba.tar.gz
src-5a3b9507d784aaa6a7ce35432b2111a7eec12cba.zip
pf: Convert pfi_kkif to use counter_u64
Improve caching behaviour by using counter_u64 rather than variables shared between cores. The result of converting all counters to counter(9) (i.e. this full patch series) is a significant improvement in throughput. As tested by olivier@, on Intel Xeon E5-2697Av4 (16Cores, 32 threads) hardware with Mellanox ConnectX-4 MCX416A-CCAT (100GBase-SR4) nics we see: x FreeBSD 20201223: inet packets-per-second + FreeBSD 20201223 with pf patches: inet packets-per-second +--------------------------------------------------------------------------+ | + | | xx + | |xxx +++| ||A| | | |A|| +--------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 5 9216962 9526356 9343902 9371057.6 116720.36 + 5 19427190 19698400 19502922 19546509 109084.92 Difference at 95.0% confidence 1.01755e+07 +/- 164756 108.584% +/- 2.9359% (Student's t, pooled s = 112967) Reviewed by: philip MFC after: 2 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D27763
Diffstat (limited to 'sys/netpfil/pf/pf.c')
-rw-r--r--sys/netpfil/pf/pf.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 6f4ccb99ad1f..4cccb0101650 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -6196,8 +6196,10 @@ done:
(s == NULL));
}
- kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS] += pd.tot_len;
- kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS]++;
+ counter_u64_add(kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS],
+ pd.tot_len);
+ counter_u64_add(kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS],
+ 1);
if (action == PF_PASS || r->action == PF_DROP) {
dirndx = (dir == PF_OUT);
@@ -6598,8 +6600,10 @@ done:
&pd, (s == NULL));
}
- kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS] += pd.tot_len;
- kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS]++;
+ counter_u64_add(kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS],
+ pd.tot_len);
+ counter_u64_add(kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS],
+ 1);
if (action == PF_PASS || r->action == PF_DROP) {
dirndx = (dir == PF_OUT);