Rev 788 | Rev 791 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 788 | Rev 789 | ||
|---|---|---|---|
| Line 53... | Line 53... | ||
| 53 | * we are in memory stress */ |
53 | * we are in memory stress */ |
| 54 | 54 | ||
| 55 | /* cache_create flags */ |
55 | /* cache_create flags */ |
| 56 | #define SLAB_CACHE_NOMAGAZINE 0x1 /**< Do not use per-cpu cache */ |
56 | #define SLAB_CACHE_NOMAGAZINE 0x1 /**< Do not use per-cpu cache */ |
| 57 | #define SLAB_CACHE_SLINSIDE 0x2 /**< Have control structure inside SLAB */ |
57 | #define SLAB_CACHE_SLINSIDE 0x2 /**< Have control structure inside SLAB */ |
| - | 58 | /** We add magazine cache later, if we have this flag */ |
|
| - | 59 | #define SLAB_CACHE_MAGDEFERRED (0x4 | SLAB_CACHE_NOMAGAZINE) |
|
| 58 | 60 | ||
| 59 | typedef struct { |
61 | typedef struct { |
| 60 | link_t link; |
62 | link_t link; |
| 61 | count_t busy; /**< Count of full slots in magazine */ |
63 | count_t busy; /**< Count of full slots in magazine */ |
| 62 | count_t size; /**< Number of slots in magazine */ |
64 | count_t size; /**< Number of slots in magazine */ |
| 63 | void *objs[0]; /**< Slots in magazine */ |
65 | void *objs[0]; /**< Slots in magazine */ |
| 64 | }slab_magazine_t; |
66 | }slab_magazine_t; |
| 65 | 67 | ||
| 66 | typedef struct { |
68 | typedef struct { |
| - | 69 | slab_magazine_t *current; |
|
| - | 70 | slab_magazine_t *last; |
|
| - | 71 | SPINLOCK_DECLARE(lock); |
|
| - | 72 | }slab_mag_cache_t; |
|
| - | 73 | ||
| - | 74 | ||
| - | 75 | typedef struct { |
|
| 67 | char *name; |
76 | char *name; |
| 68 | 77 | ||
| 69 | link_t link; |
78 | link_t link; |
| 70 | /* Configuration */ |
79 | /* Configuration */ |
| 71 | size_t size; /**< Size of SLAB position - align_up(sizeof(obj)) */ |
80 | size_t size; /**< Size of SLAB position - align_up(sizeof(obj)) */ |
| Line 90... | Line 99... | ||
| 90 | /* Magazines */ |
99 | /* Magazines */ |
| 91 | link_t magazines; /**< List o full magazines */ |
100 | link_t magazines; /**< List o full magazines */ |
| 92 | SPINLOCK_DECLARE(maglock); |
101 | SPINLOCK_DECLARE(maglock); |
| 93 | 102 | ||
| 94 | /** CPU cache */ |
103 | /** CPU cache */ |
| 95 | struct { |
- | |
| 96 | slab_magazine_t *current; |
- | |
| 97 | slab_magazine_t *last; |
104 | slab_mag_cache_t *mag_cache; |
| 98 | SPINLOCK_DECLARE(lock); |
- | |
| 99 | }mag_cache[0]; |
- | |
| 100 | }slab_cache_t; |
105 | }slab_cache_t; |
| 101 | 106 | ||
| 102 | extern slab_cache_t * slab_cache_create(char *name, |
107 | extern slab_cache_t * slab_cache_create(char *name, |
| 103 | size_t size, |
108 | size_t size, |
| 104 | size_t align, |
109 | size_t align, |
| Line 111... | Line 116... | ||
| 111 | extern void slab_free(slab_cache_t *cache, void *obj); |
116 | extern void slab_free(slab_cache_t *cache, void *obj); |
| 112 | extern count_t slab_reclaim(int flags); |
117 | extern count_t slab_reclaim(int flags); |
| 113 | 118 | ||
| 114 | /** Initialize SLAB subsytem */ |
119 | /** Initialize SLAB subsytem */ |
| 115 | extern void slab_cache_init(void); |
120 | extern void slab_cache_init(void); |
| - | 121 | extern void slab_enable_cpucache(void); |
|
| 116 | 122 | ||
| 117 | /* KConsole debug */ |
123 | /* KConsole debug */ |
| 118 | extern void slab_print_list(void); |
124 | extern void slab_print_list(void); |
| 119 | 125 | ||
| 120 | /* Malloc support */ |
126 | /* Malloc support */ |
| 121 | extern void * kalloc(unsigned int size, int flags); |
127 | extern void * kalloc(unsigned int size, int flags); |
| 122 | extern void kfree(void *obj); |
128 | extern void kfree(void *obj); |
| 123 | - | ||
| 124 | #endif |
129 | #endif |