]> git.karo-electronics.de Git - linux-beck.git/commitdiff
perf_counter, x86: Improve interactions with fast-gup
authorIngo Molnar <mingo@elte.hu>
Mon, 15 Jun 2009 09:35:01 +0000 (11:35 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 19 Jun 2009 14:55:16 +0000 (16:55 +0200)
Improve a few details in perfcounter call-chain recording that
makes use of fast-GUP:

- Use ACCESS_ONCE() to observe the pte value. ptes are fundamentally
  racy and can be changed on another CPU, so we have to be careful
  about how we access them. The PAE branch is already careful with
  read-barriers - but the non-PAE and 64-bit side needs an
  ACCESS_ONCE() to make sure the pte value is observed only once.

- make the checks a bit stricter so that we can feed it any kind of
  cra^H^H^H user-space input ;-)

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/include/asm/uaccess.h
arch/x86/mm/gup.c

index b685ece89d5cdcf7cca51fabb9dfdce5dd3e021d..512ee87062c20ba23e2cb508d3e2eb0408e7bfd0 100644 (file)
 #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
 
 #define KERNEL_DS      MAKE_MM_SEG(-1UL)
-#define USER_DS                MAKE_MM_SEG(PAGE_OFFSET)
+
+#ifdef CONFIG_X86_32
+# define USER_DS       MAKE_MM_SEG(PAGE_OFFSET)
+#else
+# define USER_DS       MAKE_MM_SEG(__VIRTUAL_MASK)
+#endif
 
 #define get_ds()       (KERNEL_DS)
 #define get_fs()       (current_thread_info()->addr_limit)
index 697d5727c119a2deebfe3958874dfb6f842517aa..2d1d784ad3f789aa250e86ba418013c8010484f3 100644 (file)
@@ -14,7 +14,7 @@
 static inline pte_t gup_get_pte(pte_t *ptep)
 {
 #ifndef CONFIG_X86_PAE
-       return *ptep;
+       return ACCESS_ONCE(*ptep);
 #else
        /*
         * With get_user_pages_fast, we walk down the pagetables without taking