lkml.org 
[lkml]   [2018]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH for 4.21 04/16] mm: Introduce vm_map_user_ram, vm_unmap_user_ram
On Wed, 10 Oct 2018 15:19:24 -0400
Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:

> + * vm_unmap_user_ram - unmap linear kernel address space set up by vm_map_user_ram
> + * @mem: the pointer returned by vm_map_user_ram
> + * @count: the count passed to that vm_map_user_ram call (cannot unmap partial)
> + */
> +void vm_unmap_user_ram(const void *mem, unsigned int count)
> +{
> + unsigned long size = (unsigned long)count << PAGE_SHIFT;
> + unsigned long addr = (unsigned long)mem;
> + struct vmap_area *va;
> +
> + might_sleep();
> + BUG_ON(!addr);
> + BUG_ON(addr < VMALLOC_START);
> + BUG_ON(addr > VMALLOC_END);
> + BUG_ON(!PAGE_ALIGNED(addr));
> +
> + debug_check_no_locks_freed(mem, size);
> + va = find_vmap_area(addr);
> + BUG_ON(!va);
> + free_unmap_vmap_area(va);
> +}
> +EXPORT_SYMBOL(vm_unmap_user_ram);
> +

Noticing this from Sergey's question in another patch, why are you
using BUG_ON()? That's rather extreme and something we are trying to
avoid adding more of (I still need to remove the BUG_ON()s I've added
over ten years ago). I don't see why all these BUG_ON's can't be turned
into:

if (WARN_ON(x))
return;

-- Steve

\
 
 \ /
  Last update: 2018-10-16 20:31    [W:0.227 / U:14.996 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site