Date: Fri, 9 Jul 2021 13:24:26 GMT From: Kristof Provost <kp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: b43db87c97dd - stable/12 - pf: getstates: avoid taking the hashrow lock if the row is empty Message-ID: <202107091324.169DOQKH063419@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b43db87c97dd396da866919842715aef7b84daba commit b43db87c97dd396da866919842715aef7b84daba Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2021-06-29 09:34:49 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2021-07-09 08:08:32 +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 (cherry picked from commit a19ff8ce9b58548a5f965db2c46eb03c38b15edb) --- 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 0ce39db05c15..92b0cda8261e 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -5122,6 +5122,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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107091324.169DOQKH063419>