Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/linux/sunrpc/metrics.h |
| 3 | * |
| 4 | * Declarations for RPC client per-operation metrics |
| 5 | * |
| 6 | * Copyright (C) 2005 Chuck Lever <cel@netapp.com> |
| 7 | * |
| 8 | * RPC client per-operation statistics provide latency and retry |
| 9 | * information about each type of RPC procedure in a given RPC program. |
| 10 | * These statistics are not for detailed problem diagnosis, but simply |
| 11 | * to indicate whether the problem is local or remote. |
| 12 | * |
| 13 | * These counters are not meant to be human-readable, but are meant to be |
| 14 | * integrated into system monitoring tools such as "sar" and "iostat". As |
| 15 | * such, the counters are sampled by the tools over time, and are never |
| 16 | * zeroed after a file system is mounted. Moving averages can be computed |
| 17 | * by the tools by taking the difference between two instantaneous samples |
| 18 | * and dividing that by the time between the samples. |
| 19 | * |
| 20 | * The counters are maintained in a single array per RPC client, indexed |
| 21 | * by procedure number. There is no need to maintain separate counter |
| 22 | * arrays per-CPU because these counters are always modified behind locks. |
| 23 | */ |
| 24 | |
| 25 | #ifndef _LINUX_SUNRPC_METRICS_H |
| 26 | #define _LINUX_SUNRPC_METRICS_H |
| 27 | |
| 28 | #include <linux/seq_file.h> |
Chuck Lever | ff83997 | 2010-05-07 13:34:47 -0400 | [diff] [blame] | 29 | #include <linux/ktime.h> |
Chuck Lever | edef129 | 2014-11-08 20:15:09 -0500 | [diff] [blame] | 30 | #include <linux/spinlock.h> |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 31 | |
| 32 | #define RPC_IOSTATS_VERS "1.0" |
| 33 | |
| 34 | struct rpc_iostats { |
Chuck Lever | edef129 | 2014-11-08 20:15:09 -0500 | [diff] [blame] | 35 | spinlock_t om_lock; |
| 36 | |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 37 | /* |
| 38 | * These counters give an idea about how many request |
| 39 | * transmissions are required, on average, to complete that |
| 40 | * particular procedure. Some procedures may require more |
| 41 | * than one transmission because the server is unresponsive, |
| 42 | * the client is retransmitting too aggressively, or the |
| 43 | * requests are large and the network is congested. |
| 44 | */ |
| 45 | unsigned long om_ops, /* count of operations */ |
| 46 | om_ntrans, /* count of RPC transmissions */ |
| 47 | om_timeouts; /* count of major timeouts */ |
| 48 | |
| 49 | /* |
| 50 | * These count how many bytes are sent and received for a |
| 51 | * given RPC procedure type. This indicates how much load a |
| 52 | * particular procedure is putting on the network. These |
| 53 | * counts include the RPC and ULP headers, and the request |
| 54 | * payload. |
| 55 | */ |
| 56 | unsigned long long om_bytes_sent, /* count of bytes out */ |
| 57 | om_bytes_recv; /* count of bytes in */ |
| 58 | |
| 59 | /* |
| 60 | * The length of time an RPC request waits in queue before |
| 61 | * transmission, the network + server latency of the request, |
| 62 | * and the total time the request spent from init to release |
| 63 | * are measured. |
| 64 | */ |
Chuck Lever | ff83997 | 2010-05-07 13:34:47 -0400 | [diff] [blame] | 65 | ktime_t om_queue, /* queued for xmit */ |
| 66 | om_rtt, /* RPC RTT */ |
| 67 | om_execute; /* RPC execution */ |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 68 | } ____cacheline_aligned; |
| 69 | |
| 70 | struct rpc_task; |
| 71 | struct rpc_clnt; |
| 72 | |
| 73 | /* |
| 74 | * EXPORTed functions for managing rpc_iostats structures |
| 75 | */ |
Adrian Bunk | 7866bab | 2006-04-18 13:14:13 -0400 | [diff] [blame] | 76 | |
| 77 | #ifdef CONFIG_PROC_FS |
| 78 | |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 79 | struct rpc_iostats * rpc_alloc_iostats(struct rpc_clnt *); |
Weston Andros Adamson | 0a70219 | 2012-02-17 13:15:24 -0500 | [diff] [blame] | 80 | void rpc_count_iostats(const struct rpc_task *, |
| 81 | struct rpc_iostats *); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 82 | void rpc_print_iostats(struct seq_file *, struct rpc_clnt *); |
| 83 | void rpc_free_iostats(struct rpc_iostats *); |
| 84 | |
Adrian Bunk | 7866bab | 2006-04-18 13:14:13 -0400 | [diff] [blame] | 85 | #else /* CONFIG_PROC_FS */ |
| 86 | |
| 87 | static inline struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) { return NULL; } |
Weston Andros Adamson | 0a70219 | 2012-02-17 13:15:24 -0500 | [diff] [blame] | 88 | static inline void rpc_count_iostats(const struct rpc_task *task, |
| 89 | struct rpc_iostats *stats) {} |
Adrian Bunk | 7866bab | 2006-04-18 13:14:13 -0400 | [diff] [blame] | 90 | static inline void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt) {} |
| 91 | static inline void rpc_free_iostats(struct rpc_iostats *stats) {} |
| 92 | |
| 93 | #endif /* CONFIG_PROC_FS */ |
| 94 | |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 95 | #endif /* _LINUX_SUNRPC_METRICS_H */ |