To improve hardware offload debuggability extend struct netns_nftables with 'count_wq_stats' counter and expose it to userspace as 'nf_flowtable_count_wq_stats' sysctl entry. Increment the counter when allocating new workqueue task and decrement it after flow_offload_work_stats() is finished. Signed-off-by: Vlad Buslov <vladbu@xxxxxxxxxx> Signed-off-by: Oz Shlomo <ozsh@xxxxxxxxxx> Reviewed-by: Paul Blakey <paulb@xxxxxxxxxx> --- include/net/netns/nftables.h | 1 + net/netfilter/nf_conntrack_standalone.c | 8 ++++++++ net/netfilter/nf_flow_table_offload.c | 3 +++ 3 files changed, 12 insertions(+) diff --git a/include/net/netns/nftables.h b/include/net/netns/nftables.h index ad6058d2b5f9..60b3905c0ae9 100644 --- a/include/net/netns/nftables.h +++ b/include/net/netns/nftables.h @@ -11,6 +11,7 @@ struct netns_nftables { atomic_t count_wq_add; int max_wq_add; atomic_t count_wq_del; + atomic_t count_wq_stats; }; #endif diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index cebdf389f7eb..4ec49ff6593c 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c @@ -624,6 +624,7 @@ enum nf_ct_sysctl_index { NF_SYSCTL_CT_COUNT_WQ_ADD, NF_SYSCTL_CT_MAX_WQ_ADD, NF_SYSCTL_CT_COUNT_WQ_DEL, + NF_SYSCTL_CT_COUNT_WQ_STATS, #endif __NF_SYSCTL_CT_LAST_SYSCTL, @@ -1012,6 +1013,12 @@ static struct ctl_table nf_ct_sysctl_table[] = { .mode = 0444, .proc_handler = proc_dointvec, }, + [NF_SYSCTL_CT_COUNT_WQ_STATS] = { + .procname = "nf_flowtable_count_wq_stats", + .maxlen = sizeof(int), + .mode = 0444, + .proc_handler = proc_dointvec, + }, #endif {} }; @@ -1155,6 +1162,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net) table[NF_SYSCTL_CT_COUNT_WQ_ADD].data = &net->nft.count_wq_add; table[NF_SYSCTL_CT_MAX_WQ_ADD].data = &net->nft.max_wq_add; table[NF_SYSCTL_CT_COUNT_WQ_DEL].data = &net->nft.count_wq_del; + table[NF_SYSCTL_CT_COUNT_WQ_STATS].data = &net->nft.count_wq_stats; #endif nf_conntrack_standalone_init_tcp_sysctl(net, table); diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c index 82cd78c8eb25..ff52d903aad9 100644 --- a/net/netfilter/nf_flow_table_offload.c +++ b/net/netfilter/nf_flow_table_offload.c @@ -969,6 +969,7 @@ static void flow_offload_work_handler(struct work_struct *work) break; case FLOW_CLS_STATS: flow_offload_work_stats(offload); + atomic_dec(&net->nft.count_wq_stats); break; default: WARN_ON_ONCE(1); @@ -1054,6 +1055,7 @@ void nf_flow_offload_del(struct nf_flowtable *flowtable, void nf_flow_offload_stats(struct nf_flowtable *flowtable, struct flow_offload *flow) { + struct net *net = read_pnet(&flowtable->net); struct flow_offload_work *offload; __s32 delta; @@ -1065,6 +1067,7 @@ void nf_flow_offload_stats(struct nf_flowtable *flowtable, if (!offload) return; + atomic_inc(&net->nft.count_wq_stats); flow_offload_queue_work(offload); } -- 2.31.1