Commit 0c871971 authored by Ingo Molnar's avatar Ingo Molnar

perf_counter, x86: Improve interactions with fast-gup

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: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent e5289d4a
...@@ -25,7 +25,12 @@ ...@@ -25,7 +25,12 @@
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
#define KERNEL_DS MAKE_MM_SEG(-1UL) #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_ds() (KERNEL_DS)
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
static inline pte_t gup_get_pte(pte_t *ptep) static inline pte_t gup_get_pte(pte_t *ptep)
{ {
#ifndef CONFIG_X86_PAE #ifndef CONFIG_X86_PAE
return *ptep; return ACCESS_ONCE(*ptep);
#else #else
/* /*
* With get_user_pages_fast, we walk down the pagetables without taking * With get_user_pages_fast, we walk down the pagetables without taking
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment