1 /* SPDX-License-Identifier: GPL-2.0 */
3 * linux/include/linux/sunrpc/metrics.h
5 * Declarations for RPC client per-operation metrics
7 * Copyright (C) 2005 Chuck Lever <cel@netapp.com>
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.
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.
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.
26 #ifndef _LINUX_SUNRPC_METRICS_H
27 #define _LINUX_SUNRPC_METRICS_H
29 #include <linux/seq_file.h>
30 #include <linux/ktime.h>
31 #include <linux/spinlock.h>
33 #define RPC_IOSTATS_VERS "1.0"
39 * These counters give an idea about how many request
40 * transmissions are required, on average, to complete that
41 * particular procedure. Some procedures may require more
42 * than one transmission because the server is unresponsive,
43 * the client is retransmitting too aggressively, or the
44 * requests are large and the network is congested.
46 unsigned long om_ops
, /* count of operations */
47 om_ntrans
, /* count of RPC transmissions */
48 om_timeouts
; /* count of major timeouts */
51 * These count how many bytes are sent and received for a
52 * given RPC procedure type. This indicates how much load a
53 * particular procedure is putting on the network. These
54 * counts include the RPC and ULP headers, and the request
57 unsigned long long om_bytes_sent
, /* count of bytes out */
58 om_bytes_recv
; /* count of bytes in */
61 * The length of time an RPC request waits in queue before
62 * transmission, the network + server latency of the request,
63 * and the total time the request spent from init to release
66 ktime_t om_queue
, /* queued for xmit */
68 om_execute
; /* RPC execution */
69 } ____cacheline_aligned
;
75 * EXPORTed functions for managing rpc_iostats structures
80 struct rpc_iostats
* rpc_alloc_iostats(struct rpc_clnt
*);
81 void rpc_count_iostats(const struct rpc_task
*,
82 struct rpc_iostats
*);
83 void rpc_count_iostats_metrics(const struct rpc_task
*,
84 struct rpc_iostats
*);
85 void rpc_print_iostats(struct seq_file
*, struct rpc_clnt
*);
86 void rpc_free_iostats(struct rpc_iostats
*);
88 #else /* CONFIG_PROC_FS */
90 static inline struct rpc_iostats
*rpc_alloc_iostats(struct rpc_clnt
*clnt
) { return NULL
; }
91 static inline void rpc_count_iostats(const struct rpc_task
*task
,
92 struct rpc_iostats
*stats
) {}
93 static inline void rpc_count_iostats_metrics(const struct rpc_task
*task
,
94 struct rpc_iostats
*stats
)
98 static inline void rpc_print_iostats(struct seq_file
*seq
, struct rpc_clnt
*clnt
) {}
99 static inline void rpc_free_iostats(struct rpc_iostats
*stats
) {}
101 #endif /* CONFIG_PROC_FS */
103 #endif /* _LINUX_SUNRPC_METRICS_H */