diff options
| -rw-r--r-- | drivers/oprofile/buffer_sync.c | 6 | ||||
| -rw-r--r-- | drivers/oprofile/cpu_buffer.h | 20 |
2 files changed, 24 insertions, 2 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c index d969bb13a25..f9031d31eeb 100644 --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c | |||
| @@ -524,6 +524,7 @@ void sync_buffer(int cpu) | |||
| 524 | { | 524 | { |
| 525 | struct mm_struct *mm = NULL; | 525 | struct mm_struct *mm = NULL; |
| 526 | struct mm_struct *oldmm; | 526 | struct mm_struct *oldmm; |
| 527 | unsigned long val; | ||
| 527 | struct task_struct *new; | 528 | struct task_struct *new; |
| 528 | unsigned long cookie = 0; | 529 | unsigned long cookie = 0; |
| 529 | int in_kernel = 1; | 530 | int in_kernel = 1; |
| @@ -559,10 +560,11 @@ void sync_buffer(int cpu) | |||
| 559 | state = sb_sample_start; | 560 | state = sb_sample_start; |
| 560 | add_kernel_ctx_switch(flags & IS_KERNEL); | 561 | add_kernel_ctx_switch(flags & IS_KERNEL); |
| 561 | } | 562 | } |
| 562 | if (flags & USER_CTX_SWITCH) { | 563 | if (flags & USER_CTX_SWITCH |
| 564 | && op_cpu_buffer_get_data(&entry, &val)) { | ||
| 563 | /* userspace context switch */ | 565 | /* userspace context switch */ |
| 566 | new = (struct task_struct *)val; | ||
| 564 | oldmm = mm; | 567 | oldmm = mm; |
| 565 | new = (struct task_struct *)sample->data[0]; | ||
| 566 | release_mm(oldmm); | 568 | release_mm(oldmm); |
| 567 | mm = take_tasks_mm(new); | 569 | mm = take_tasks_mm(new); |
| 568 | if (mm != oldmm) | 570 | if (mm != oldmm) |
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h index e178dd2799c..f3437604657 100644 --- a/drivers/oprofile/cpu_buffer.h +++ b/drivers/oprofile/cpu_buffer.h | |||
| @@ -90,6 +90,26 @@ int op_cpu_buffer_add_data(struct op_entry *entry, unsigned long val) | |||
| 90 | return entry->size; | 90 | return entry->size; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | /* returns the size of data in the entry */ | ||
| 94 | static inline | ||
| 95 | int op_cpu_buffer_get_size(struct op_entry *entry) | ||
| 96 | { | ||
| 97 | return entry->size; | ||
| 98 | } | ||
| 99 | |||
| 100 | /* returns 0 if empty or the size of data including the current value */ | ||
| 101 | static inline | ||
| 102 | int op_cpu_buffer_get_data(struct op_entry *entry, unsigned long *val) | ||
| 103 | { | ||
| 104 | int size = entry->size; | ||
| 105 | if (!size) | ||
| 106 | return 0; | ||
| 107 | *val = *entry->data; | ||
| 108 | entry->size--; | ||
| 109 | entry->data++; | ||
| 110 | return size; | ||
| 111 | } | ||
| 112 | |||
| 93 | /* extra data flags */ | 113 | /* extra data flags */ |
| 94 | #define KERNEL_CTX_SWITCH (1UL << 0) | 114 | #define KERNEL_CTX_SWITCH (1UL << 0) |
| 95 | #define IS_KERNEL (1UL << 1) | 115 | #define IS_KERNEL (1UL << 1) |
