1 /* FS-Cache latency histogram
3 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #define FSCACHE_DEBUG_LEVEL THREAD
13 #include <linux/module.h>
14 #include <linux/proc_fs.h>
15 #include <linux/seq_file.h>
18 atomic_t fscache_obj_instantiate_histogram
[HZ
];
19 atomic_t fscache_objs_histogram
[HZ
];
20 atomic_t fscache_ops_histogram
[HZ
];
21 atomic_t fscache_retrieval_delay_histogram
[HZ
];
22 atomic_t fscache_retrieval_histogram
[HZ
];
25 * display the time-taken histogram
27 static int fscache_histogram_show(struct seq_file
*m
, void *v
)
32 switch ((unsigned long) v
) {
34 seq_puts(m
, "JIFS SECS OBJ INST OP RUNS OBJ RUNS RETRV DLY RETRIEVLS\n");
37 seq_puts(m
, "===== ===== ========= ========= ========= ========= =========\n");
40 index
= (unsigned long) v
- 3;
41 n
[0] = atomic_read(&fscache_obj_instantiate_histogram
[index
]);
42 n
[1] = atomic_read(&fscache_ops_histogram
[index
]);
43 n
[2] = atomic_read(&fscache_objs_histogram
[index
]);
44 n
[3] = atomic_read(&fscache_retrieval_delay_histogram
[index
]);
45 n
[4] = atomic_read(&fscache_retrieval_histogram
[index
]);
46 if (!(n
[0] | n
[1] | n
[2] | n
[3] | n
[4]))
49 t
= (index
* 1000) / HZ
;
51 seq_printf(m
, "%4lu 0.%03u %9u %9u %9u %9u %9u\n",
52 index
, t
, n
[0], n
[1], n
[2], n
[3], n
[4]);
58 * set up the iterator to start reading from the first line
60 static void *fscache_histogram_start(struct seq_file
*m
, loff_t
*_pos
)
62 if ((unsigned long long)*_pos
>= HZ
+ 2)
66 return (void *)(unsigned long) *_pos
;
70 * move to the next line
72 static void *fscache_histogram_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
75 return (unsigned long long)*pos
> HZ
+ 2 ?
76 NULL
: (void *)(unsigned long) *pos
;
80 * clean up after reading
82 static void fscache_histogram_stop(struct seq_file
*m
, void *v
)
86 static const struct seq_operations fscache_histogram_ops
= {
87 .start
= fscache_histogram_start
,
88 .stop
= fscache_histogram_stop
,
89 .next
= fscache_histogram_next
,
90 .show
= fscache_histogram_show
,
94 * open "/proc/fs/fscache/histogram" to provide latency data
96 static int fscache_histogram_open(struct inode
*inode
, struct file
*file
)
98 return seq_open(file
, &fscache_histogram_ops
);
101 const struct file_operations fscache_histogram_fops
= {
102 .owner
= THIS_MODULE
,
103 .open
= fscache_histogram_open
,
106 .release
= seq_release
,