Lines Matching refs:block
316 static int pcpu_next_hint(struct pcpu_block_md *block, int alloc_bits) in pcpu_next_hint() argument
325 if (block->scan_hint && in pcpu_next_hint()
326 block->contig_hint_start > block->scan_hint_start && in pcpu_next_hint()
327 alloc_bits > block->scan_hint) in pcpu_next_hint()
328 return block->scan_hint_start + block->scan_hint; in pcpu_next_hint()
330 return block->first_free; in pcpu_next_hint()
349 struct pcpu_block_md *block; in pcpu_next_md_free_region() local
352 for (block = chunk->md_blocks + i; i < pcpu_chunk_nr_blocks(chunk); in pcpu_next_md_free_region()
353 block++, i++) { in pcpu_next_md_free_region()
356 *bits += block->left_free; in pcpu_next_md_free_region()
357 if (block->left_free == PCPU_BITMAP_BLOCK_BITS) in pcpu_next_md_free_region()
370 *bits = block->contig_hint; in pcpu_next_md_free_region()
371 if (*bits && block->contig_hint_start >= block_off && in pcpu_next_md_free_region()
372 *bits + block->contig_hint_start < PCPU_BITMAP_BLOCK_BITS) { in pcpu_next_md_free_region()
374 block->contig_hint_start); in pcpu_next_md_free_region()
380 *bits = block->right_free; in pcpu_next_md_free_region()
381 *bit_off = (i + 1) * PCPU_BITMAP_BLOCK_BITS - block->right_free; in pcpu_next_md_free_region()
404 struct pcpu_block_md *block; in pcpu_next_fit_region() local
407 for (block = chunk->md_blocks + i; i < pcpu_chunk_nr_blocks(chunk); in pcpu_next_fit_region()
408 block++, i++) { in pcpu_next_fit_region()
411 *bits += block->left_free; in pcpu_next_fit_region()
414 if (block->left_free == PCPU_BITMAP_BLOCK_BITS) in pcpu_next_fit_region()
419 *bits = ALIGN(block->contig_hint_start, align) - in pcpu_next_fit_region()
420 block->contig_hint_start; in pcpu_next_fit_region()
425 if (block->contig_hint && in pcpu_next_fit_region()
426 block->contig_hint_start >= block_off && in pcpu_next_fit_region()
427 block->contig_hint >= *bits + alloc_bits) { in pcpu_next_fit_region()
428 int start = pcpu_next_hint(block, alloc_bits); in pcpu_next_fit_region()
430 *bits += alloc_bits + block->contig_hint_start - in pcpu_next_fit_region()
438 *bit_off = ALIGN(PCPU_BITMAP_BLOCK_BITS - block->right_free, in pcpu_next_fit_region()
586 static void pcpu_block_update(struct pcpu_block_md *block, int start, int end) in pcpu_block_update() argument
590 block->first_free = min(block->first_free, start); in pcpu_block_update()
592 block->left_free = contig; in pcpu_block_update()
594 if (end == block->nr_bits) in pcpu_block_update()
595 block->right_free = contig; in pcpu_block_update()
597 if (contig > block->contig_hint) { in pcpu_block_update()
599 if (start > block->contig_hint_start) { in pcpu_block_update()
600 if (block->contig_hint > block->scan_hint) { in pcpu_block_update()
601 block->scan_hint_start = in pcpu_block_update()
602 block->contig_hint_start; in pcpu_block_update()
603 block->scan_hint = block->contig_hint; in pcpu_block_update()
604 } else if (start < block->scan_hint_start) { in pcpu_block_update()
610 block->scan_hint = 0; in pcpu_block_update()
613 block->scan_hint = 0; in pcpu_block_update()
615 block->contig_hint_start = start; in pcpu_block_update()
616 block->contig_hint = contig; in pcpu_block_update()
617 } else if (contig == block->contig_hint) { in pcpu_block_update()
618 if (block->contig_hint_start && in pcpu_block_update()
620 __ffs(start) > __ffs(block->contig_hint_start))) { in pcpu_block_update()
622 block->contig_hint_start = start; in pcpu_block_update()
623 if (start < block->scan_hint_start && in pcpu_block_update()
624 block->contig_hint > block->scan_hint) in pcpu_block_update()
625 block->scan_hint = 0; in pcpu_block_update()
626 } else if (start > block->scan_hint_start || in pcpu_block_update()
627 block->contig_hint > block->scan_hint) { in pcpu_block_update()
633 block->scan_hint_start = start; in pcpu_block_update()
634 block->scan_hint = contig; in pcpu_block_update()
642 if ((start < block->contig_hint_start && in pcpu_block_update()
643 (contig > block->scan_hint || in pcpu_block_update()
644 (contig == block->scan_hint && in pcpu_block_update()
645 start > block->scan_hint_start)))) { in pcpu_block_update()
646 block->scan_hint_start = start; in pcpu_block_update()
647 block->scan_hint = contig; in pcpu_block_update()
674 struct pcpu_block_md *block; in pcpu_block_update_scan() local
680 block = chunk->md_blocks + s_index; in pcpu_block_update_scan()
686 pcpu_block_update(block, s_off, e_off); in pcpu_block_update_scan()
732 struct pcpu_block_md *block = chunk->md_blocks + index; in pcpu_block_refresh_hint() local
737 if (block->scan_hint) { in pcpu_block_refresh_hint()
738 start = block->scan_hint_start + block->scan_hint; in pcpu_block_refresh_hint()
739 block->contig_hint_start = block->scan_hint_start; in pcpu_block_refresh_hint()
740 block->contig_hint = block->scan_hint; in pcpu_block_refresh_hint()
741 block->scan_hint = 0; in pcpu_block_refresh_hint()
743 start = block->first_free; in pcpu_block_refresh_hint()
744 block->contig_hint = 0; in pcpu_block_refresh_hint()
747 block->right_free = 0; in pcpu_block_refresh_hint()
752 pcpu_block_update(block, rs, re); in pcpu_block_refresh_hint()
770 struct pcpu_block_md *s_block, *e_block, *block; in pcpu_block_update_hint_alloc() local
863 for (block = s_block + 1; block < e_block; block++) { in pcpu_block_update_hint_alloc()
864 block->scan_hint = 0; in pcpu_block_update_hint_alloc()
865 block->contig_hint = 0; in pcpu_block_update_hint_alloc()
866 block->left_free = 0; in pcpu_block_update_hint_alloc()
867 block->right_free = 0; in pcpu_block_update_hint_alloc()
916 struct pcpu_block_md *s_block, *e_block, *block; in pcpu_block_update_hint_free() local
982 for (block = s_block + 1; block < e_block; block++) { in pcpu_block_update_hint_free()
983 block->first_free = 0; in pcpu_block_update_hint_free()
984 block->scan_hint = 0; in pcpu_block_update_hint_free()
985 block->contig_hint_start = 0; in pcpu_block_update_hint_free()
986 block->contig_hint = PCPU_BITMAP_BLOCK_BITS; in pcpu_block_update_hint_free()
987 block->left_free = PCPU_BITMAP_BLOCK_BITS; in pcpu_block_update_hint_free()
988 block->right_free = PCPU_BITMAP_BLOCK_BITS; in pcpu_block_update_hint_free()
1260 static void pcpu_init_md_block(struct pcpu_block_md *block, int nr_bits) in pcpu_init_md_block() argument
1262 block->scan_hint = 0; in pcpu_init_md_block()
1263 block->contig_hint = nr_bits; in pcpu_init_md_block()
1264 block->left_free = nr_bits; in pcpu_init_md_block()
1265 block->right_free = nr_bits; in pcpu_init_md_block()
1266 block->first_free = 0; in pcpu_init_md_block()
1267 block->nr_bits = nr_bits; in pcpu_init_md_block()