diff options
author | Dave Hansen <dave@linux.vnet.ibm.com> | 2008-10-16 01:01:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:31 -0400 |
commit | 22b8ce94708f7cdf0b04965c6f7443dfd374c35c (patch) | |
tree | e2d5b60e9b881cf251185b23c3853c8b3e52d42a /kernel/ksysfs.c | |
parent | 0c2d64fb6cae9aae480f6a46cfe79f8d7d48b59f (diff) |
profiling: dynamically enable readprofile at runtime
Way too often, I have a machine that exhibits some kind of crappy
behavior. The CPU looks wedged in the kernel or it is spending way too
much system time and I wonder what is responsible.
I try to run readprofile. But, of course, Ubuntu doesn't enable it by
default. Dang!
The reason we boot-time enable it is that it takes a big bufffer that we
generally can only bootmem alloc. But, does it hurt to at least try and
runtime-alloc it?
To use:
echo 2 > /sys/kernel/profile
Then run readprofile like normal.
This should fix the compile issue with allmodconfig. I've compile-tested
on a bunch more configs now including a few more architectures.
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/ksysfs.c')
-rw-r--r-- | kernel/ksysfs.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index e53bc30e9ba5..08dd8ed86c77 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/kexec.h> | 16 | #include <linux/kexec.h> |
17 | #include <linux/profile.h> | ||
17 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
18 | 19 | ||
19 | #define KERNEL_ATTR_RO(_name) \ | 20 | #define KERNEL_ATTR_RO(_name) \ |
@@ -53,6 +54,37 @@ static ssize_t uevent_helper_store(struct kobject *kobj, | |||
53 | KERNEL_ATTR_RW(uevent_helper); | 54 | KERNEL_ATTR_RW(uevent_helper); |
54 | #endif | 55 | #endif |
55 | 56 | ||
57 | #ifdef CONFIG_PROFILING | ||
58 | static ssize_t profiling_show(struct kobject *kobj, | ||
59 | struct kobj_attribute *attr, char *buf) | ||
60 | { | ||
61 | return sprintf(buf, "%d\n", prof_on); | ||
62 | } | ||
63 | static ssize_t profiling_store(struct kobject *kobj, | ||
64 | struct kobj_attribute *attr, | ||
65 | const char *buf, size_t count) | ||
66 | { | ||
67 | int ret; | ||
68 | |||
69 | if (prof_on) | ||
70 | return -EEXIST; | ||
71 | /* | ||
72 | * This eventually calls into get_option() which | ||
73 | * has a ton of callers and is not const. It is | ||
74 | * easiest to cast it away here. | ||
75 | */ | ||
76 | profile_setup((char *)buf); | ||
77 | ret = profile_init(); | ||
78 | if (ret) | ||
79 | return ret; | ||
80 | ret = create_proc_profile(); | ||
81 | if (ret) | ||
82 | return ret; | ||
83 | return count; | ||
84 | } | ||
85 | KERNEL_ATTR_RW(profiling); | ||
86 | #endif | ||
87 | |||
56 | #ifdef CONFIG_KEXEC | 88 | #ifdef CONFIG_KEXEC |
57 | static ssize_t kexec_loaded_show(struct kobject *kobj, | 89 | static ssize_t kexec_loaded_show(struct kobject *kobj, |
58 | struct kobj_attribute *attr, char *buf) | 90 | struct kobj_attribute *attr, char *buf) |
@@ -109,6 +141,9 @@ static struct attribute * kernel_attrs[] = { | |||
109 | &uevent_seqnum_attr.attr, | 141 | &uevent_seqnum_attr.attr, |
110 | &uevent_helper_attr.attr, | 142 | &uevent_helper_attr.attr, |
111 | #endif | 143 | #endif |
144 | #ifdef CONFIG_PROFILING | ||
145 | &profiling_attr.attr, | ||
146 | #endif | ||
112 | #ifdef CONFIG_KEXEC | 147 | #ifdef CONFIG_KEXEC |
113 | &kexec_loaded_attr.attr, | 148 | &kexec_loaded_attr.attr, |
114 | &kexec_crash_loaded_attr.attr, | 149 | &kexec_crash_loaded_attr.attr, |