Rev 1757 | Rev 1766 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1757 | Rev 1760 | ||
|---|---|---|---|
| Line 160... | Line 160... | ||
| 160 | void *data; |
160 | void *data; |
| 161 | slab_t *slab; |
161 | slab_t *slab; |
| 162 | size_t fsize; |
162 | size_t fsize; |
| 163 | int i; |
163 | int i; |
| 164 | int status; |
164 | int status; |
| 165 | pfn_t pfn; |
- | |
| 166 | int zone=0; |
165 | int zone=0; |
| 167 | 166 | ||
| 168 | pfn = frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone); |
167 | data = frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone); |
| 169 | data = (void *) PA2KA(PFN2ADDR(pfn)); |
- | |
| 170 | if (status != FRAME_OK) { |
168 | if (status != FRAME_OK) { |
| 171 | return NULL; |
169 | return NULL; |
| 172 | } |
170 | } |
| 173 | if (! (cache->flags & SLAB_CACHE_SLINSIDE)) { |
171 | if (! (cache->flags & SLAB_CACHE_SLINSIDE)) { |
| 174 | slab = slab_alloc(slab_extern_cache, flags); |
172 | slab = slab_alloc(slab_extern_cache, flags); |
| 175 | if (!slab) { |
173 | if (!slab) { |
| 176 | frame_free(ADDR2PFN(KA2PA(data))); |
174 | frame_free(KA2PA(data)); |
| 177 | return NULL; |
175 | return NULL; |
| 178 | } |
176 | } |
| 179 | } else { |
177 | } else { |
| 180 | fsize = (PAGE_SIZE << cache->order); |
178 | fsize = (PAGE_SIZE << cache->order); |
| 181 | slab = data + fsize - sizeof(*slab); |
179 | slab = data + fsize - sizeof(*slab); |
| 182 | } |
180 | } |
| 183 | 181 | ||
| 184 | /* Fill in slab structures */ |
182 | /* Fill in slab structures */ |
| 185 | for (i=0; i < (1 << cache->order); i++) |
183 | for (i=0; i < (1 << cache->order); i++) |
| 186 | frame_set_parent(pfn+i, slab, zone); |
184 | frame_set_parent(ADDR2PFN(KA2PA(data))+i, slab, zone); |
| 187 | 185 | ||
| 188 | slab->start = data; |
186 | slab->start = data; |
| 189 | slab->available = cache->objects; |
187 | slab->available = cache->objects; |
| 190 | slab->nextavail = 0; |
188 | slab->nextavail = 0; |
| 191 | slab->cache = cache; |
189 | slab->cache = cache; |
| Line 202... | Line 200... | ||
| 202 | * |
200 | * |
| 203 | * @return number of freed frames |
201 | * @return number of freed frames |
| 204 | */ |
202 | */ |
| 205 | static count_t slab_space_free(slab_cache_t *cache, slab_t *slab) |
203 | static count_t slab_space_free(slab_cache_t *cache, slab_t *slab) |
| 206 | { |
204 | { |
| 207 | frame_free(ADDR2PFN(KA2PA(slab->start))); |
205 | frame_free(KA2PA(slab->start)); |
| 208 | if (! (cache->flags & SLAB_CACHE_SLINSIDE)) |
206 | if (! (cache->flags & SLAB_CACHE_SLINSIDE)) |
| 209 | slab_free(slab_extern_cache, slab); |
207 | slab_free(slab_extern_cache, slab); |
| 210 | 208 | ||
| 211 | atomic_dec(&cache->allocated_slabs); |
209 | atomic_dec(&cache->allocated_slabs); |
| 212 | 210 | ||