Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a866374a authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Linus Torvalds
Browse files

[PATCH] mm: pagefault_{disable,enable}()



Introduce pagefault_{disable,enable}() and use these where previously we did
manual preempt increments/decrements to make the pagefault handler do the
atomic thing.

Currently they still rely on the increased preempt count, but do not rely on
the disabled preemption, this might go away in the future.

(NOTE: the extra barrier() in pagefault_disable might fix some holes on
       machines which have too many registers for their own good)

[heiko.carstens@de.ibm.com: s390 fix]
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: default avatarNick Piggin <npiggin@suse.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6edaf68a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
	if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
		return -EFAULT;

	inc_preempt_count();
	pagefault_disable();

	switch (op) {
	case FUTEX_OP_SET:
@@ -223,7 +223,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
		break;
	}

	dec_preempt_count();
	pagefault_enable();

	if (!ret) {
		switch (cmp) {
+4 −6
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
	unsigned long vaddr;

	/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
	inc_preempt_count();
	pagefault_disable();
	if (!PageHighMem(page))
		return page_address(page);

@@ -52,8 +52,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)

#ifdef CONFIG_DEBUG_HIGHMEM
	if (vaddr >= PAGE_OFFSET && vaddr < (unsigned long)high_memory) {
		dec_preempt_count();
		preempt_check_resched();
		pagefault_enable();
		return;
	}

@@ -68,8 +67,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
	 */
	kpte_clear_flush(kmap_pte-idx, vaddr);

	dec_preempt_count();
	preempt_check_resched();
	pagefault_enable();
}

/* This is the same as kmap_atomic() but can map memory that doesn't
@@ -80,7 +78,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
	enum fixed_addresses idx;
	unsigned long vaddr;

	inc_preempt_count();
	pagefault_disable();

	idx = type + KM_TYPE_NR*smp_processor_id();
	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+4 −6
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ void *__kmap_atomic(struct page *page, enum km_type type)
	unsigned long vaddr;

	/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
	inc_preempt_count();
	pagefault_disable();
	if (!PageHighMem(page))
		return page_address(page);

@@ -62,8 +62,7 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
	enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();

	if (vaddr < FIXADDR_START) { // FIXME
		dec_preempt_count();
		preempt_check_resched();
		pagefault_enable();
		return;
	}

@@ -78,8 +77,7 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
	local_flush_tlb_one(vaddr);
#endif

	dec_preempt_count();
	preempt_check_resched();
	pagefault_enable();
}

#ifndef CONFIG_LIMITED_DMA
@@ -92,7 +90,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
	enum fixed_addresses idx;
	unsigned long vaddr;

	inc_preempt_count();
	pagefault_disable();

	idx = type + KM_TYPE_NR*smp_processor_id();
	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+3 −3
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@

#include <linux/errno.h>
#include <linux/mm.h>
#include <asm/uaccess.h>
#include <linux/uaccess.h>
#include <asm/futex.h>

#ifndef __s390x__
@@ -258,7 +258,7 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
{
	int oldval = 0, newval, ret;

	inc_preempt_count();
	pagefault_disable();

	switch (op) {
	case FUTEX_OP_SET:
@@ -284,7 +284,7 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
	default:
		ret = -ENOSYS;
	}
	dec_preempt_count();
	pagefault_enable();
	*old = oldval;
	return ret;
}
+3 −5
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
	unsigned long vaddr;

	/* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
	inc_preempt_count();
	pagefault_disable();
	if (!PageHighMem(page))
		return page_address(page);

@@ -70,8 +70,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
	unsigned long idx = type + KM_TYPE_NR*smp_processor_id();

	if (vaddr < FIXADDR_START) { // FIXME
		dec_preempt_count();
		preempt_check_resched();
		pagefault_enable();
		return;
	}

@@ -97,8 +96,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
#endif
#endif

	dec_preempt_count();
	preempt_check_resched();
	pagefault_enable();
}

/* We may be fed a pagetable here by ptep_to_xxx and others. */
Loading