嵌入式linux中文站在线图书

Previous Page
Next Page

12.1. Statistics

Statistics about frame reception are kept in the per-CPU array netdev_rx_stat, whose elements are of type netif_rx_stats (see include/linux/netdevice.h):

struct netif_rx_stats netdev_rx_stat[NR_CPUS];
 
struct netif_rx_stats
{
        unsigned total;
        unsigned dropped;
        unsigned time_squeeze;
        unsigned throttled;
        unsigned fastroute_hit;
        unsigned fastroute_success;
        unsigned fastroute_defer;
        unsigned fastroute_deferred_out;
        unsigned fastroute_latency_reduction;
        unsigned cpu_collision;
} __ _  _cacheline_aligned;
 

The elements of netif_rx_stats are:


total

Total number of ingress frames processed, including any that might be discarded. This value is updated both in netif_rx and in netif_receive_skb, which means that (by mistake) the same frame is accounted for twice when the driver does not use NAPI (i.e., it uses the netif_rx interface; see Figure 10-2 in Chapter 10).


dropped

Number of frames that were dropped because they were received when the CPU was in the throttle state.


time_squeeze

Number of times net_rx_action had to return while frames were still in the CPU ingress queue, so as not to become a CPU hog. See the section "Processing the NET_RX_SOFTIRQ: net_rx_action" in Chapter 10.


throttled

Number of times the CPU went into the throttle state. This value is incremented by netif_rx.


fastroute_hit


fastroute_success


fastroute_defer


fastroute_latency_reduction


fastroute_deferred_out

Fields that used to be used by the Fastroute feature. This feature has been dropped in kernel 2.6.8.


cpu_collision

Number of times the CPU failed to grab the lock on a device driver (more precisely, on dev->xmit_lock) because the lock was already taken by another CPU. This counter is updated in qdisc_restart, which handles only frame transmission, not reception. cpu_collision is the only statistic about transmission that has been included in this structure.

The fact that some of the preceding counters are currently updated only by netif_rx (which is used only by non-NAPI drivers), means that their values are not correct when using NAPI drivers.

The contents of the netdev_rx_stat vector can be viewed via the /proc interface. See the next section.

Other statistics are kept by the driver in private data structures (see Chapter 2), by higher-layer protocols, and by the Traffic Control queuing disciplines. Some of those values can be read with user-space applications such as ifconfig, tc, ip, or netstat, and others are also exported via /proc.


Previous Page
Next Page