Page MenuHomeFreeBSD

pf: add pf_bcmp_state_key
ClosedPublic

Authored by mjg on Nov 26 2021, 3:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 24, 6:28 AM
Unknown Object (File)
Feb 22 2024, 9:38 AM
Unknown Object (File)
Feb 21 2024, 2:56 PM
Unknown Object (File)
Feb 21 2024, 12:11 AM
Unknown Object (File)
Dec 20 2023, 5:28 AM
Unknown Object (File)
Dec 12 2023, 6:04 AM
Unknown Object (File)
Dec 3 2023, 7:59 PM
Unknown Object (File)
Sep 8 2023, 4:57 PM

Details

Summary

The comparison size of 40 bytes is known at compilation time but clang refuses to optimize it, thus hand-roll a short variant.

Benchmarked on a kernel with other changes on top of it. Interestingly it fails to provide a speed up, but instead it shifts CPU time elsewhere.

before: https://people.freebsd.org/~mjg/pf_nohashrow.svg
after: https://people.freebsd.org/~mjg/pf_nohashrow_custom_bcmp.svg

You can see time in netisr_dispatch -> ip_input -> ip_tryforward drop from 12.19 to 10.40 of the total.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mjg requested review of this revision.Nov 26 2021, 3:09 PM
sys/netpfil/pf/pf.c
431

s1ptr (and s2ptr) is not declared anywhere. Do you mean var1 = k1[0]?

433

Can't we do if (k1[0] != k2[0])?

mjg marked 2 inline comments as done.Nov 27 2021, 4:24 PM
mjg added inline comments.
sys/netpfil/pf/pf.c
431

i somehow upload the older version

There's one more in sys/netpfil/pf/pf_lb.c that could also use pf_bcmp_state_key() (in pf_get_translation()).

This revision is now accepted and ready to land.Nov 27 2021, 5:07 PM
This revision was automatically updated to reflect the committed changes.
mjg marked an inline comment as done.