net: tracepoint napi:napi_poll add work and budget
authorJesper Dangaard Brouer <brouer@redhat.com>
Thu, 7 Jul 2016 16:01:32 +0000 (18:01 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 9 Jul 2016 22:05:02 +0000 (18:05 -0400)
An important information for the napi_poll tracepoint is knowing
the work done (packets processed) by the napi_poll() call. Add
both the work done and budget, as they are related.

Handle trace_napi_poll() param change in dropwatch/drop_monitor
and in python perf script netdev-times.py in backward compat way,
as python fortunately supports optional parameter handling.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/trace/events/napi.h
net/core/dev.c
net/core/drop_monitor.c
net/core/netpoll.c
tools/perf/scripts/python/netdev-times.py

index 8fe1e93f531dd81a8e549689a1b8e9b551231e9e..118ed776763941ea7fd0a28aa4dd7d31648fedf2 100644 (file)
 
 TRACE_EVENT(napi_poll,
 
-       TP_PROTO(struct napi_struct *napi),
+       TP_PROTO(struct napi_struct *napi, int work, int budget),
 
-       TP_ARGS(napi),
+       TP_ARGS(napi, work, budget),
 
        TP_STRUCT__entry(
                __field(        struct napi_struct *,   napi)
+               __field(        int,                    work)
+               __field(        int,                    budget)
                __string(       dev_name, napi->dev ? napi->dev->name : NO_DEV)
        ),
 
        TP_fast_assign(
                __entry->napi = napi;
+               __entry->work = work;
+               __entry->budget = budget;
                __assign_str(dev_name, napi->dev ? napi->dev->name : NO_DEV);
        ),
 
-       TP_printk("napi poll on napi struct %p for device %s",
-               __entry->napi, __get_str(dev_name))
+       TP_printk("napi poll on napi struct %p for device %s work %d budget %d",
+                 __entry->napi, __get_str(dev_name),
+                 __entry->work, __entry->budget)
 );
 
 #undef NO_DEV
index b92d63bfde7ae762eb3fc0201ca4709e5218858b..7894e406c80684754fac5d144f2b40a18897f153 100644 (file)
@@ -4972,7 +4972,7 @@ bool sk_busy_loop(struct sock *sk, int nonblock)
 
                        if (test_bit(NAPI_STATE_SCHED, &napi->state)) {
                                rc = napi->poll(napi, BUSY_POLL_BUDGET);
-                               trace_napi_poll(napi);
+                               trace_napi_poll(napi, rc, BUSY_POLL_BUDGET);
                                if (rc == BUSY_POLL_BUDGET) {
                                        napi_complete_done(napi, rc);
                                        napi_schedule(napi);
@@ -5128,7 +5128,7 @@ static int napi_poll(struct napi_struct *n, struct list_head *repoll)
        work = 0;
        if (test_bit(NAPI_STATE_SCHED, &n->state)) {
                work = n->poll(n, weight);
-               trace_napi_poll(n);
+               trace_napi_poll(n, work, weight);
        }
 
        WARN_ON_ONCE(work > weight);
index 252e155c837b7532778ef558c9c3cb47a68a654b..d6b3b579560df7220023cae07a0486be77e2b4f1 100644 (file)
@@ -187,7 +187,8 @@ static void trace_kfree_skb_hit(void *ignore, struct sk_buff *skb, void *locatio
        trace_drop_common(skb, location);
 }
 
-static void trace_napi_poll_hit(void *ignore, struct napi_struct *napi)
+static void trace_napi_poll_hit(void *ignore, struct napi_struct *napi,
+                               int work, int budget)
 {
        struct dm_hw_stat_delta *new_stat;
 
index 94acfc89ad976da245bed577511bd7a1c079f6f5..53599bd0c82df605e6c4b8a6e4f0ef6aa2ee9fee 100644 (file)
@@ -163,7 +163,7 @@ static void poll_one_napi(struct napi_struct *napi)
         */
        work = napi->poll(napi, 0);
        WARN_ONCE(work, "%pF exceeded budget in poll\n", napi->poll);
-       trace_napi_poll(napi);
+       trace_napi_poll(napi, work, 0);
 
        clear_bit(NAPI_STATE_NPSVC, &napi->state);
 }
index 4d21ef2d601dfcc22338e36fa260a6936e975dcb..4c6f09ac7d129e0f5ee9b0c823836d4de8f5c04c 100644 (file)
@@ -252,9 +252,10 @@ def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, i
        event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret)
        all_event_list.append(event_info)
 
-def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi, dev_name):
+def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi,
+                    dev_name, work=None, budget=None):
        event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
-                       napi, dev_name)
+                       napi, dev_name, work, budget)
        all_event_list.append(event_info)
 
 def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
@@ -354,11 +355,13 @@ def handle_irq_softirq_exit(event_info):
        receive_hunk_list.append(rec_data)
 
 def handle_napi_poll(event_info):
-       (name, context, cpu, time, pid, comm, napi, dev_name) = event_info
+       (name, context, cpu, time, pid, comm, napi, dev_name,
+               work, budget) = event_info
        if cpu in net_rx_dic.keys():
                event_list = net_rx_dic[cpu]['event_list']
                rec_data = {'event_name':'napi_poll',
-                               'dev':dev_name, 'event_t':time}
+                               'dev':dev_name, 'event_t':time,
+                               'work':work, 'budget':budget}
                event_list.append(rec_data)
 
 def handle_netif_rx(event_info):