Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1395079

Re: kmap_atomic and preemption

From Vineet Gupta <Vineet.Gupta1@synopsys.com>
Newsgroups linux.kernel
Subject Re: kmap_atomic and preemption
Date 2016-05-05 14:40 +0200
Message-ID <rvqJs-8s0-19@gated-at.bofh.it> (permalink)
References <rv2nM-28B-17@gated-at.bofh.it> <rv5lE-4Ot-13@gated-at.bofh.it> <rv5OG-5wR-15@gated-at.bofh.it> <rv6B3-6n8-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wednesday 04 May 2016 08:31 PM, Peter Zijlstra wrote:
> So I'm fairly sure people rely on the fact you cannot have pagefault
> inside a kmap_atomic().

So this translates to: any hardware page faults inside kmap_atomic() can't lead to
do_page_fault() taking a lock - those can only be ex_table fixups, yes ?
Could you please also help explain your earlier comment about kmap_atomic needing
to disable preemption so that "returned pointer stayed valid". I can't quite
fathom how that can happen

> But you could potentially get away with leaving preemption enabled. Give
> it a try, see if something goes *bang* ;-)

So tried patch further below: on a quad core slowish FPGA setup, concurrent
hackbench and LMBench seem to run w/o issues  - so it is not obviously broken even
if not proven otherwise. But the point is highmem page is a slow path anyways -
needs a PTE update, new TLB entry etc. I hoped to not wiggle even a single cache
line for the low page - but seems like that is not possible.

OTOH, if we do keep the status quo - then making these 2 cache lines into 1 is not
possible either. From reading the orig "decoupling of prremption and page fault"
thread it seems to be because preempt count is per cpu on x86.

@@ -67,7 +67,6 @@ void *kmap_atomic(struct page *page)
        int idx, cpu_idx;
        unsigned long vaddr;
 
-       preempt_disable();
        pagefault_disable();
        if (!PageHighMem(page))
                return page_address(page);
@@ -107,7 +106,6 @@ void __kunmap_atomic(void *kv)
        }
 
        pagefault_enable();
-       preempt_enable();
 }

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

kmap_atomic and preemption Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-05-04 12:40 +0200
  Re: kmap_atomic and preemption Peter Zijlstra <peterz@infradead.org> - 2016-05-04 15:50 +0200
    Re: kmap_atomic and preemption Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2016-05-04 16:00 +0200
      Re: kmap_atomic and preemption Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-05-04 16:10 +0200
    Re: kmap_atomic and preemption Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-05-04 16:20 +0200
      Re: kmap_atomic and preemption Peter Zijlstra <peterz@infradead.org> - 2016-05-04 17:10 +0200
        Re: kmap_atomic and preemption Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-05-05 14:40 +0200
    Re: kmap_atomic and preemption Russell King - ARM Linux <linux@armlinux.org.uk> - 2016-05-04 21:30 +0200
      Re: kmap_atomic and preemption Peter Zijlstra <peterz@infradead.org> - 2016-05-05 11:40 +0200

csiph-web