stats.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_miss_collisions;
  10. atomic_t sectors_bypassed;
  11. };
  12. struct cache_stats {
  13. struct kobject kobj;
  14. unsigned long cache_hits;
  15. unsigned long cache_misses;
  16. unsigned long cache_bypass_hits;
  17. unsigned long cache_bypass_misses;
  18. unsigned long cache_miss_collisions;
  19. unsigned long sectors_bypassed;
  20. unsigned int rescale;
  21. };
  22. struct cache_accounting {
  23. struct closure cl;
  24. struct timer_list timer;
  25. atomic_t closing;
  26. struct cache_stat_collector collector;
  27. struct cache_stats total;
  28. struct cache_stats five_minute;
  29. struct cache_stats hour;
  30. struct cache_stats day;
  31. };
  32. struct cache_set;
  33. struct cached_dev;
  34. struct bcache_device;
  35. void bch_cache_accounting_init(struct cache_accounting *acc,
  36. struct closure *parent);
  37. int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
  38. struct kobject *parent);
  39. void bch_cache_accounting_clear(struct cache_accounting *acc);
  40. void bch_cache_accounting_destroy(struct cache_accounting *acc);
  41. void bch_mark_cache_accounting(struct cache_set *c, struct bcache_device *d,
  42. bool hit, bool bypass);
  43. void bch_mark_cache_miss_collision(struct cache_set *c,
  44. struct bcache_device *d);
  45. void bch_mark_sectors_bypassed(struct cache_set *c,
  46. struct cached_dev *dc,
  47. int sectors);
  48. #endif /* _BCACHE_STATS_H_ */