diff options
Diffstat (limited to 'kernel/profile.c')
| -rw-r--r-- | kernel/profile.c | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/kernel/profile.c b/kernel/profile.c index ad81f799a9b4..5a730fdb1a2c 100644 --- a/kernel/profile.c +++ b/kernel/profile.c | |||
| @@ -87,72 +87,52 @@ void __init profile_init(void) | |||
| 87 | 87 | ||
| 88 | #ifdef CONFIG_PROFILING | 88 | #ifdef CONFIG_PROFILING |
| 89 | 89 | ||
| 90 | static DECLARE_RWSEM(profile_rwsem); | 90 | static BLOCKING_NOTIFIER_HEAD(task_exit_notifier); |
| 91 | static DEFINE_RWLOCK(handoff_lock); | 91 | static ATOMIC_NOTIFIER_HEAD(task_free_notifier); |
| 92 | static struct notifier_block * task_exit_notifier; | 92 | static BLOCKING_NOTIFIER_HEAD(munmap_notifier); |
| 93 | static struct notifier_block * task_free_notifier; | ||
| 94 | static struct notifier_block * munmap_notifier; | ||
| 95 | 93 | ||
| 96 | void profile_task_exit(struct task_struct * task) | 94 | void profile_task_exit(struct task_struct * task) |
| 97 | { | 95 | { |
| 98 | down_read(&profile_rwsem); | 96 | blocking_notifier_call_chain(&task_exit_notifier, 0, task); |
| 99 | notifier_call_chain(&task_exit_notifier, 0, task); | ||
| 100 | up_read(&profile_rwsem); | ||
| 101 | } | 97 | } |
| 102 | 98 | ||
| 103 | int profile_handoff_task(struct task_struct * task) | 99 | int profile_handoff_task(struct task_struct * task) |
| 104 | { | 100 | { |
| 105 | int ret; | 101 | int ret; |
| 106 | read_lock(&handoff_lock); | 102 | ret = atomic_notifier_call_chain(&task_free_notifier, 0, task); |
| 107 | ret = notifier_call_chain(&task_free_notifier, 0, task); | ||
| 108 | read_unlock(&handoff_lock); | ||
| 109 | return (ret == NOTIFY_OK) ? 1 : 0; | 103 | return (ret == NOTIFY_OK) ? 1 : 0; |
| 110 | } | 104 | } |
| 111 | 105 | ||
| 112 | void profile_munmap(unsigned long addr) | 106 | void profile_munmap(unsigned long addr) |
| 113 | { | 107 | { |
| 114 | down_read(&profile_rwsem); | 108 | blocking_notifier_call_chain(&munmap_notifier, 0, (void *)addr); |
| 115 | notifier_call_chain(&munmap_notifier, 0, (void *)addr); | ||
| 116 | up_read(&profile_rwsem); | ||
| 117 | } | 109 | } |
| 118 | 110 | ||
| 119 | int task_handoff_register(struct notifier_block * n) | 111 | int task_handoff_register(struct notifier_block * n) |
| 120 | { | 112 | { |
| 121 | int err = -EINVAL; | 113 | return atomic_notifier_chain_register(&task_free_notifier, n); |
| 122 | |||
| 123 | write_lock(&handoff_lock); | ||
| 124 | err = notifier_chain_register(&task_free_notifier, n); | ||
| 125 | write_unlock(&handoff_lock); | ||
| 126 | return err; | ||
| 127 | } | 114 | } |
| 128 | 115 | ||
| 129 | int task_handoff_unregister(struct notifier_block * n) | 116 | int task_handoff_unregister(struct notifier_block * n) |
| 130 | { | 117 | { |
| 131 | int err = -EINVAL; | 118 | return atomic_notifier_chain_unregister(&task_free_notifier, n); |
| 132 | |||
| 133 | write_lock(&handoff_lock); | ||
| 134 | err = notifier_chain_unregister(&task_free_notifier, n); | ||
| 135 | write_unlock(&handoff_lock); | ||
| 136 | return err; | ||
| 137 | } | 119 | } |
| 138 | 120 | ||
| 139 | int profile_event_register(enum profile_type type, struct notifier_block * n) | 121 | int profile_event_register(enum profile_type type, struct notifier_block * n) |
| 140 | { | 122 | { |
| 141 | int err = -EINVAL; | 123 | int err = -EINVAL; |
| 142 | 124 | ||
| 143 | down_write(&profile_rwsem); | ||
| 144 | |||
| 145 | switch (type) { | 125 | switch (type) { |
| 146 | case PROFILE_TASK_EXIT: | 126 | case PROFILE_TASK_EXIT: |
| 147 | err = notifier_chain_register(&task_exit_notifier, n); | 127 | err = blocking_notifier_chain_register( |
| 128 | &task_exit_notifier, n); | ||
| 148 | break; | 129 | break; |
| 149 | case PROFILE_MUNMAP: | 130 | case PROFILE_MUNMAP: |
| 150 | err = notifier_chain_register(&munmap_notifier, n); | 131 | err = blocking_notifier_chain_register( |
| 132 | &munmap_notifier, n); | ||
| 151 | break; | 133 | break; |
| 152 | } | 134 | } |
| 153 | 135 | ||
| 154 | up_write(&profile_rwsem); | ||
| 155 | |||
| 156 | return err; | 136 | return err; |
| 157 | } | 137 | } |
| 158 | 138 | ||
| @@ -161,18 +141,17 @@ int profile_event_unregister(enum profile_type type, struct notifier_block * n) | |||
| 161 | { | 141 | { |
| 162 | int err = -EINVAL; | 142 | int err = -EINVAL; |
| 163 | 143 | ||
| 164 | down_write(&profile_rwsem); | ||
| 165 | |||
| 166 | switch (type) { | 144 | switch (type) { |
| 167 | case PROFILE_TASK_EXIT: | 145 | case PROFILE_TASK_EXIT: |
| 168 | err = notifier_chain_unregister(&task_exit_notifier, n); | 146 | err = blocking_notifier_chain_unregister( |
| 147 | &task_exit_notifier, n); | ||
| 169 | break; | 148 | break; |
| 170 | case PROFILE_MUNMAP: | 149 | case PROFILE_MUNMAP: |
| 171 | err = notifier_chain_unregister(&munmap_notifier, n); | 150 | err = blocking_notifier_chain_unregister( |
| 151 | &munmap_notifier, n); | ||
| 172 | break; | 152 | break; |
| 173 | } | 153 | } |
| 174 | 154 | ||
| 175 | up_write(&profile_rwsem); | ||
| 176 | return err; | 155 | return err; |
| 177 | } | 156 | } |
| 178 | 157 | ||
