metrics.h 3.2 KB

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