From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbcEDPBq (ORCPT ); Wed, 4 May 2016 11:01:46 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:54846 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750917AbcEDPBo (ORCPT ); Wed, 4 May 2016 11:01:44 -0400 Date: Wed, 4 May 2016 17:01:38 +0200 From: Peter Zijlstra To: Vineet Gupta Cc: Nicolas Pitre , Andrew Morton , David Hildenbrand , Thomas Petazzoni , Russell King , lkml , "linux-mm@kvack.org" , "linux-arch@vger.kernel.org" Subject: Re: kmap_atomic and preemption Message-ID: <20160504150138.GR3430@twins.programming.kicks-ass.net> References: <5729D0F4.9090907@synopsys.com> <20160504134729.GP3430@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 04, 2016 at 02:16:11PM +0000, Vineet Gupta wrote: > > static inline void *kmap_atomic(struct page *page) > > { > > preempt_disable(); > > pagefault_disable(); > > if (!PageHighMem(page)) > > return page_address(page); > > > > return __kmap_atomic(page); > > } > > I actually want to return early for !PageHighMem and avoid the pointless 2 > LD-ADD-ST to memory for map and 2 LD-SUB-ST for unmap for regular pages for such > cases. So I'm fairly sure people rely on the fact you cannot have pagefault inside a kmap_atomic(). But you could potentially get away with leaving preemption enabled. Give it a try, see if something goes *bang* ;-)