linux_dsm_epyc7002/include/linux/sunrpc/metrics.h
Dave Wysochanski 016583d703 sunrpc: Change rpc_print_iostats to rpc_clnt_show_stats and handle rpc_clnt clones
The existing rpc_print_iostats has a few shortcomings.  First, the naming
is not consistent with other functions in the kernel that display stats.
Second, it is really displaying stats for an rpc_clnt structure as it
displays both xprt stats and per-op stats.  Third, it does not handle
rpc_clnt clones, which is important for the one in-kernel tree caller
of this function, the NFS client's nfs_show_stats function.

Fix all of the above by renaming the rpc_print_iostats to
rpc_clnt_show_stats and looping through any rpc_clnt clones via
cl_parent.

Once this interface is fixed, this addresses a problem with NFSv4.
Before this patch, the /proc/self/mountstats always showed incorrect
counts for NFSv4 lease and session related opcodes such as SEQUENCE,
RENEW, SETCLIENTID, CREATE_SESSION, etc.  These counts were always 0
even though many ops would go over the wire.  The reason for this is
there are multiple rpc_clnt structures allocated for any given NFSv4
mount, and inside nfs_show_stats() we callled into rpc_print_iostats()
which only handled one of them, nfs_server->client.  Fix these counts
by calling sunrpc's new rpc_clnt_show_stats() function, which handles
cloned rpc_clnt structs and prints the stats together.

Note that one side-effect of the above is that multiple mounts from
the same NFS server will show identical counts in the above ops due
to the fact the one rpc_clnt (representing the NFSv4 client state)
is shared across mounts.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
2018-07-31 12:53:35 -04:00

104 lines
3.5 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* linux/include/linux/sunrpc/metrics.h
*
* Declarations for RPC client per-operation metrics
*
* Copyright (C) 2005 Chuck Lever <cel@netapp.com>
*
* RPC client per-operation statistics provide latency and retry
* information about each type of RPC procedure in a given RPC program.
* These statistics are not for detailed problem diagnosis, but simply
* to indicate whether the problem is local or remote.
*
* These counters are not meant to be human-readable, but are meant to be
* integrated into system monitoring tools such as "sar" and "iostat". As
* such, the counters are sampled by the tools over time, and are never
* zeroed after a file system is mounted. Moving averages can be computed
* by the tools by taking the difference between two instantaneous samples
* and dividing that by the time between the samples.
*
* The counters are maintained in a single array per RPC client, indexed
* by procedure number. There is no need to maintain separate counter
* arrays per-CPU because these counters are always modified behind locks.
*/
#ifndef _LINUX_SUNRPC_METRICS_H
#define _LINUX_SUNRPC_METRICS_H
#include <linux/seq_file.h>
#include <linux/ktime.h>
#include <linux/spinlock.h>
#define RPC_IOSTATS_VERS "1.0"
struct rpc_iostats {
spinlock_t om_lock;
/*
* These counters give an idea about how many request
* transmissions are required, on average, to complete that
* particular procedure. Some procedures may require more
* than one transmission because the server is unresponsive,
* the client is retransmitting too aggressively, or the
* requests are large and the network is congested.
*/
unsigned long om_ops, /* count of operations */
om_ntrans, /* count of RPC transmissions */
om_timeouts; /* count of major timeouts */
/*
* These count how many bytes are sent and received for a
* given RPC procedure type. This indicates how much load a
* particular procedure is putting on the network. These
* counts include the RPC and ULP headers, and the request
* payload.
*/
unsigned long long om_bytes_sent, /* count of bytes out */
om_bytes_recv; /* count of bytes in */
/*
* The length of time an RPC request waits in queue before
* transmission, the network + server latency of the request,
* and the total time the request spent from init to release
* are measured.
*/
ktime_t om_queue, /* queued for xmit */
om_rtt, /* RPC RTT */
om_execute; /* RPC execution */
} ____cacheline_aligned;
struct rpc_task;
struct rpc_clnt;
/*
* EXPORTed functions for managing rpc_iostats structures
*/
#ifdef CONFIG_PROC_FS
struct rpc_iostats * rpc_alloc_iostats(struct rpc_clnt *);
void rpc_count_iostats(const struct rpc_task *,
struct rpc_iostats *);
void rpc_count_iostats_metrics(const struct rpc_task *,
struct rpc_iostats *);
void rpc_clnt_show_stats(struct seq_file *, struct rpc_clnt *);
void rpc_free_iostats(struct rpc_iostats *);
#else /* CONFIG_PROC_FS */
static inline struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) { return NULL; }
static inline void rpc_count_iostats(const struct rpc_task *task,
struct rpc_iostats *stats) {}
static inline void rpc_count_iostats_metrics(const struct rpc_task *task,
struct rpc_iostats *stats)
{
}
static inline void rpc_clnt_show_stats(struct seq_file *seq, struct rpc_clnt *clnt) {}
static inline void rpc_free_iostats(struct rpc_iostats *stats) {}
#endif /* CONFIG_PROC_FS */
#endif /* _LINUX_SUNRPC_METRICS_H */