^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _BCACHE_STATS_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _BCACHE_STATS_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) struct cache_stat_collector {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) atomic_t cache_hits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) atomic_t cache_misses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) atomic_t cache_bypass_hits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) atomic_t cache_bypass_misses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) atomic_t cache_readaheads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) atomic_t cache_miss_collisions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) atomic_t sectors_bypassed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct cache_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct kobject kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) unsigned long cache_hits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) unsigned long cache_misses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) unsigned long cache_bypass_hits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) unsigned long cache_bypass_misses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned long cache_readaheads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unsigned long cache_miss_collisions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned long sectors_bypassed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) unsigned int rescale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct cache_accounting {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct closure cl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) atomic_t closing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct cache_stat_collector collector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct cache_stats total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct cache_stats five_minute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct cache_stats hour;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct cache_stats day;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct cache_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct cached_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct bcache_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) void bch_cache_accounting_init(struct cache_accounting *acc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct closure *parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct kobject *parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) void bch_cache_accounting_clear(struct cache_accounting *acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void bch_cache_accounting_destroy(struct cache_accounting *acc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) void bch_mark_cache_accounting(struct cache_set *c, struct bcache_device *d,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) bool hit, bool bypass);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void bch_mark_cache_readahead(struct cache_set *c, struct bcache_device *d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void bch_mark_cache_miss_collision(struct cache_set *c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct bcache_device *d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void bch_mark_sectors_bypassed(struct cache_set *c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct cached_dev *dc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #endif /* _BCACHE_STATS_H_ */