Skip to content

Commit

Permalink
mm: pass addr as unsigned long to vb_free
Browse files Browse the repository at this point in the history
Ever use of addr in vb_free casts to unsigned long first, and the caller
has an unsigned long version of the address available anyway.  Just pass
that and avoid all the casts.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Gao Xiang <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Haiyang Zhang <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: "K. Y. Srinivasan" <[email protected]>
Cc: Laura Abbott <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Michael Kelley <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Nitin Gupta <[email protected]>
Cc: Robin Murphy <[email protected]>
Cc: Sakari Ailus <[email protected]>
Cc: Stephen Hemminger <[email protected]>
Cc: Sumit Semwal <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Will Deacon <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Hellwig authored and torvalds committed Jun 2, 2020
1 parent b607e6d commit 78a0e8c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions mm/vmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
return vaddr;
}

static void vb_free(const void *addr, unsigned long size)
static void vb_free(unsigned long addr, unsigned long size)
{
unsigned long offset;
unsigned long vb_idx;
Expand All @@ -1675,24 +1675,22 @@ static void vb_free(const void *addr, unsigned long size)
BUG_ON(offset_in_page(size));
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);

flush_cache_vunmap((unsigned long)addr, (unsigned long)addr + size);
flush_cache_vunmap(addr, addr + size);

order = get_order(size);

offset = (unsigned long)addr & (VMAP_BLOCK_SIZE - 1);
offset >>= PAGE_SHIFT;
offset = (addr & (VMAP_BLOCK_SIZE - 1)) >> PAGE_SHIFT;

vb_idx = addr_to_vb_idx((unsigned long)addr);
vb_idx = addr_to_vb_idx(addr);
rcu_read_lock();
vb = radix_tree_lookup(&vmap_block_tree, vb_idx);
rcu_read_unlock();
BUG_ON(!vb);

vunmap_page_range((unsigned long)addr, (unsigned long)addr + size);
vunmap_page_range(addr, addr + size);

if (debug_pagealloc_enabled_static())
flush_tlb_kernel_range((unsigned long)addr,
(unsigned long)addr + size);
flush_tlb_kernel_range(addr, addr + size);

spin_lock(&vb->lock);

Expand Down Expand Up @@ -1792,7 +1790,7 @@ void vm_unmap_ram(const void *mem, unsigned int count)

if (likely(count <= VMAP_MAX_ALLOC)) {
debug_check_no_locks_freed(mem, size);
vb_free(mem, size);
vb_free(addr, size);
return;
}

Expand Down

0 comments on commit 78a0e8c

Please sign in to comment.