slab_def.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _LINUX_SLAB_DEF_H
  2. #define _LINUX_SLAB_DEF_H
  3. #include <linux/reciprocal_div.h>
  4. /*
  5. * Definitions unique to the original Linux SLAB allocator.
  6. */
  7. struct kmem_cache {
  8. struct array_cache __percpu *cpu_cache;
  9. /* 1) Cache tunables. Protected by slab_mutex */
  10. unsigned int batchcount;
  11. unsigned int limit;
  12. unsigned int shared;
  13. unsigned int size;
  14. struct reciprocal_value reciprocal_buffer_size;
  15. /* 2) touched by every alloc & free from the backend */
  16. unsigned int flags; /* constant flags */
  17. unsigned int num; /* # of objs per slab */
  18. /* 3) cache_grow/shrink */
  19. /* order of pgs per slab (2^n) */
  20. unsigned int gfporder;
  21. /* force GFP flags, e.g. GFP_DMA */
  22. gfp_t allocflags;
  23. size_t colour; /* cache colouring range */
  24. unsigned int colour_off; /* colour offset */
  25. struct kmem_cache *freelist_cache;
  26. unsigned int freelist_size;
  27. /* constructor func */
  28. void (*ctor)(void *obj);
  29. /* 4) cache creation/removal */
  30. const char *name;
  31. struct list_head list;
  32. int refcount;
  33. int object_size;
  34. int align;
  35. /* 5) statistics */
  36. #ifdef CONFIG_DEBUG_SLAB
  37. unsigned long num_active;
  38. unsigned long num_allocations;
  39. unsigned long high_mark;
  40. unsigned long grown;
  41. unsigned long reaped;
  42. unsigned long errors;
  43. unsigned long max_freeable;
  44. unsigned long node_allocs;
  45. unsigned long node_frees;
  46. unsigned long node_overflow;
  47. atomic_t allochit;
  48. atomic_t allocmiss;
  49. atomic_t freehit;
  50. atomic_t freemiss;
  51. /*
  52. * If debugging is enabled, then the allocator can add additional
  53. * fields and/or padding to every object. size contains the total
  54. * object size including these internal fields, the following two
  55. * variables contain the offset to the user object and its size.
  56. */
  57. int obj_offset;
  58. #endif /* CONFIG_DEBUG_SLAB */
  59. #ifdef CONFIG_MEMCG_KMEM
  60. struct memcg_cache_params memcg_params;
  61. #endif
  62. struct kmem_cache_node *node[MAX_NUMNODES];
  63. };
  64. #endif /* _LINUX_SLAB_DEF_H */