Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 2 | #ifndef _BCACHE_STATS_H_ |
| 3 | #define _BCACHE_STATS_H_ |
| 4 | |
| 5 | struct cache_stat_collector { |
| 6 | atomic_t cache_hits; |
| 7 | atomic_t cache_misses; |
| 8 | atomic_t cache_bypass_hits; |
| 9 | atomic_t cache_bypass_misses; |
| 10 | atomic_t cache_readaheads; |
| 11 | atomic_t cache_miss_collisions; |
| 12 | atomic_t sectors_bypassed; |
| 13 | }; |
| 14 | |
| 15 | struct cache_stats { |
| 16 | struct kobject kobj; |
| 17 | |
| 18 | unsigned long cache_hits; |
| 19 | unsigned long cache_misses; |
| 20 | unsigned long cache_bypass_hits; |
| 21 | unsigned long cache_bypass_misses; |
| 22 | unsigned long cache_readaheads; |
| 23 | unsigned long cache_miss_collisions; |
| 24 | unsigned long sectors_bypassed; |
| 25 | |
Coly Li | 6f10f7d | 2018-08-11 13:19:44 +0800 | [diff] [blame] | 26 | unsigned int rescale; |
Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | struct cache_accounting { |
| 30 | struct closure cl; |
| 31 | struct timer_list timer; |
| 32 | atomic_t closing; |
| 33 | |
| 34 | struct cache_stat_collector collector; |
| 35 | |
| 36 | struct cache_stats total; |
| 37 | struct cache_stats five_minute; |
| 38 | struct cache_stats hour; |
| 39 | struct cache_stats day; |
| 40 | }; |
| 41 | |
Kent Overstreet | 220bb38 | 2013-09-10 19:02:45 -0700 | [diff] [blame] | 42 | struct cache_set; |
| 43 | struct cached_dev; |
| 44 | struct bcache_device; |
Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 45 | |
| 46 | void bch_cache_accounting_init(struct cache_accounting *acc, |
| 47 | struct closure *parent); |
| 48 | |
| 49 | int bch_cache_accounting_add_kobjs(struct cache_accounting *acc, |
| 50 | struct kobject *parent); |
| 51 | |
| 52 | void bch_cache_accounting_clear(struct cache_accounting *acc); |
| 53 | |
| 54 | void bch_cache_accounting_destroy(struct cache_accounting *acc); |
| 55 | |
Coly Li | fc2d598 | 2018-08-11 13:19:46 +0800 | [diff] [blame] | 56 | void bch_mark_cache_accounting(struct cache_set *c, struct bcache_device *d, |
| 57 | bool hit, bool bypass); |
| 58 | void bch_mark_cache_readahead(struct cache_set *c, struct bcache_device *d); |
| 59 | void bch_mark_cache_miss_collision(struct cache_set *c, |
| 60 | struct bcache_device *d); |
| 61 | void bch_mark_sectors_bypassed(struct cache_set *c, |
| 62 | struct cached_dev *dc, |
| 63 | int sectors); |
Kent Overstreet | cafe563 | 2013-03-23 16:11:31 -0700 | [diff] [blame] | 64 | |
| 65 | #endif /* _BCACHE_STATS_H_ */ |