login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
September
»
5
Re: [RFC][PATCH] dynamically enable readprofile at runtime
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Randy Dunlap
Subject:
Re: [RFC][PATCH] dynamically enable readprofile at runtime
Date: Thursday, September 4, 2008 - 7:03 pm
On Fri, 29 Aug 2008 13:27:13 -0700 Dave Hansen wrote:
quoted text
> 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.
I like it.
quoted text
> Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com> > --- > > linux-2.6.git-dave/kernel/ksysfs.c | 29 +++++++++++++++++++++++++++++ > linux-2.6.git-dave/kernel/profile.c | 33 ++++++++++++++++++++++++--------- > 2 files changed, 53 insertions(+), 9 deletions(-) > > diff -puN kernel/ksysfs.c~dynamic-readprofile kernel/ksysfs.c > --- linux-2.6.git/kernel/ksysfs.c~dynamic-readprofile 2008-08-29 13:15:52.000000000 -0700 > +++ linux-2.6.git-dave/kernel/ksysfs.c 2008-08-29 13:19:03.000000000 -0700 > @@ -14,6 +14,7 @@ > #include <linux/module.h> > #include <linux/init.h> > #include <linux/kexec.h> > +#include <linux/profile.h> > #include <linux/sched.h> > > #define KERNEL_ATTR_RO(_name) \ > @@ -53,6 +54,31 @@ static ssize_t uevent_helper_store(struc > KERNEL_ATTR_RW(uevent_helper); > #endif > > +#ifdef CONFIG_PROFILING > +/* uevent helper program, used during early boo */
s/boo/boot/ ??
quoted text
> +static ssize_t profiling_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + return sprintf(buf, "%d\n", prof_on); > +} > +static ssize_t profiling_store(struct kobject *kobj, > + struct kobj_attribute *attr, > + const char *buf, size_t count) > +{ > + int ret; > + > + profile_setup(buf); > + profile_init(); > + if (!prof_buffer) > + return -ENOMEM; > + ret = create_proc_profile(); > + if (ret) > + return ret; > + return count; > +} > +KERNEL_ATTR_RW(profiling); > +#endif > + > #ifdef CONFIG_KEXEC > static ssize_t kexec_loaded_show(struct kobject *kobj, > struct kobj_attribute *attr, char *buf) > @@ -109,6 +135,9 @@ static struct attribute * kernel_attrs[] > &uevent_seqnum_attr.attr, > &uevent_helper_attr.attr, > #endif > +#ifdef CONFIG_PROFILING > + &profiling_attr.attr, > +#endif > #ifdef CONFIG_KEXEC > &kexec_loaded_attr.attr, > &kexec_crash_loaded_attr.attr, > diff -puN kernel/profile.c~dynamic-readprofile kernel/profile.c > --- linux-2.6.git/kernel/profile.c~dynamic-readprofile 2008-08-29 13:15:52.000000000 -0700 > +++ linux-2.6.git-dave/kernel/profile.c 2008-08-29 13:18:50.000000000 -0700 > @@ -50,11 +50,11 @@ static DEFINE_PER_CPU(int, cpu_profile_f > static DEFINE_MUTEX(profile_flip_mutex); > #endif /* CONFIG_SMP */ > > -static int __init profile_setup(char *str) > +int profile_setup(char *str) > { > - static char __initdata schedstr[] = "schedule"; > - static char __initdata sleepstr[] = "sleep"; > - static char __initdata kvmstr[] = "kvm"; > + static char schedstr[] = "schedule"; > + static char sleepstr[] = "sleep"; > + static char kvmstr[] = "kvm"; > int par; > > if (!strncmp(str, sleepstr, strlen(sleepstr))) { > @@ -100,14 +100,29 @@ static int __init profile_setup(char *st > __setup("profile=", profile_setup); > > > -void __init profile_init(void) > +void profile_init(void) > { > + int buffer_bytes; > if (!prof_on) > return; > > /* only text is profiled */ > prof_len = (_etext - _stext) >> prof_shift; > - prof_buffer = alloc_bootmem(prof_len*sizeof(atomic_t)); > + buffer_bytes = prof_len*sizeof(atomic_t); > + if (!slab_is_available()) { > + prof_buffer = alloc_bootmem(buffer_bytes); > + return; > + } > + > + prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL); > + if (prof_buffer) > + return; > + > + prof_buffer = alloc_pages_exact(buffer_bytes, GFP_KERNEL|__GFP_ZERO); > + if (prof_buffer) > + return; > + > + prof_buffer = vmalloc(buffer_bytes); > } > > /* Profile event notifications */ > @@ -527,7 +542,7 @@ static void __init profile_nop(void *unu > { > } > > -static int __init create_hash_tables(void) > +static int create_hash_tables(void) > { > int cpu; > > @@ -575,14 +590,14 @@ out_cleanup: > #define create_hash_tables() ({ 0; }) > #endif > > -static int __init create_proc_profile(void) > +int create_proc_profile(void) > { > struct proc_dir_entry *entry; > > if (!prof_on) > return 0; > if (create_hash_tables()) > - return -1; > + return -ENOMEM; > entry = proc_create("profile", S_IWUSR | S_IRUGO, > NULL, &proc_profile_operations); > if (!entry)
--- ~Randy Linux Plumbers Conference, 17-19 September 2008, Portland, Oregon USA
http://linuxplumbersconf.org/
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[RFC][PATCH] dynamically enable readprofile at runtime
, Dave Hansen
, (Fri Aug 29, 1:27 pm)
Re: [RFC][PATCH] dynamically enable readprofile at runtime
, Randy Dunlap
, (Thu Sep 4, 7:03 pm)
Re: [RFC][PATCH] dynamically enable readprofile at runtime
, Dave Hansen
, (Fri Sep 5, 9:18 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Jan Engelhardt
Re: Linux Security *Module* Framework (Was: LSM conversion to static interface)
Luben Tuikov
Re: Integration of SCST in the mainstream Linux kernel
Christoph Lameter
[PATCH 1/2] Make page->private usable in compound pages V1
Michal Nazarewicz
Re: [PATCH] USB: Gadget: g_multi: added INF file for gadget with multiple configur...
Frederic Weisbecker
Re: [PATCH v4 5/5] perf:add a script shows a process of packet
git
:
Jan Harkes
Re: git-svn and huge data and modifying the git-svn-HEAD branch directly
Andy Parkins
git-fetch fails with error code 128
Eli Zaretskii
Re: Switching from CVS to GIT
Matthieu Moy
Re: git pull (Your local changes to ... would be overwritten by merge)
Jakub Narebski
Re: GSoC 2008 - Mentors Wanted!
git-commits-head
:
Linux Kernel Mailing List
No need to do lock_super() for exclusion in generic_shutdown_super()
Linux Kernel Mailing List
x86, msr: Export the register-setting MSR functions via /dev/*/msr
Linux Kernel Mailing List
sh-sci: update receive error handling for muxed irqs
Linux Kernel Mailing List
ARM: 5970/1: nomadik-gpio: fix spinlock usage
Linux Kernel Mailing List
Input: gpio-keys - add support for disabling gpios through sysfs
linux-netdev
:
Patrick McHardy
[NET_SCHED]: sch_ingress: remove netfilter support
Patrick McHardy
Re: no reassembly for outgoing packets on RAW socket
Frans Pop
svc: failed to register lockdv1 RPC service (errno 97).
Rose, Gregory V
RE: __bad_udelay in network driver breaks build
Eric Dumazet
[PATCH] net: ALIGN/PTR_ALIGN cleanup in alloc_netdev_mq()/netdev_priv()
openbsd-misc
:
elitdostlar
Seks partneri arayan bayanlar bu adreste - 8878xs706x6438
Marcus Andree
Re: This is what Linus Torvalds calls openBSD crowd
Lars D. Noodén
Re: sshd.config and AllowUsers
ropers
Re: Real men don't attack straw men
Henning Brauer
Re: Sun Blade 1000?
Colocation donated by:
Syndicate