From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergey Senozhatsky Subject: Re: [RFC PATCH for 4.21 04/16] mm: Introduce vm_map_user_ram, vm_unmap_user_ram Date: Wed, 17 Oct 2018 09:27:22 +0900 Message-ID: <20181017002722.GA1068@jagdpanzerIV> References: <20181010191936.7495-1-mathieu.desnoyers@efficios.com> <20181010191936.7495-5-mathieu.desnoyers@efficios.com> <20181016143016.10da89bd@gandalf.local.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20181016143016.10da89bd@gandalf.local.home> Sender: linux-kernel-owner@vger.kernel.org To: Steven Rostedt Cc: Mathieu Desnoyers , Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Thomas Gleixner , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H . Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , Josh Triplett , Linus Torvalds , Catalin Marinas Will Deacon List-Id: linux-api@vger.kernel.org On (10/16/18 14:30), Steven Rostedt wrote: > > +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: +1 > if (WARN_ON(x)) > return; Given that this somewhat MM-related, I'd may be say VM_WARN_ON(). -ss