aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2015-04-06 17:53:17 -0700
committerrogersb11 <brettrogers11@gmail.com>2015-12-02 12:26:42 -0500
commitc3fc2581d22148f67d89e9007bd05e1fc22a5e21 (patch)
tree7f7b5ae0c325c9c6ae0ff3cd45e0fd6fcd25a53a
parentf5ceef891ba22738dcb22ef2d2bed2b62b5e6858 (diff)
downloadkernel_samsung_smdk4412-c3fc2581d22148f67d89e9007bd05e1fc22a5e21.zip
kernel_samsung_smdk4412-c3fc2581d22148f67d89e9007bd05e1fc22a5e21.tar.gz
kernel_samsung_smdk4412-c3fc2581d22148f67d89e9007bd05e1fc22a5e21.tar.bz2
proc: uid: Changes the thread notifier to profile event notifier.
In order to keep the code consistent with all other platforms, the thread notifier is changed to profile event notifier. Change-Id: I5b996c789927b42dacba10af6fe81a21866e2c8f
-rw-r--r--drivers/misc/Kconfig2
-rw-r--r--drivers/misc/uid_cputime.c51
2 files changed, 19 insertions, 34 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a946880..0559caa 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -704,7 +704,7 @@ config MPU_SENSORS_MPU6050
config UID_CPUTIME
tristate "Per-UID cpu time statistics"
- default n
+ depends on PROFILING
help
Per UID based cpu time statistics exported to /proc/uid_cputime
diff --git a/drivers/misc/uid_cputime.c b/drivers/misc/uid_cputime.c
index c032197..87c8ddd 100644
--- a/drivers/misc/uid_cputime.c
+++ b/drivers/misc/uid_cputime.c
@@ -13,8 +13,6 @@
*
*/
-#include <asm/thread_notify.h>
-
#include <linux/atomic.h>
#include <linux/err.h>
#include <linux/hashtable.h>
@@ -22,6 +20,7 @@
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/proc_fs.h>
+#include <linux/profile.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
@@ -30,7 +29,7 @@
#define UID_HASH_BITS 10
DECLARE_HASHTABLE(hash_table, UID_HASH_BITS);
-static DEFINE_SPINLOCK(uid_lock);
+static DEFINE_MUTEX(uid_lock);
static struct proc_dir_entry *parent;
struct uid_entry {
@@ -82,7 +81,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
cputime_t stime;
unsigned long bkt;
- spin_lock(&uid_lock);
+ mutex_lock(&uid_lock);
hash_for_each(hash_table, bkt, node, uid_entry, hash) {
uid_entry->active_stime = 0;
@@ -94,7 +93,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
uid_entry = find_or_register_uid(task_uid(task));
if (!uid_entry) {
read_unlock(&tasklist_lock);
- spin_unlock(&uid_lock);
+ mutex_unlock(&uid_lock);
pr_err("%s: failed to find the uid_entry for uid %d\n",
__func__, task_uid(task));
return -ENOMEM;
@@ -115,7 +114,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
cputime_to_usecs(total_stime));
}
- spin_unlock(&uid_lock);
+ mutex_unlock(&uid_lock);
return 0;
}
@@ -163,7 +162,7 @@ static ssize_t uid_remove_write(struct file *file,
return -EINVAL;
}
- spin_lock(&uid_lock);
+ mutex_lock(&uid_lock);
for (; uid_start <= uid_end; uid_start++) {
hash_for_each_possible_safe(hash_table, uid_entry, node, tmp,
@@ -173,7 +172,7 @@ static ssize_t uid_remove_write(struct file *file,
}
}
- spin_unlock(&uid_lock);
+ mutex_unlock(&uid_lock);
return count;
}
@@ -183,14 +182,19 @@ static const struct file_operations uid_remove_fops = {
.write = uid_remove_write,
};
-static void uid_task_exit(struct task_struct *task)
+static int process_notifier(struct notifier_block *self,
+ unsigned long cmd, void *v)
{
+ struct task_struct *task = v;
struct uid_entry *uid_entry;
- uid_t uid = task_uid(task);
cputime_t utime, stime;
+ uid_t uid;
- spin_lock(&uid_lock);
+ if (!task)
+ return NOTIFY_OK;
+ mutex_lock(&uid_lock);
+ uid = task_uid(task);
uid_entry = find_or_register_uid(uid);
if (!uid_entry) {
pr_err("%s: failed to find uid %d\n", __func__, uid);
@@ -202,27 +206,8 @@ static void uid_task_exit(struct task_struct *task)
uid_entry->stime += stime;
exit:
- spin_unlock(&uid_lock);
-}
-
-static int process_notifier(struct notifier_block *self,
- unsigned long cmd, void *v)
-{
- struct thread_info *thread = v;
- struct task_struct *task = v ? thread->task : NULL;
-
- if (!task)
- return NOTIFY_DONE;
-
- switch (cmd) {
- case THREAD_NOTIFY_EXIT:
- uid_task_exit(task);
- break;
- default:
- break;
- }
-
- return NOTIFY_DONE;
+ mutex_unlock(&uid_lock);
+ return NOTIFY_OK;
}
static struct notifier_block process_notifier_block = {
@@ -245,7 +230,7 @@ static int __init proc_uid_cputime_init(void)
proc_create_data("show_uid_stat", S_IWUGO, parent, &uid_stat_fops,
NULL);
- thread_register_notifier(&process_notifier_block);
+ profile_event_register(PROFILE_TASK_EXIT, &process_notifier_block);
return 0;
}