Skip to content

Commit 3fcd76e

Browse files
Zhang Yanfeitorvalds
authored andcommitted
mm/vmalloc.c: remove dead code in vb_alloc
Space in a vmap block that was once allocated is considered dirty and not made available for allocation again before the whole block is recycled. The result is that free space within a vmap block is always contiguous. So if a vmap block has enough free space for allocation, the allocation is impossible to fail. Thus, the fragmented block purging was never invoked from vb_alloc(). So remove this dead code. [ Same patches also sent by: Chanho Min <chanho.min@lge.com> Johannes Weiner <hannes@cmpxchg.org> but git doesn't do "multiple authors" ] Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ab15d9b commit 3fcd76e

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

mm/vmalloc.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,6 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
910910
struct vmap_block *vb;
911911
unsigned long addr = 0;
912912
unsigned int order;
913-
int purge = 0;
914913

915914
BUG_ON(size & ~PAGE_MASK);
916915
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);
@@ -934,17 +933,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
934933
if (vb->free < 1UL << order)
935934
goto next;
936935

937-
i = bitmap_find_free_region(vb->alloc_map,
938-
VMAP_BBMAP_BITS, order);
939-
940-
if (i < 0) {
941-
if (vb->free + vb->dirty == VMAP_BBMAP_BITS) {
942-
/* fragmented and no outstanding allocations */
943-
BUG_ON(vb->dirty != VMAP_BBMAP_BITS);
944-
purge = 1;
945-
}
946-
goto next;
947-
}
936+
i = VMAP_BBMAP_BITS - vb->free;
948937
addr = vb->va->va_start + (i << PAGE_SHIFT);
949938
BUG_ON(addr_to_vb_idx(addr) !=
950939
addr_to_vb_idx(vb->va->va_start));
@@ -960,9 +949,6 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
960949
spin_unlock(&vb->lock);
961950
}
962951

963-
if (purge)
964-
purge_fragmented_blocks_thiscpu();
965-
966952
put_cpu_var(vmap_block_queue);
967953
rcu_read_unlock();
968954

0 commit comments

Comments
 (0)