metrics.h 3.7 KB

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