diff mbox series

[net-next] net: core: Add napi_complete_done tracepoint

Message ID 1665426094-88160-1-git-send-email-jdamato@fastly.com (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: core: Add napi_complete_done tracepoint | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 4 maintainers not CCed: mingo@redhat.com rostedt@goodmis.org petrm@nvidia.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch fail CHECK: Alignment should match open parenthesis CHECK: Lines should not end with a '(' ERROR: space prohibited after that open parenthesis '(' WARNING: line length of 85 exceeds 80 columns WARNING: line length of 87 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Joe Damato Oct. 10, 2022, 6:21 p.m. UTC
Add a tracepoint to help debug napi_complete_done. Users who set
defer_hard_irqs and the GRO timer can use this tracepoint to better
understand what impact these options have when their NIC driver calls
napi_complete_done.

perf trace can be used to enable the tracepoint and the output can be
examined to determine which settings should be adjusted.

$ sudo perf trace -e napi:napi_complete_done -a --call-graph=fp --libtraceevent_print

356.774 :0/0 napi:napi_complete_done(napi_complete_done on napi struct 0xffff88e052f02010 dev vlan100 irq_defers_remaining 2 timeout 20000 work_done 0 ret 0)
	napi_complete_done ([kernel.kallsyms])
	napi_complete_done ([kernel.kallsyms])
	i40e_napi_poll ([i40e])
	__napi_poll ([kernel.kallsyms])
	net_rx_action ([kernel.kallsyms])
	__do_softirq ([kernel.kallsyms])
	sysvec_apic_timer_interrupt ([kernel.kallsyms])
	asm_sysvec_apic_timer_interrupt ([kernel.kallsyms])
	intel_idle_irq ([kernel.kallsyms])
	cpuidle_enter_state ([kernel.kallsyms])
	cpuidle_enter ([kernel.kallsyms])
	do_idle ([kernel.kallsyms])
	cpu_startup_entry ([kernel.kallsyms])
	[0x243d98] ([kernel.kallsyms])
	secondary_startup_64_no_verify ([kernel.kallsyms])

Signed-off-by: Joe Damato <jdamato@fastly.com>
---
 include/trace/events/napi.h | 29 +++++++++++++++++++++++++++++
 net/core/dev.c              |  2 ++
 2 files changed, 31 insertions(+)

Comments

Jakub Kicinski Oct. 11, 2022, 12:58 a.m. UTC | #1
On Mon, 10 Oct 2022 11:21:34 -0700 Joe Damato wrote:
> Add a tracepoint to help debug napi_complete_done. Users who set
> defer_hard_irqs and the GRO timer can use this tracepoint to better
> understand what impact these options have when their NIC driver calls
> napi_complete_done.
> 
> perf trace can be used to enable the tracepoint and the output can be
> examined to determine which settings should be adjusted.

Are you familiar with bpftrace, and it's ability to attach to kfunc 
and kretfunc? We mostly add tracepoints to static functions which get
inlined these days.
Joe Damato Oct. 11, 2022, 1:01 a.m. UTC | #2
On Mon, Oct 10, 2022 at 05:58:24PM -0700, Jakub Kicinski wrote:
> On Mon, 10 Oct 2022 11:21:34 -0700 Joe Damato wrote:
> > Add a tracepoint to help debug napi_complete_done. Users who set
> > defer_hard_irqs and the GRO timer can use this tracepoint to better
> > understand what impact these options have when their NIC driver calls
> > napi_complete_done.
> > 
> > perf trace can be used to enable the tracepoint and the output can be
> > examined to determine which settings should be adjusted.
> 
> Are you familiar with bpftrace, and it's ability to attach to kfunc 
> and kretfunc? We mostly add tracepoints to static functions which get
> inlined these days.

Fair enough; I'll avoid sending patches like that in the future. It's been
helpful for me, but point taken. Sorry for the noise.
diff mbox series

Patch

diff --git a/include/trace/events/napi.h b/include/trace/events/napi.h
index 6678cf8..e8473d3 100644
--- a/include/trace/events/napi.h
+++ b/include/trace/events/napi.h
@@ -11,6 +11,35 @@ 
 
 #define NO_DEV "(no_device)"
 
+TRACE_EVENT(napi_complete_done,
+	TP_PROTO(struct napi_struct *napi, int hard_irq_defer, unsigned long timeout,
+		int work_done, bool ret),
+
+	TP_ARGS(napi, hard_irq_defer, timeout, work_done, ret),
+
+	TP_STRUCT__entry(
+		__field(	struct napi_struct *,	napi)
+		__string(	dev_name,  napi->dev ? napi->dev->name : NO_DEV)
+		__field(	int,			hard_irq_defer)
+		__field(	unsigned long,		timeout)
+		__field(	int,			work_done)
+		__field(	int,			ret)
+	),
+
+	TP_fast_assign(
+		__entry->napi = napi;
+		__assign_str(dev_name, napi->dev ? napi->dev->name : NO_DEV);
+		__entry->hard_irq_defer = hard_irq_defer;
+		__entry->timeout = timeout;
+		__entry->work_done = work_done;
+		__entry->ret = ret;
+	),
+
+	TP_printk("napi_complete_done on napi struct %p dev %s irq_defers_remaining %d timeout %lu work_done %d ret %d",
+		__entry->napi, __get_str(dev_name), __entry->hard_irq_defer,
+		__entry->timeout, __entry->work_done, __entry->ret)
+);
+
 TRACE_EVENT(napi_poll,
 
 	TP_PROTO(struct napi_struct *napi, int work, int budget),
diff --git a/net/core/dev.c b/net/core/dev.c
index fa53830..e601f97 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6091,6 +6091,8 @@  bool napi_complete_done(struct napi_struct *n, int work_done)
 	if (timeout)
 		hrtimer_start(&n->timer, ns_to_ktime(timeout),
 			      HRTIMER_MODE_REL_PINNED);
+
+	trace_napi_complete_done(n, n->defer_hard_irqs_count, timeout, work_done, ret);
 	return ret;
 }
 EXPORT_SYMBOL(napi_complete_done);