ecache.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef JEMALLOC_INTERNAL_ECACHE_H
  2. #define JEMALLOC_INTERNAL_ECACHE_H
  3. #include "jemalloc/internal/eset.h"
  4. #include "jemalloc/internal/san.h"
  5. #include "jemalloc/internal/mutex.h"
  6. typedef struct ecache_s ecache_t;
  7. struct ecache_s {
  8. malloc_mutex_t mtx;
  9. eset_t eset;
  10. eset_t guarded_eset;
  11. /* All stored extents must be in the same state. */
  12. extent_state_t state;
  13. /* The index of the ehooks the ecache is associated with. */
  14. unsigned ind;
  15. /*
  16. * If true, delay coalescing until eviction; otherwise coalesce during
  17. * deallocation.
  18. */
  19. bool delay_coalesce;
  20. };
  21. static inline size_t
  22. ecache_npages_get(ecache_t *ecache) {
  23. return eset_npages_get(&ecache->eset) +
  24. eset_npages_get(&ecache->guarded_eset);
  25. }
  26. /* Get the number of extents in the given page size index. */
  27. static inline size_t
  28. ecache_nextents_get(ecache_t *ecache, pszind_t ind) {
  29. return eset_nextents_get(&ecache->eset, ind) +
  30. eset_nextents_get(&ecache->guarded_eset, ind);
  31. }
  32. /* Get the sum total bytes of the extents in the given page size index. */
  33. static inline size_t
  34. ecache_nbytes_get(ecache_t *ecache, pszind_t ind) {
  35. return eset_nbytes_get(&ecache->eset, ind) +
  36. eset_nbytes_get(&ecache->guarded_eset, ind);
  37. }
  38. static inline unsigned
  39. ecache_ind_get(ecache_t *ecache) {
  40. return ecache->ind;
  41. }
  42. bool ecache_init(tsdn_t *tsdn, ecache_t *ecache, extent_state_t state,
  43. unsigned ind, bool delay_coalesce);
  44. void ecache_prefork(tsdn_t *tsdn, ecache_t *ecache);
  45. void ecache_postfork_parent(tsdn_t *tsdn, ecache_t *ecache);
  46. void ecache_postfork_child(tsdn_t *tsdn, ecache_t *ecache);
  47. #endif /* JEMALLOC_INTERNAL_ECACHE_H */