stats.h 1.6 KB

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