metrics.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #ifndef _LINUX_SUNRPC_METRICS_H
  25. #define _LINUX_SUNRPC_METRICS_H
  26. #include <linux/seq_file.h>
  27. #define RPC_IOSTATS_VERS "1.0"
  28. struct rpc_iostats {
  29. /*
  30. * These counters give an idea about how many request
  31. * transmissions are required, on average, to complete that
  32. * particular procedure. Some procedures may require more
  33. * than one transmission because the server is unresponsive,
  34. * the client is retransmitting too aggressively, or the
  35. * requests are large and the network is congested.
  36. */
  37. unsigned long om_ops, /* count of operations */
  38. om_ntrans, /* count of RPC transmissions */
  39. om_timeouts; /* count of major timeouts */
  40. /*
  41. * These count how many bytes are sent and received for a
  42. * given RPC procedure type. This indicates how much load a
  43. * particular procedure is putting on the network. These
  44. * counts include the RPC and ULP headers, and the request
  45. * payload.
  46. */
  47. unsigned long long om_bytes_sent, /* count of bytes out */
  48. om_bytes_recv; /* count of bytes in */
  49. /*
  50. * The length of time an RPC request waits in queue before
  51. * transmission, the network + server latency of the request,
  52. * and the total time the request spent from init to release
  53. * are measured.
  54. */
  55. unsigned long long om_queue, /* jiffies queued for xmit */
  56. om_rtt, /* jiffies for RPC RTT */
  57. om_execute; /* jiffies for RPC execution */
  58. } ____cacheline_aligned;
  59. struct rpc_task;
  60. struct rpc_clnt;
  61. /*
  62. * EXPORTed functions for managing rpc_iostats structures
  63. */
  64. #ifdef CONFIG_PROC_FS
  65. struct rpc_iostats * rpc_alloc_iostats(struct rpc_clnt *);
  66. void rpc_count_iostats(struct rpc_task *);
  67. void rpc_print_iostats(struct seq_file *, struct rpc_clnt *);
  68. void rpc_free_iostats(struct rpc_iostats *);
  69. #else /* CONFIG_PROC_FS */
  70. static inline struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) { return NULL; }
  71. static inline void rpc_count_iostats(struct rpc_task *task) {}
  72. static inline void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt) {}
  73. static inline void rpc_free_iostats(struct rpc_iostats *stats) {}
  74. #endif /* CONFIG_PROC_FS */
  75. #endif /* _LINUX_SUNRPC_METRICS_H */