~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/sunrpc/stats.c

Version: ~ [ linux-5.14-rc3 ] ~ [ linux-5.13.5 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.53 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.135 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.198 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.240 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.276 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.276 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/sunrpc/stats.c (Version linux-4.8.17) and /net/sunrpc/stats.c (Version linux-2.4.37.11)


  1 /*                                                  1 /*
  2  * linux/net/sunrpc/stats.c                         2  * linux/net/sunrpc/stats.c
  3  *                                                  3  *
  4  * procfs-based user access to generic RPC sta      4  * procfs-based user access to generic RPC statistics. The stats files
  5  * reside in /proc/net/rpc.                         5  * reside in /proc/net/rpc.
  6  *                                                  6  *
  7  * The read routines assume that the buffer pa      7  * The read routines assume that the buffer passed in is just big enough.
  8  * If you implement an RPC service that has it      8  * If you implement an RPC service that has its own stats routine which
  9  * appends the generic RPC stats, make sure yo      9  * appends the generic RPC stats, make sure you don't exceed the PAGE_SIZE
 10  * limit.                                          10  * limit.
 11  *                                                 11  *
 12  * Copyright (C) 1995, 1996, 1997 Olaf Kirch <     12  * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
 13  */                                                13  */
 14                                                    14 
 15 #include <linux/module.h>                          15 #include <linux/module.h>
 16 #include <linux/slab.h>                        << 
 17                                                    16 
 18 #include <linux/init.h>                            17 #include <linux/init.h>
 19 #include <linux/kernel.h>                          18 #include <linux/kernel.h>
                                                   >>  19 #include <linux/sched.h>
 20 #include <linux/proc_fs.h>                         20 #include <linux/proc_fs.h>
 21 #include <linux/seq_file.h>                    << 
 22 #include <linux/sunrpc/clnt.h>                     21 #include <linux/sunrpc/clnt.h>
 23 #include <linux/sunrpc/svcsock.h>                  22 #include <linux/sunrpc/svcsock.h>
 24 #include <linux/sunrpc/metrics.h>              !!  23 #include <linux/init.h>
 25 #include <linux/rcupdate.h>                    << 
 26                                                << 
 27 #include "netns.h"                             << 
 28                                                    24 
 29 #define RPCDBG_FACILITY RPCDBG_MISC                25 #define RPCDBG_FACILITY RPCDBG_MISC
 30                                                    26 
                                                   >>  27 static struct proc_dir_entry    *proc_net_rpc = NULL;
                                                   >>  28 
 31 /*                                                 29 /*
 32  * Get RPC client stats                            30  * Get RPC client stats
 33  */                                                31  */
 34 static int rpc_proc_show(struct seq_file *seq, !!  32 int
 35         const struct rpc_stat   *statp = seq-> !!  33 rpc_proc_read(char *buffer, char **start, off_t offset, int count,
 36         const struct rpc_program *prog = statp !!  34                                 int *eof, void *data)
 37         unsigned int i, j;                     !!  35 {
                                                   >>  36         struct rpc_stat *statp = (struct rpc_stat *) data;
                                                   >>  37         struct rpc_program *prog = statp->program;
                                                   >>  38         struct rpc_version *vers;
                                                   >>  39         int             len, i, j;
 38                                                    40 
 39         seq_printf(seq,                        !!  41         len = sprintf(buffer,
 40                 "net %u %u %u %u\n",           !!  42                 "net %d %d %d %d\n",
 41                         statp->netcnt,             43                         statp->netcnt,
 42                         statp->netudpcnt,          44                         statp->netudpcnt,
 43                         statp->nettcpcnt,          45                         statp->nettcpcnt,
 44                         statp->nettcpconn);        46                         statp->nettcpconn);
 45         seq_printf(seq,                        !!  47         len += sprintf(buffer + len,
 46                 "rpc %u %u %u\n",              !!  48                 "rpc %d %d %d\n",
 47                         statp->rpccnt,             49                         statp->rpccnt,
 48                         statp->rpcretrans,         50                         statp->rpcretrans,
 49                         statp->rpcauthrefresh)     51                         statp->rpcauthrefresh);
 50                                                    52 
 51         for (i = 0; i < prog->nrvers; i++) {       53         for (i = 0; i < prog->nrvers; i++) {
 52                 const struct rpc_version *vers !!  54                 if (!(vers = prog->version[i]))
 53                 if (!vers)                     << 
 54                         continue;                  55                         continue;
 55                 seq_printf(seq, "proc%u %u",   !!  56                 len += sprintf(buffer + len, "proc%d %d",
 56                                         vers->     57                                         vers->number, vers->nrprocs);
 57                 for (j = 0; j < vers->nrprocs;     58                 for (j = 0; j < vers->nrprocs; j++)
 58                         seq_printf(seq, " %u", !!  59                         len += sprintf(buffer + len, " %d",
 59                                         vers->     60                                         vers->procs[j].p_count);
 60                 seq_putc(seq, '\n');           !!  61                 buffer[len++] = '\n';
 61         }                                          62         }
 62         return 0;                              << 
 63 }                                              << 
 64                                                    63 
 65 static int rpc_proc_open(struct inode *inode,  !!  64         if (offset >= len) {
 66 {                                              !!  65                 *start = buffer;
 67         return single_open(file, rpc_proc_show !!  66                 *eof = 1;
                                                   >>  67                 return 0;
                                                   >>  68         }
                                                   >>  69         *start = buffer + offset;
                                                   >>  70         if ((len -= offset) > count)
                                                   >>  71                 return count;
                                                   >>  72         *eof = 1;
                                                   >>  73         return len;
 68 }                                                  74 }
 69                                                    75 
 70 static const struct file_operations rpc_proc_f << 
 71         .owner = THIS_MODULE,                  << 
 72         .open = rpc_proc_open,                 << 
 73         .read  = seq_read,                     << 
 74         .llseek = seq_lseek,                   << 
 75         .release = single_release,             << 
 76 };                                             << 
 77                                                << 
 78 /*                                                 76 /*
 79  * Get RPC server stats                            77  * Get RPC server stats
 80  */                                                78  */
 81 void svc_seq_show(struct seq_file *seq, const  !!  79 int
 82         const struct svc_program *prog = statp !!  80 svc_proc_read(char *buffer, char **start, off_t offset, int count,
 83         const struct svc_procedure *proc;      !!  81                                 int *eof, void *data)
 84         const struct svc_version *vers;        !!  82 {
 85         unsigned int i, j;                     !!  83         struct svc_stat *statp  = (struct svc_stat *) data;
                                                   >>  84         struct svc_program *prog = statp->program;
                                                   >>  85         struct svc_procedure *proc;
                                                   >>  86         struct svc_version *vers;
                                                   >>  87         int             len, i, j;
 86                                                    88 
 87         seq_printf(seq,                        !!  89         len = sprintf(buffer,
 88                 "net %u %u %u %u\n",           !!  90                 "net %d %d %d %d\n",
 89                         statp->netcnt,             91                         statp->netcnt,
 90                         statp->netudpcnt,          92                         statp->netudpcnt,
 91                         statp->nettcpcnt,          93                         statp->nettcpcnt,
 92                         statp->nettcpconn);        94                         statp->nettcpconn);
 93         seq_printf(seq,                        !!  95         len += sprintf(buffer + len,
 94                 "rpc %u %u %u %u %u\n",        !!  96                 "rpc %d %d %d %d %d\n",
 95                         statp->rpccnt,             97                         statp->rpccnt,
 96                         statp->rpcbadfmt+statp     98                         statp->rpcbadfmt+statp->rpcbadauth+statp->rpcbadclnt,
 97                         statp->rpcbadfmt,          99                         statp->rpcbadfmt,
 98                         statp->rpcbadauth,        100                         statp->rpcbadauth,
 99                         statp->rpcbadclnt);       101                         statp->rpcbadclnt);
100                                                   102 
101         for (i = 0; i < prog->pg_nvers; i++) {    103         for (i = 0; i < prog->pg_nvers; i++) {
102                 if (!(vers = prog->pg_vers[i])    104                 if (!(vers = prog->pg_vers[i]) || !(proc = vers->vs_proc))
103                         continue;                 105                         continue;
104                 seq_printf(seq, "proc%d %u", i !! 106                 len += sprintf(buffer + len, "proc%d %d", i, vers->vs_nproc);
105                 for (j = 0; j < vers->vs_nproc    107                 for (j = 0; j < vers->vs_nproc; j++, proc++)
106                         seq_printf(seq, " %u", !! 108                         len += sprintf(buffer + len, " %d", proc->pc_count);
107                 seq_putc(seq, '\n');           !! 109                 buffer[len++] = '\n';
108         }                                         110         }
109 }                                              << 
110 EXPORT_SYMBOL_GPL(svc_seq_show);               << 
111                                                << 
112 /**                                            << 
113  * rpc_alloc_iostats - allocate an rpc_iostats << 
114  * @clnt: RPC program, version, and xprt       << 
115  *                                             << 
116  */                                            << 
117 struct rpc_iostats *rpc_alloc_iostats(struct r << 
118 {                                              << 
119         struct rpc_iostats *stats;             << 
120         int i;                                 << 
121                                                   111 
122         stats = kcalloc(clnt->cl_maxproc, size !! 112         if (offset >= len) {
123         if (stats) {                           !! 113                 *start = buffer;
124                 for (i = 0; i < clnt->cl_maxpr !! 114                 *eof = 1;
125                         spin_lock_init(&stats[ !! 115                 return 0;
126         }                                         116         }
127         return stats;                          !! 117         *start = buffer + offset;
                                                   >> 118         if ((len -= offset) > count)
                                                   >> 119                 return count;
                                                   >> 120         *eof = 1;
                                                   >> 121         return len;
128 }                                                 122 }
129 EXPORT_SYMBOL_GPL(rpc_alloc_iostats);          << 
130                                                << 
131 /**                                            << 
132  * rpc_free_iostats - release an rpc_iostats s << 
133  * @stats: doomed rpc_iostats structure        << 
134  *                                             << 
135  */                                            << 
136 void rpc_free_iostats(struct rpc_iostats *stat << 
137 {                                              << 
138         kfree(stats);                          << 
139 }                                              << 
140 EXPORT_SYMBOL_GPL(rpc_free_iostats);           << 
141                                                << 
142 /**                                            << 
143  * rpc_count_iostats_metrics - tally up per-ta << 
144  * @task: completed rpc_task                   << 
145  * @op_metrics: stat structure for OP that wil << 
146  */                                            << 
147 void rpc_count_iostats_metrics(const struct rp << 
148                                struct rpc_iost << 
149 {                                              << 
150         struct rpc_rqst *req = task->tk_rqstp; << 
151         ktime_t delta, now;                    << 
152                                                << 
153         if (!op_metrics || !req)               << 
154                 return;                        << 
155                                                << 
156         now = ktime_get();                     << 
157         spin_lock(&op_metrics->om_lock);       << 
158                                                << 
159         op_metrics->om_ops++;                  << 
160         op_metrics->om_ntrans += req->rq_ntran << 
161         op_metrics->om_timeouts += task->tk_ti << 
162                                                << 
163         op_metrics->om_bytes_sent += req->rq_x << 
164         op_metrics->om_bytes_recv += req->rq_r << 
165                                                << 
166         delta = ktime_sub(req->rq_xtime, task- << 
167         op_metrics->om_queue = ktime_add(op_me << 
168                                                << 
169         op_metrics->om_rtt = ktime_add(op_metr << 
170                                                << 
171         delta = ktime_sub(now, task->tk_start) << 
172         op_metrics->om_execute = ktime_add(op_ << 
173                                                << 
174         spin_unlock(&op_metrics->om_lock);     << 
175 }                                              << 
176 EXPORT_SYMBOL_GPL(rpc_count_iostats_metrics);  << 
177                                                << 
178 /**                                            << 
179  * rpc_count_iostats - tally up per-task stats << 
180  * @task: completed rpc_task                   << 
181  * @stats: array of stat structures            << 
182  *                                             << 
183  * Uses the statidx from @task                 << 
184  */                                            << 
185 void rpc_count_iostats(const struct rpc_task * << 
186 {                                              << 
187         rpc_count_iostats_metrics(task,        << 
188                                   &stats[task- << 
189 }                                              << 
190 EXPORT_SYMBOL_GPL(rpc_count_iostats);          << 
191                                                << 
192 static void _print_name(struct seq_file *seq,  << 
193                         struct rpc_procinfo *p << 
194 {                                              << 
195         if (procs[op].p_name)                  << 
196                 seq_printf(seq, "\t%12s: ", pr << 
197         else if (op == 0)                      << 
198                 seq_printf(seq, "\t        NUL << 
199         else                                   << 
200                 seq_printf(seq, "\t%12u: ", op << 
201 }                                              << 
202                                                << 
203 void rpc_print_iostats(struct seq_file *seq, s << 
204 {                                              << 
205         struct rpc_iostats *stats = clnt->cl_m << 
206         struct rpc_xprt *xprt;                 << 
207         unsigned int op, maxproc = clnt->cl_ma << 
208                                                << 
209         if (!stats)                            << 
210                 return;                        << 
211                                                << 
212         seq_printf(seq, "\tRPC iostats version << 
213         seq_printf(seq, "p/v: %u/%u (%s)\n",   << 
214                         clnt->cl_prog, clnt->c << 
215                                                << 
216         rcu_read_lock();                       << 
217         xprt = rcu_dereference(clnt->cl_xprt); << 
218         if (xprt)                              << 
219                 xprt->ops->print_stats(xprt, s << 
220         rcu_read_unlock();                     << 
221                                                << 
222         seq_printf(seq, "\tper-op statistics\n << 
223         for (op = 0; op < maxproc; op++) {     << 
224                 struct rpc_iostats *metrics =  << 
225                 _print_name(seq, op, clnt->cl_ << 
226                 seq_printf(seq, "%lu %lu %lu % << 
227                                 metrics->om_op << 
228                                 metrics->om_nt << 
229                                 metrics->om_ti << 
230                                 metrics->om_by << 
231                                 metrics->om_by << 
232                                 ktime_to_ms(me << 
233                                 ktime_to_ms(me << 
234                                 ktime_to_ms(me << 
235         }                                      << 
236 }                                              << 
237 EXPORT_SYMBOL_GPL(rpc_print_iostats);          << 
238                                                   123 
239 /*                                                124 /*
240  * Register/unregister RPC proc files             125  * Register/unregister RPC proc files
241  */                                               126  */
242 static inline struct proc_dir_entry *             127 static inline struct proc_dir_entry *
243 do_register(struct net *net, const char *name, !! 128 do_register(const char *name, void *data, int issvc)
244             const struct file_operations *fops << 
245 {                                                 129 {
246         struct sunrpc_net *sn;                 !! 130         rpc_proc_init();
247                                                !! 131         dprintk("RPC: registering /proc/net/rpc/%s\n", name);
248         dprintk("RPC:       registering /proc/ !! 132         return create_proc_read_entry(name, 0, proc_net_rpc, 
249         sn = net_generic(net, sunrpc_net_id);  !! 133                                       issvc? svc_proc_read : rpc_proc_read,
250         return proc_create_data(name, 0, sn->p !! 134                                       data);
251 }                                                 135 }
252                                                   136 
253 struct proc_dir_entry *                           137 struct proc_dir_entry *
254 rpc_proc_register(struct net *net, struct rpc_ !! 138 rpc_proc_register(struct rpc_stat *statp)
255 {                                                 139 {
256         return do_register(net, statp->program !! 140         return do_register(statp->program->name, statp, 0);
257 }                                                 141 }
258 EXPORT_SYMBOL_GPL(rpc_proc_register);          << 
259                                                   142 
260 void                                              143 void
261 rpc_proc_unregister(struct net *net, const cha !! 144 rpc_proc_unregister(const char *name)
262 {                                                 145 {
263         struct sunrpc_net *sn;                 !! 146         remove_proc_entry(name, proc_net_rpc);
264                                                << 
265         sn = net_generic(net, sunrpc_net_id);  << 
266         remove_proc_entry(name, sn->proc_net_r << 
267 }                                                 147 }
268 EXPORT_SYMBOL_GPL(rpc_proc_unregister);        << 
269                                                   148 
270 struct proc_dir_entry *                           149 struct proc_dir_entry *
271 svc_proc_register(struct net *net, struct svc_ !! 150 svc_proc_register(struct svc_stat *statp)
272 {                                                 151 {
273         return do_register(net, statp->program !! 152         return do_register(statp->program->pg_name, statp, 1);
274 }                                                 153 }
275 EXPORT_SYMBOL_GPL(svc_proc_register);          << 
276                                                   154 
277 void                                              155 void
278 svc_proc_unregister(struct net *net, const cha !! 156 svc_proc_unregister(const char *name)
279 {                                                 157 {
280         struct sunrpc_net *sn;                 !! 158         remove_proc_entry(name, proc_net_rpc);
                                                   >> 159 }
281                                                   160 
282         sn = net_generic(net, sunrpc_net_id);  !! 161 void
283         remove_proc_entry(name, sn->proc_net_r !! 162 rpc_proc_init(void)
                                                   >> 163 {
                                                   >> 164         dprintk("RPC: registering /proc/net/rpc\n");
                                                   >> 165         if (!proc_net_rpc) {
                                                   >> 166                 struct proc_dir_entry *ent;
                                                   >> 167                 ent = proc_mkdir("net/rpc", 0);
                                                   >> 168                 if (ent) {
                                                   >> 169                         ent->owner = THIS_MODULE;
                                                   >> 170                         proc_net_rpc = ent;
                                                   >> 171                 }
                                                   >> 172         }
284 }                                                 173 }
285 EXPORT_SYMBOL_GPL(svc_proc_unregister);        << 
286                                                   174 
287 int rpc_proc_init(struct net *net)             !! 175 void
                                                   >> 176 rpc_proc_exit(void)
288 {                                                 177 {
289         struct sunrpc_net *sn;                 !! 178         dprintk("RPC: unregistering /proc/net/rpc\n");
                                                   >> 179         if (proc_net_rpc) {
                                                   >> 180                 proc_net_rpc = NULL;
                                                   >> 181                 remove_proc_entry("net/rpc", 0);
                                                   >> 182         }
                                                   >> 183 }
290                                                   184 
291         dprintk("RPC:       registering /proc/ << 
292         sn = net_generic(net, sunrpc_net_id);  << 
293         sn->proc_net_rpc = proc_mkdir("rpc", n << 
294         if (sn->proc_net_rpc == NULL)          << 
295                 return -ENOMEM;                << 
296                                                   185 
                                                   >> 186 static int __init
                                                   >> 187 init_sunrpc(void)
                                                   >> 188 {
                                                   >> 189 #ifdef RPC_DEBUG
                                                   >> 190         rpc_register_sysctl();
                                                   >> 191 #endif
                                                   >> 192         rpc_proc_init();
297         return 0;                                 193         return 0;
298 }                                                 194 }
299                                                   195 
300 void rpc_proc_exit(struct net *net)            !! 196 static void __exit
                                                   >> 197 cleanup_sunrpc(void)
301 {                                                 198 {
302         dprintk("RPC:       unregistering /pro !! 199 #ifdef RPC_DEBUG
303         remove_proc_entry("rpc", net->proc_net !! 200         rpc_unregister_sysctl();
304 }                                              !! 201 #endif
305                                                !! 202         rpc_proc_exit();
                                                   >> 203 }
                                                   >> 204 MODULE_LICENSE("GPL");
                                                   >> 205 module_init(init_sunrpc);
                                                   >> 206 module_exit(cleanup_sunrpc);
306                                                   207 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp