metrics.h 3.5 KB

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