git: 0d2ab4a4ced0 - main - pf: add hashtable row count SDT
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 09 Nov 2023 14:35:26 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=0d2ab4a4ced0f153a6b6a58ca3cfa6efbeeec7a2 commit 0d2ab4a4ced0f153a6b6a58ca3cfa6efbeeec7a2 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2023-11-09 12:39:56 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2023-11-09 13:21:53 +0000 pf: add hashtable row count SDT This allows us to figure out how many states each hashrow contains. That can be important to know when debugging performance issues. A simple probe could be: dtrace -n 'pf:purge:state:rowcount { @counts["states per row"] = quantize(arg1); }' dtrace: description 'pf:purge:state:rowcount ' matched 1 probe ^C states per row value ------------- Distribution ------------- count -1 | 0 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8257624 1 | 14321 2 | 0 MFC after: 1 week Sponsored by: Modirum MDPay --- sys/netpfil/pf/pf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 4990dce653b1..d5a9583d83f8 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -137,6 +137,7 @@ SDT_PROBE_DEFINE3(pf, eth, test_rule, mismatch, SDT_PROBE_DEFINE2(pf, eth, test_rule, match, "int", "struct pf_keth_rule *"); SDT_PROBE_DEFINE2(pf, eth, test_rule, final_match, "int", "struct pf_keth_rule *"); +SDT_PROBE_DEFINE2(pf, purge, state, rowcount, "int", "size_t"); /* * Global variables @@ -2174,6 +2175,7 @@ pf_purge_expired_states(u_int i, int maxcheck) struct pf_idhash *ih; struct pf_kstate *s; struct pf_krule_item *mrm; + size_t count; V_pf_status.states = uma_zone_get_cur(V_pf_state_z); @@ -2181,6 +2183,7 @@ pf_purge_expired_states(u_int i, int maxcheck) * Go through hash and unlink states that expire now. */ while (maxcheck > 0) { + count = 0; ih = &V_pf_idhash[i]; /* only take the lock if we expect to do work */ @@ -2203,10 +2206,13 @@ relock: mrm->r->rule_ref |= PFRULE_REFS; if (s->rt_kif) s->rt_kif->pfik_flags |= PFI_IFLAG_REFS; + count++; } PF_HASHROW_UNLOCK(ih); } + SDT_PROBE2(pf, purge, state, rowcount, i, count); + /* Return when we hit end of hash. */ if (++i > pf_hashmask) { V_pf_status.states = uma_zone_get_cur(V_pf_state_z);