forked from todaygood/io-latency
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatency_stats.h
64 lines (56 loc) · 2.54 KB
/
latency_stats.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _IO_LATENCY_STATS_H_
#define _IO_LATENCY_STATS_H_
#include <linux/types.h>
#include "config.h"
/* for 2.6.32.36xen */
#ifdef USE_HASH_TABLE
#ifndef __percpu
#define __percpu
#endif
#endif
/* 300s is max disk I/O latency which application may accept */
#define IO_LATENCY_STATS_S_NR 100
#define IO_LATENCY_STATS_S_GRAINSIZE (1000/IO_LATENCY_STATS_S_NR)
#define IO_LATENCY_STATS_MS_NR 100
#define IO_LATENCY_STATS_MS_GRAINSIZE (1000/IO_LATENCY_STATS_MS_NR)
#define IO_LATENCY_STATS_US_NR 100
#define IO_LATENCY_STATS_US_GRAINSIZE (1000/IO_LATENCY_STATS_S_NR)
#define IO_SIZE_MAX (1024 * 1024)
#define IO_SIZE_STATS_GRAINSIZE 4096
#define IO_SIZE_STATS_NR (IO_SIZE_MAX / IO_SIZE_STATS_GRAINSIZE)
struct latency_stats {
/* latency statistic buckets */
unsigned long latency_stats_s[IO_LATENCY_STATS_S_NR];
unsigned long latency_stats_ms[IO_LATENCY_STATS_MS_NR];
unsigned long latency_stats_us[IO_LATENCY_STATS_US_NR];
unsigned long latency_read_stats_s[IO_LATENCY_STATS_S_NR];
unsigned long latency_read_stats_ms[IO_LATENCY_STATS_MS_NR];
unsigned long latency_read_stats_us[IO_LATENCY_STATS_US_NR];
unsigned long latency_write_stats_s[IO_LATENCY_STATS_S_NR];
unsigned long latency_write_stats_ms[IO_LATENCY_STATS_MS_NR];
unsigned long latency_write_stats_us[IO_LATENCY_STATS_US_NR];
/* latency statistic for block-layer buckets */
unsigned long soft_latency_stats_s[IO_LATENCY_STATS_S_NR];
unsigned long soft_latency_stats_ms[IO_LATENCY_STATS_MS_NR];
unsigned long soft_latency_stats_us[IO_LATENCY_STATS_US_NR];
unsigned long soft_latency_read_stats_s[IO_LATENCY_STATS_S_NR];
unsigned long soft_latency_read_stats_ms[IO_LATENCY_STATS_MS_NR];
unsigned long soft_latency_read_stats_us[IO_LATENCY_STATS_US_NR];
unsigned long soft_latency_write_stats_s[IO_LATENCY_STATS_S_NR];
unsigned long soft_latency_write_stats_ms[IO_LATENCY_STATS_MS_NR];
unsigned long soft_latency_write_stats_us[IO_LATENCY_STATS_US_NR];
/* io size statistic buckets */
unsigned long io_size_stats[IO_SIZE_STATS_NR];
unsigned long io_read_size_stats[IO_SIZE_STATS_NR];
unsigned long io_write_size_stats[IO_SIZE_STATS_NR];
};
int init_latency_stats(void);
void exit_latency_stats(void);
struct latency_stats __percpu *create_latency_stats(void);
void destroy_latency_stats(struct latency_stats __percpu *lstats);
void update_latency_stats(struct latency_stats *lstats, unsigned long stime,
unsigned long now, int soft, int rw);
void update_io_size_stats(struct latency_stats *lstats, unsigned long size,
int rw);
void reset_latency_stats(struct latency_stats __percpu *lstats);
#endif