Lines Matching refs:info

45 static int grow(rh_info_t * info, int max_blocks)
52 if (max_blocks <= info->max_blocks)
55 new_blocks = max_blocks - info->max_blocks;
61 if (info->max_blocks > 0) {
64 memcpy(block, info->block,
65 sizeof(rh_block_t) * info->max_blocks);
67 delta = (char *)block - (char *)info->block;
70 blks = (unsigned long)info->block;
71 blke = (unsigned long)(info->block + info->max_blocks);
73 for (i = 0, blk = block; i < info->max_blocks; i++, blk++)
76 fixup(blks, blke, delta, &info->empty_list);
77 fixup(blks, blke, delta, &info->free_list);
78 fixup(blks, blke, delta, &info->taken_list);
81 if ((info->flags & RHIF_STATIC_BLOCK) == 0)
82 kfree(info->block);
85 info->block = block;
86 info->empty_slots += new_blocks;
87 info->max_blocks = max_blocks;
88 info->flags &= ~RHIF_STATIC_BLOCK;
91 blk = block + info->max_blocks - new_blocks;
93 list_add(&blk->list, &info->empty_list);
103 static int assure_empty(rh_info_t * info, int slots)
112 if (info->empty_slots >= slots)
116 max_blocks = ((info->max_blocks + slots) + 15) & ~15;
118 return grow(info, max_blocks);
121 static rh_block_t *get_slot(rh_info_t * info)
127 if (info->empty_slots == 0) {
133 blk = list_entry(info->empty_list.next, rh_block_t, list);
135 info->empty_slots--;
145 static inline void release_slot(rh_info_t * info, rh_block_t * blk)
147 list_add(&blk->list, &info->empty_list);
148 info->empty_slots++;
151 static void attach_free_block(rh_info_t * info, rh_block_t * blkn)
172 list_for_each(l, &info->free_list) {
205 list_add(&blkn->list, &info->free_list);
211 release_slot(info, blkn);
229 release_slot(info, after);
232 static void attach_taken_block(rh_info_t * info, rh_block_t * blkn)
238 list_for_each(l, &info->taken_list) {
246 list_add_tail(&blkn->list, &info->taken_list);
255 rh_info_t *info;
261 info = kmalloc(sizeof(*info), GFP_ATOMIC);
262 if (info == NULL)
265 info->alignment = alignment;
268 info->block = NULL;
269 info->max_blocks = 0;
270 info->empty_slots = 0;
271 info->flags = 0;
273 INIT_LIST_HEAD(&info->empty_list);
274 INIT_LIST_HEAD(&info->free_list);
275 INIT_LIST_HEAD(&info->taken_list);
277 return info;
285 void rh_destroy(rh_info_t * info)
287 if ((info->flags & RHIF_STATIC_BLOCK) == 0)
288 kfree(info->block);
290 if ((info->flags & RHIF_STATIC_INFO) == 0)
291 kfree(info);
296 * Initialize in place a remote heap info block. This is needed to support
300 void rh_init(rh_info_t * info, unsigned int alignment, int max_blocks,
310 info->alignment = alignment;
313 info->block = block;
314 info->max_blocks = max_blocks;
315 info->empty_slots = max_blocks;
316 info->flags = RHIF_STATIC_INFO | RHIF_STATIC_BLOCK;
318 INIT_LIST_HEAD(&info->empty_list);
319 INIT_LIST_HEAD(&info->free_list);
320 INIT_LIST_HEAD(&info->taken_list);
324 list_add(&blk->list, &info->empty_list);
329 int rh_attach_region(rh_info_t * info, unsigned long start, int size)
338 m = info->alignment - 1;
354 r = assure_empty(info, 1);
358 blk = get_slot(info);
363 attach_free_block(info, blk);
370 unsigned long rh_detach_region(rh_info_t * info, unsigned long start, int size)
383 m = info->alignment - 1;
391 if (assure_empty(info, 1) < 0)
395 list_for_each(l, &info->free_list) {
412 release_slot(info, blk);
427 newblk = get_slot(info);
442 unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment, const char *owner)
454 size = (size + (info->alignment - 1)) & ~(info->alignment - 1);
456 if (assure_empty(info, 2) < 0)
460 list_for_each(l, &info->free_list) {
485 spblk = get_slot(info);
491 newblk = get_slot(info);
502 release_slot(info, blk);
507 attach_taken_block(info, newblk);
517 unsigned long rh_alloc(rh_info_t * info, int size, const char *owner)
519 return rh_alloc_align(info, size, info->alignment, owner);
527 unsigned long rh_alloc_fixed(rh_info_t * info, unsigned long start, int size, const char *owner)
540 m = info->alignment - 1;
548 if (assure_empty(info, 2) < 0)
552 list_for_each(l, &info->free_list) {
572 attach_taken_block(info, blk);
589 newblk2 = get_slot(info);
596 newblk1 = get_slot(info);
602 attach_taken_block(info, newblk1);
612 int rh_free(rh_info_t * info, unsigned long start)
620 list_for_each(l, &info->taken_list) {
635 attach_free_block(info, blk);
641 int rh_get_stats(rh_info_t * info, int what, int max_stats, rh_stats_t * stats)
651 h = &info->free_list;
655 h = &info->taken_list;
679 int rh_set_owner(rh_info_t * info, unsigned long start, const char *owner)
687 list_for_each(l, &info->taken_list) {
704 void rh_dump(rh_info_t * info)
713 "info @0x%p (%d slots empty / %d max)\n",
714 info, info->empty_slots, info->max_blocks);
717 nr = rh_get_stats(info, RHGS_FREE, maxnr, st);
728 nr = rh_get_stats(info, RHGS_TAKEN, maxnr, st);
740 void rh_dump_blk(rh_info_t * info, rh_block_t * blk)