git: a19ff8ce9b58 - main - pf: getstates: avoid taking the hashrow lock if the row is empty
Kristof Provost
kp at FreeBSD.org
Fri Jul 2 13:49:18 UTC 2021
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=a19ff8ce9b58548a5f965db2c46eb03c38b15edb
commit a19ff8ce9b58548a5f965db2c46eb03c38b15edb
Author: Kristof Provost <kp at FreeBSD.org>
AuthorDate: 2021-06-29 09:34:49 +0000
Commit: Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-07-02 12:47:54 +0000
pf: getstates: avoid taking the hashrow lock if the row is empty
Reviewed by: mjg
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30946
---
sys/netpfil/pf/pf_ioctl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index a802780277aa..9acfe56b7208 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -5054,6 +5054,10 @@ pf_getstates(struct pfioc_nv *nv)
for (int i = 0; i < pf_hashmask; i++) {
struct pf_idhash *ih = &V_pf_idhash[i];
+ /* Avoid taking the lock if there are no states in the row. */
+ if (LIST_EMPTY(&ih->states))
+ continue;
+
PF_HASHROW_LOCK(ih);
LIST_FOREACH(s, &ih->states, entry) {
if (s->timeout == PFTM_UNLINKED)
More information about the dev-commits-src-all
mailing list