blob: 0ee3f7052846b05cb2a413c73c7f2e6bc0890b6a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Chuck Lever11c556b2006-03-20 13:44:22 -05002/*
3 * linux/include/linux/sunrpc/metrics.h
4 *
5 * Declarations for RPC client per-operation metrics
6 *
7 * Copyright (C) 2005 Chuck Lever <cel@netapp.com>
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
26#ifndef _LINUX_SUNRPC_METRICS_H
27#define _LINUX_SUNRPC_METRICS_H
28
29#include <linux/seq_file.h>
Chuck Leverff839972010-05-07 13:34:47 -040030#include <linux/ktime.h>
Chuck Leveredef1292014-11-08 20:15:09 -050031#include <linux/spinlock.h>
Chuck Lever11c556b2006-03-20 13:44:22 -050032
Dave Wysochanskia3325182019-05-23 16:13:50 -040033#define RPC_IOSTATS_VERS "1.1"
Chuck Lever11c556b2006-03-20 13:44:22 -050034
35struct rpc_iostats {
Chuck Leveredef1292014-11-08 20:15:09 -050036 spinlock_t om_lock;
37
Chuck Lever11c556b2006-03-20 13:44:22 -050038 /*
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.
45 */
46 unsigned long om_ops, /* count of operations */
47 om_ntrans, /* count of RPC transmissions */
48 om_timeouts; /* count of major timeouts */
49
50 /*
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
55 * payload.
56 */
57 unsigned long long om_bytes_sent, /* count of bytes out */
58 om_bytes_recv; /* count of bytes in */
59
60 /*
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
64 * are measured.
65 */
Chuck Leverff839972010-05-07 13:34:47 -040066 ktime_t om_queue, /* queued for xmit */
67 om_rtt, /* RPC RTT */
68 om_execute; /* RPC execution */
Dave Wysochanskia3325182019-05-23 16:13:50 -040069 /*
70 * The count of operations that complete with tk_status < 0.
71 * These statuses usually indicate error conditions.
72 */
73 unsigned long om_error_status;
Chuck Lever11c556b2006-03-20 13:44:22 -050074} ____cacheline_aligned;
75
76struct rpc_task;
77struct rpc_clnt;
78
79/*
80 * EXPORTed functions for managing rpc_iostats structures
81 */
Adrian Bunk7866bab2006-04-18 13:14:13 -040082
83#ifdef CONFIG_PROC_FS
84
Chuck Lever11c556b2006-03-20 13:44:22 -050085struct rpc_iostats * rpc_alloc_iostats(struct rpc_clnt *);
Weston Andros Adamson0a702192012-02-17 13:15:24 -050086void rpc_count_iostats(const struct rpc_task *,
87 struct rpc_iostats *);
Weston Andros Adamson840210f2014-06-24 10:59:52 -040088void rpc_count_iostats_metrics(const struct rpc_task *,
89 struct rpc_iostats *);
Dave Wysochanski016583d2018-07-31 10:10:51 -040090void rpc_clnt_show_stats(struct seq_file *, struct rpc_clnt *);
Chuck Lever11c556b2006-03-20 13:44:22 -050091void rpc_free_iostats(struct rpc_iostats *);
92
Adrian Bunk7866bab2006-04-18 13:14:13 -040093#else /* CONFIG_PROC_FS */
94
95static inline struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) { return NULL; }
Weston Andros Adamson0a702192012-02-17 13:15:24 -050096static inline void rpc_count_iostats(const struct rpc_task *task,
97 struct rpc_iostats *stats) {}
Trond Myklebust54d7e72a2015-02-12 08:28:12 -050098static inline void rpc_count_iostats_metrics(const struct rpc_task *task,
99 struct rpc_iostats *stats)
100{
101}
102
Dave Wysochanski016583d2018-07-31 10:10:51 -0400103static inline void rpc_clnt_show_stats(struct seq_file *seq, struct rpc_clnt *clnt) {}
Adrian Bunk7866bab2006-04-18 13:14:13 -0400104static inline void rpc_free_iostats(struct rpc_iostats *stats) {}
105
106#endif /* CONFIG_PROC_FS */
107
Chuck Lever11c556b2006-03-20 13:44:22 -0500108#endif /* _LINUX_SUNRPC_METRICS_H */