2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* linux/kernel/profile.c
|
|
|
|
* Simple profiling. Manages a direct-mapped profile hit count buffer,
|
|
|
|
* with configurable resolution, support for restricting the cpus on
|
|
|
|
* which profiling is done, and switching between cpu time and
|
|
|
|
* schedule() calls via kernel command line parameters passed at boot.
|
|
|
|
*
|
|
|
|
* Scheduler profiling support, Arjan van de Ven and Ingo Molnar,
|
|
|
|
* Red Hat, July 2004
|
|
|
|
* Consolidation of architecture support code for profiling,
|
|
|
|
* William Irwin, Oracle, July 2004
|
|
|
|
* Amortized hit count accounting via per-cpu open-addressed hashtables
|
|
|
|
* to resolve timer interrupt livelocks, William Irwin, Oracle, 2004
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/profile.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
#include <linux/notifier.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/cpumask.h>
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <linux/highmem.h>
|
2006-03-23 04:00:24 -07:00
|
|
|
#include <linux/mutex.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/sections.h>
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 06:55:46 -07:00
|
|
|
#include <asm/irq_regs.h>
|
Detach sched.h from mm.h
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.
This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
getting them indirectly
Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
they don't need sched.h
b) sched.h stops being dependency for significant number of files:
on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
after patch it's only 3744 (-8.3%).
Cross-compile tested on
all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
alpha alpha-up
arm
i386 i386-up i386-defconfig i386-allnoconfig
ia64 ia64-up
m68k
mips
parisc parisc-up
powerpc powerpc-up
s390 s390-up
sparc sparc-up
sparc64 sparc64-up
um-x86_64
x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig
as well as my two usual configs.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-20 14:22:52 -07:00
|
|
|
#include <asm/ptrace.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
struct profile_hit {
|
|
|
|
u32 pc, hits;
|
|
|
|
};
|
|
|
|
#define PROFILE_GRPSHIFT 3
|
|
|
|
#define PROFILE_GRPSZ (1 << PROFILE_GRPSHIFT)
|
|
|
|
#define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
|
|
|
|
#define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
|
|
|
|
|
|
|
|
/* Oprofile timer tick hook */
|
2007-10-16 23:29:26 -07:00
|
|
|
static int (*timer_hook)(struct pt_regs *) __read_mostly;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
static atomic_t *prof_buffer;
|
|
|
|
static unsigned long prof_len, prof_shift;
|
2007-01-11 00:15:38 -07:00
|
|
|
|
2006-12-06 21:37:24 -07:00
|
|
|
int prof_on __read_mostly;
|
2007-01-11 00:15:38 -07:00
|
|
|
EXPORT_SYMBOL_GPL(prof_on);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
|
|
|
|
static DEFINE_PER_CPU(int, cpu_profile_flip);
|
2006-03-23 04:00:24 -07:00
|
|
|
static DEFINE_MUTEX(profile_flip_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
|
2008-01-25 13:08:33 -07:00
|
|
|
static int __init profile_setup(char *str)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2005-05-16 21:53:58 -07:00
|
|
|
static char __initdata schedstr[] = "schedule";
|
2006-12-06 21:37:24 -07:00
|
|
|
static char __initdata sleepstr[] = "sleep";
|
2007-01-11 00:15:38 -07:00
|
|
|
static char __initdata kvmstr[] = "kvm";
|
2005-04-16 15:20:36 -07:00
|
|
|
int par;
|
|
|
|
|
2006-12-06 21:37:24 -07:00
|
|
|
if (!strncmp(str, sleepstr, strlen(sleepstr))) {
|
2007-10-24 09:23:50 -07:00
|
|
|
#ifdef CONFIG_SCHEDSTATS
|
2006-12-06 21:37:24 -07:00
|
|
|
prof_on = SLEEP_PROFILING;
|
|
|
|
if (str[strlen(sleepstr)] == ',')
|
|
|
|
str += strlen(sleepstr) + 1;
|
|
|
|
if (get_option(&str, &par))
|
|
|
|
prof_shift = par;
|
|
|
|
printk(KERN_INFO
|
|
|
|
"kernel sleep profiling enabled (shift: %ld)\n",
|
|
|
|
prof_shift);
|
2007-10-24 09:23:50 -07:00
|
|
|
#else
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"kernel sleep profiling requires CONFIG_SCHEDSTATS\n");
|
|
|
|
#endif /* CONFIG_SCHEDSTATS */
|
2007-01-05 17:36:29 -07:00
|
|
|
} else if (!strncmp(str, schedstr, strlen(schedstr))) {
|
2005-04-16 15:20:36 -07:00
|
|
|
prof_on = SCHED_PROFILING;
|
2005-05-16 21:53:58 -07:00
|
|
|
if (str[strlen(schedstr)] == ',')
|
|
|
|
str += strlen(schedstr) + 1;
|
|
|
|
if (get_option(&str, &par))
|
|
|
|
prof_shift = par;
|
|
|
|
printk(KERN_INFO
|
|
|
|
"kernel schedule profiling enabled (shift: %ld)\n",
|
|
|
|
prof_shift);
|
2007-01-11 00:15:38 -07:00
|
|
|
} else if (!strncmp(str, kvmstr, strlen(kvmstr))) {
|
|
|
|
prof_on = KVM_PROFILING;
|
|
|
|
if (str[strlen(kvmstr)] == ',')
|
|
|
|
str += strlen(kvmstr) + 1;
|
|
|
|
if (get_option(&str, &par))
|
|
|
|
prof_shift = par;
|
|
|
|
printk(KERN_INFO
|
|
|
|
"kernel KVM profiling enabled (shift: %ld)\n",
|
|
|
|
prof_shift);
|
2005-05-16 21:53:58 -07:00
|
|
|
} else if (get_option(&str, &par)) {
|
2005-04-16 15:20:36 -07:00
|
|
|
prof_shift = par;
|
|
|
|
prof_on = CPU_PROFILING;
|
|
|
|
printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n",
|
|
|
|
prof_shift);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("profile=", profile_setup);
|
|
|
|
|
|
|
|
|
|
|
|
void __init profile_init(void)
|
|
|
|
{
|
2008-01-25 13:08:33 -07:00
|
|
|
if (!prof_on)
|
2005-04-16 15:20:36 -07:00
|
|
|
return;
|
2008-01-25 13:08:33 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* only text is profiled */
|
|
|
|
prof_len = (_etext - _stext) >> prof_shift;
|
|
|
|
prof_buffer = alloc_bootmem(prof_len*sizeof(atomic_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Profile event notifications */
|
2008-01-25 13:08:33 -07:00
|
|
|
|
[PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
We noticed that notifier chains in the kernel fall into two basic usage
classes:
"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;
"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.
We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.
With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)
There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)
Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.
Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.
ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain
BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain
It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)
The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.
[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-27 02:16:30 -07:00
|
|
|
static BLOCKING_NOTIFIER_HEAD(task_exit_notifier);
|
|
|
|
static ATOMIC_NOTIFIER_HEAD(task_free_notifier);
|
|
|
|
static BLOCKING_NOTIFIER_HEAD(munmap_notifier);
|
2008-01-25 13:08:33 -07:00
|
|
|
|
|
|
|
void profile_task_exit(struct task_struct *task)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
[PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
We noticed that notifier chains in the kernel fall into two basic usage
classes:
"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;
"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.
We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.
With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)
There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)
Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.
Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.
ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain
BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain
It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)
The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.
[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-27 02:16:30 -07:00
|
|
|
blocking_notifier_call_chain(&task_exit_notifier, 0, task);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2008-01-25 13:08:33 -07:00
|
|
|
|
|
|
|
int profile_handoff_task(struct task_struct *task)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
int ret;
|
[PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
We noticed that notifier chains in the kernel fall into two basic usage
classes:
"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;
"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.
We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.
With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)
There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)
Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.
Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.
ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain
BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain
It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)
The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.
[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-27 02:16:30 -07:00
|
|
|
ret = atomic_notifier_call_chain(&task_free_notifier, 0, task);
|
2005-04-16 15:20:36 -07:00
|
|
|
return (ret == NOTIFY_OK) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void profile_munmap(unsigned long addr)
|
|
|
|
{
|
[PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
We noticed that notifier chains in the kernel fall into two basic usage
classes:
"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;
"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.
We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.
With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)
There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)
Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.
Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.
ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain
BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain
It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)
The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.
[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-27 02:16:30 -07:00
|
|
|
blocking_notifier_call_chain(&munmap_notifier, 0, (void *)addr);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-01-25 13:08:33 -07:00
|
|
|
int task_handoff_register(struct notifier_block *n)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
[PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
We noticed that notifier chains in the kernel fall into two basic usage
classes:
"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;
"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.
We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.
With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)
There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)
Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.
Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.
ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain
BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain
It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)
The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.
[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-27 02:16:30 -07:00
|
|
|
return atomic_notifier_chain_register(&task_free_notifier, n);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2008-01-25 13:08:33 -07:00
|
|
|
EXPORT_SYMBOL_GPL(task_handoff_register);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-01-25 13:08:33 -07:00
|
|
|
int task_handoff_unregister(struct notifier_block *n)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
[PATCH] Notifier chain update: API changes
The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
We noticed that notifier chains in the kernel fall into two basic usage
classes:
"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;
"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.
We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.
With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)
There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)
Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.
Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.
ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain
BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain
It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)
The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.
[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-03-27 02:16:30 -07:00
|
|
|
return atomic_notifier_chain_unregister(&task_free_notifier, n);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2008-01-25 13:08:33 -07:00
|
|
|
EXPORT_SYMBOL_GPL(task_handoff_unregister);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-01-25 13:08:33 -07:00
|
|
|
int profile_event_register(enum profile_type type, struct notifier_block *n)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
int err = -EINVAL;
|
2008-01-25 13:08:33 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
switch (type) {
|
2008-01-25 13:08:33 -07:00
|
|
|
case PROFILE_TASK_EXIT:
|
|
|
|
err = blocking_notifier_chain_register(
|
|
|
|
&task_exit_notifier, n);
|
|
|
|
break;
|
|
|
|
case PROFILE_MUNMAP:
|
|
|
|
err = blocking_notifier_chain_register(
|
|
|
|
&munmap_notifier, n);
|
|
|
|
break;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2008-01-25 13:08:33 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
return err;
|
|
|
|
}
|
2008-01-25 13:08:33 -07:00
|
|
|
EXPORT_SYMBOL_GPL(profile_event_register);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-01-25 13:08:33 -07:00
|
|
|
int profile_event_unregister(enum profile_type type, struct notifier_block *n)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
int err = -EINVAL;
|
2008-01-25 13:08:33 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
switch (type) {
|
2008-01-25 13:08:33 -07:00
|
|
|
case PROFILE_TASK_EXIT:
|
|
|
|
err = blocking_notifier_chain_unregister(
|
|
|
|
&task_exit_notifier, n);
|
|
|
|
break;
|
|
|
|
case PROFILE_MUNMAP:
|
|
|
|
err = blocking_notifier_chain_unregister(
|
|
|
|
&munmap_notifier, n);
|
|
|
|
break;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
2008-01-25 13:08:33 -07:00
|
|
|
EXPORT_SYMBOL_GPL(profile_event_unregister);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
int register_timer_hook(int (*hook)(struct pt_regs *))
|
|
|
|
{
|
|
|
|
if (timer_hook)
|
|
|
|
return -EBUSY;
|
|
|
|
timer_hook = hook;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-01-25 13:08:33 -07:00
|
|
|
EXPORT_SYMBOL_GPL(register_timer_hook);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
void unregister_timer_hook(int (*hook)(struct pt_regs *))
|
|
|
|
{
|
|
|
|
WARN_ON(hook != timer_hook);
|
|
|
|
timer_hook = NULL;
|
|
|
|
/* make sure all CPUs see the NULL hook */
|
2005-05-01 08:59:04 -07:00
|
|
|
synchronize_sched(); /* Allow ongoing interrupts to complete. */
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(unregister_timer_hook);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/*
|
|
|
|
* Each cpu has a pair of open-addressed hashtables for pending
|
|
|
|
* profile hits. read_profile() IPI's all cpus to request them
|
|
|
|
* to flip buffers and flushes their contents to prof_buffer itself.
|
|
|
|
* Flip requests are serialized by the profile_flip_mutex. The sole
|
|
|
|
* use of having a second hashtable is for avoiding cacheline
|
|
|
|
* contention that would otherwise happen during flushes of pending
|
|
|
|
* profile hits required for the accuracy of reported profile hits
|
|
|
|
* and so resurrect the interrupt livelock issue.
|
|
|
|
*
|
|
|
|
* The open-addressed hashtables are indexed by profile buffer slot
|
|
|
|
* and hold the number of pending hits to that profile buffer slot on
|
|
|
|
* a cpu in an entry. When the hashtable overflows, all pending hits
|
|
|
|
* are accounted to their corresponding profile buffer slots with
|
|
|
|
* atomic_add() and the hashtable emptied. As numerous pending hits
|
|
|
|
* may be accounted to a profile buffer slot in a hashtable entry,
|
|
|
|
* this amortizes a number of atomic profile buffer increments likely
|
|
|
|
* to be far larger than the number of entries in the hashtable,
|
|
|
|
* particularly given that the number of distinct profile buffer
|
|
|
|
* positions to which hits are accounted during short intervals (e.g.
|
|
|
|
* several seconds) is usually very small. Exclusion from buffer
|
|
|
|
* flipping is provided by interrupt disablement (note that for
|
2006-12-06 21:37:24 -07:00
|
|
|
* SCHED_PROFILING or SLEEP_PROFILING profile_hit() may be called from
|
|
|
|
* process context).
|
2005-04-16 15:20:36 -07:00
|
|
|
* The hash function is meant to be lightweight as opposed to strong,
|
|
|
|
* and was vaguely inspired by ppc64 firmware-supported inverted
|
|
|
|
* pagetable hash functions, but uses a full hashtable full of finite
|
|
|
|
* collision chains, not just pairs of them.
|
|
|
|
*
|
|
|
|
* -- wli
|
|
|
|
*/
|
|
|
|
static void __profile_flip_buffers(void *unused)
|
|
|
|
{
|
|
|
|
int cpu = smp_processor_id();
|
|
|
|
|
|
|
|
per_cpu(cpu_profile_flip, cpu) = !per_cpu(cpu_profile_flip, cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void profile_flip_buffers(void)
|
|
|
|
{
|
|
|
|
int i, j, cpu;
|
|
|
|
|
2006-03-23 04:00:24 -07:00
|
|
|
mutex_lock(&profile_flip_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
j = per_cpu(cpu_profile_flip, get_cpu());
|
|
|
|
put_cpu();
|
2008-05-09 00:39:44 -07:00
|
|
|
on_each_cpu(__profile_flip_buffers, NULL, 1);
|
2005-04-16 15:20:36 -07:00
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[j];
|
|
|
|
for (i = 0; i < NR_PROFILE_HIT; ++i) {
|
|
|
|
if (!hits[i].hits) {
|
|
|
|
if (hits[i].pc)
|
|
|
|
hits[i].pc = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
|
|
|
|
hits[i].hits = hits[i].pc = 0;
|
|
|
|
}
|
|
|
|
}
|
2006-03-23 04:00:24 -07:00
|
|
|
mutex_unlock(&profile_flip_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void profile_discard_flip_buffers(void)
|
|
|
|
{
|
|
|
|
int i, cpu;
|
|
|
|
|
2006-03-23 04:00:24 -07:00
|
|
|
mutex_lock(&profile_flip_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
i = per_cpu(cpu_profile_flip, get_cpu());
|
|
|
|
put_cpu();
|
2008-05-09 00:39:44 -07:00
|
|
|
on_each_cpu(__profile_flip_buffers, NULL, 1);
|
2005-04-16 15:20:36 -07:00
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i];
|
|
|
|
memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit));
|
|
|
|
}
|
2006-03-23 04:00:24 -07:00
|
|
|
mutex_unlock(&profile_flip_mutex);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2006-12-06 21:37:24 -07:00
|
|
|
void profile_hits(int type, void *__pc, unsigned int nr_hits)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
|
|
|
|
int i, j, cpu;
|
|
|
|
struct profile_hit *hits;
|
|
|
|
|
|
|
|
if (prof_on != type || !prof_buffer)
|
|
|
|
return;
|
|
|
|
pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
|
|
|
|
i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
|
|
|
|
secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
|
|
|
|
cpu = get_cpu();
|
|
|
|
hits = per_cpu(cpu_profile_hits, cpu)[per_cpu(cpu_profile_flip, cpu)];
|
|
|
|
if (!hits) {
|
|
|
|
put_cpu();
|
|
|
|
return;
|
|
|
|
}
|
2006-12-06 21:37:24 -07:00
|
|
|
/*
|
|
|
|
* We buffer the global profiler buffer into a per-CPU
|
|
|
|
* queue and thus reduce the number of global (and possibly
|
|
|
|
* NUMA-alien) accesses. The write-queue is self-coalescing:
|
|
|
|
*/
|
2005-04-16 15:20:36 -07:00
|
|
|
local_irq_save(flags);
|
|
|
|
do {
|
|
|
|
for (j = 0; j < PROFILE_GRPSZ; ++j) {
|
|
|
|
if (hits[i + j].pc == pc) {
|
2006-12-06 21:37:24 -07:00
|
|
|
hits[i + j].hits += nr_hits;
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
} else if (!hits[i + j].hits) {
|
|
|
|
hits[i + j].pc = pc;
|
2006-12-06 21:37:24 -07:00
|
|
|
hits[i + j].hits = nr_hits;
|
2005-04-16 15:20:36 -07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i = (i + secondary) & (NR_PROFILE_HIT - 1);
|
|
|
|
} while (i != primary);
|
2006-12-06 21:37:24 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the current hit(s) and flush the write-queue out
|
|
|
|
* to the global buffer:
|
|
|
|
*/
|
|
|
|
atomic_add(nr_hits, &prof_buffer[pc]);
|
2005-04-16 15:20:36 -07:00
|
|
|
for (i = 0; i < NR_PROFILE_HIT; ++i) {
|
|
|
|
atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
|
|
|
|
hits[i].pc = hits[i].hits = 0;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
local_irq_restore(flags);
|
|
|
|
put_cpu();
|
|
|
|
}
|
|
|
|
|
2006-06-27 02:54:07 -07:00
|
|
|
static int __devinit profile_cpu_callback(struct notifier_block *info,
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned long action, void *__cpu)
|
|
|
|
{
|
|
|
|
int node, cpu = (unsigned long)__cpu;
|
|
|
|
struct page *page;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case CPU_UP_PREPARE:
|
2007-05-09 02:35:10 -07:00
|
|
|
case CPU_UP_PREPARE_FROZEN:
|
2005-04-16 15:20:36 -07:00
|
|
|
node = cpu_to_node(cpu);
|
|
|
|
per_cpu(cpu_profile_flip, cpu) = 0;
|
|
|
|
if (!per_cpu(cpu_profile_hits, cpu)[1]) {
|
2006-09-25 23:31:45 -07:00
|
|
|
page = alloc_pages_node(node,
|
2007-10-16 01:25:34 -07:00
|
|
|
GFP_KERNEL | __GFP_ZERO,
|
2006-09-25 23:31:45 -07:00
|
|
|
0);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!page)
|
|
|
|
return NOTIFY_BAD;
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[1] = page_address(page);
|
|
|
|
}
|
|
|
|
if (!per_cpu(cpu_profile_hits, cpu)[0]) {
|
2006-09-25 23:31:45 -07:00
|
|
|
page = alloc_pages_node(node,
|
2007-10-16 01:25:34 -07:00
|
|
|
GFP_KERNEL | __GFP_ZERO,
|
2006-09-25 23:31:45 -07:00
|
|
|
0);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!page)
|
|
|
|
goto out_free;
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[0] = page_address(page);
|
|
|
|
}
|
|
|
|
break;
|
2008-01-25 13:08:33 -07:00
|
|
|
out_free:
|
2005-04-16 15:20:36 -07:00
|
|
|
page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[1] = NULL;
|
|
|
|
__free_page(page);
|
|
|
|
return NOTIFY_BAD;
|
|
|
|
case CPU_ONLINE:
|
2007-05-09 02:35:10 -07:00
|
|
|
case CPU_ONLINE_FROZEN:
|
2005-04-16 15:20:36 -07:00
|
|
|
cpu_set(cpu, prof_cpu_mask);
|
|
|
|
break;
|
|
|
|
case CPU_UP_CANCELED:
|
2007-05-09 02:35:10 -07:00
|
|
|
case CPU_UP_CANCELED_FROZEN:
|
2005-04-16 15:20:36 -07:00
|
|
|
case CPU_DEAD:
|
2007-05-09 02:35:10 -07:00
|
|
|
case CPU_DEAD_FROZEN:
|
2005-04-16 15:20:36 -07:00
|
|
|
cpu_clear(cpu, prof_cpu_mask);
|
|
|
|
if (per_cpu(cpu_profile_hits, cpu)[0]) {
|
|
|
|
page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[0]);
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[0] = NULL;
|
|
|
|
__free_page(page);
|
|
|
|
}
|
|
|
|
if (per_cpu(cpu_profile_hits, cpu)[1]) {
|
|
|
|
page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[1] = NULL;
|
|
|
|
__free_page(page);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NOTIFY_OK;
|
|
|
|
}
|
|
|
|
#else /* !CONFIG_SMP */
|
|
|
|
#define profile_flip_buffers() do { } while (0)
|
|
|
|
#define profile_discard_flip_buffers() do { } while (0)
|
2006-12-06 21:38:17 -07:00
|
|
|
#define profile_cpu_callback NULL
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-12-06 21:37:24 -07:00
|
|
|
void profile_hits(int type, void *__pc, unsigned int nr_hits)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
unsigned long pc;
|
|
|
|
|
|
|
|
if (prof_on != type || !prof_buffer)
|
|
|
|
return;
|
|
|
|
pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
|
2006-12-06 21:37:24 -07:00
|
|
|
atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
#endif /* !CONFIG_SMP */
|
2007-01-22 21:40:33 -07:00
|
|
|
EXPORT_SYMBOL_GPL(profile_hits);
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 06:55:46 -07:00
|
|
|
void profile_tick(int type)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 06:55:46 -07:00
|
|
|
struct pt_regs *regs = get_irq_regs();
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
if (type == CPU_PROFILING && timer_hook)
|
|
|
|
timer_hook(regs);
|
|
|
|
if (!user_mode(regs) && cpu_isset(smp_processor_id(), prof_cpu_mask))
|
|
|
|
profile_hit(type, (void *)profile_pc(regs));
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
|
2008-01-25 13:08:33 -07:00
|
|
|
static int prof_cpu_mask_read_proc(char *page, char **start, off_t off,
|
2005-04-16 15:20:36 -07:00
|
|
|
int count, int *eof, void *data)
|
|
|
|
{
|
|
|
|
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
|
|
|
|
if (count - len < 2)
|
|
|
|
return -EINVAL;
|
|
|
|
len += sprintf(page + len, "\n");
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2008-01-25 13:08:33 -07:00
|
|
|
static int prof_cpu_mask_write_proc(struct file *file,
|
|
|
|
const char __user *buffer, unsigned long count, void *data)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
cpumask_t *mask = (cpumask_t *)data;
|
|
|
|
unsigned long full_count = count, err;
|
|
|
|
cpumask_t new_value;
|
|
|
|
|
2006-10-11 01:21:55 -07:00
|
|
|
err = cpumask_parse_user(buffer, count, new_value);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
*mask = new_value;
|
|
|
|
return full_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *entry;
|
|
|
|
|
|
|
|
/* create /proc/irq/prof_cpu_mask */
|
2008-01-25 13:08:33 -07:00
|
|
|
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
|
|
|
|
if (!entry)
|
2005-04-16 15:20:36 -07:00
|
|
|
return;
|
|
|
|
entry->data = (void *)&prof_cpu_mask;
|
|
|
|
entry->read_proc = prof_cpu_mask_read_proc;
|
|
|
|
entry->write_proc = prof_cpu_mask_write_proc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function accesses profiling information. The returned data is
|
|
|
|
* binary: the sampling step and the actual contents of the profile
|
|
|
|
* buffer. Use of the program readprofile is recommended in order to
|
|
|
|
* get meaningful info out of these data.
|
|
|
|
*/
|
|
|
|
static ssize_t
|
|
|
|
read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
unsigned long p = *ppos;
|
|
|
|
ssize_t read;
|
2008-01-25 13:08:33 -07:00
|
|
|
char *pnt;
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned int sample_step = 1 << prof_shift;
|
|
|
|
|
|
|
|
profile_flip_buffers();
|
|
|
|
if (p >= (prof_len+1)*sizeof(unsigned int))
|
|
|
|
return 0;
|
|
|
|
if (count > (prof_len+1)*sizeof(unsigned int) - p)
|
|
|
|
count = (prof_len+1)*sizeof(unsigned int) - p;
|
|
|
|
read = 0;
|
|
|
|
|
|
|
|
while (p < sizeof(unsigned int) && count > 0) {
|
2008-01-25 13:08:33 -07:00
|
|
|
if (put_user(*((char *)(&sample_step)+p), buf))
|
2006-12-06 21:36:37 -07:00
|
|
|
return -EFAULT;
|
2005-04-16 15:20:36 -07:00
|
|
|
buf++; p++; count--; read++;
|
|
|
|
}
|
|
|
|
pnt = (char *)prof_buffer + p - sizeof(atomic_t);
|
2008-01-25 13:08:33 -07:00
|
|
|
if (copy_to_user(buf, (void *)pnt, count))
|
2005-04-16 15:20:36 -07:00
|
|
|
return -EFAULT;
|
|
|
|
read += count;
|
|
|
|
*ppos += read;
|
|
|
|
return read;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Writing to /proc/profile resets the counters
|
|
|
|
*
|
|
|
|
* Writing a 'profiling multiplier' value into it also re-sets the profiling
|
|
|
|
* interrupt frequency, on architectures that support this.
|
|
|
|
*/
|
|
|
|
static ssize_t write_profile(struct file *file, const char __user *buf,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
2008-01-25 13:08:33 -07:00
|
|
|
extern int setup_profiling_timer(unsigned int multiplier);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
if (count == sizeof(int)) {
|
|
|
|
unsigned int multiplier;
|
|
|
|
|
|
|
|
if (copy_from_user(&multiplier, buf, sizeof(int)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (setup_profiling_timer(multiplier))
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
profile_discard_flip_buffers();
|
|
|
|
memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2006-12-06 21:40:36 -07:00
|
|
|
static const struct file_operations proc_profile_operations = {
|
2005-04-16 15:20:36 -07:00
|
|
|
.read = read_profile,
|
|
|
|
.write = write_profile,
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
static void __init profile_nop(void *unused)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init create_hash_tables(void)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
int node = cpu_to_node(cpu);
|
|
|
|
struct page *page;
|
|
|
|
|
2006-09-25 23:31:45 -07:00
|
|
|
page = alloc_pages_node(node,
|
|
|
|
GFP_KERNEL | __GFP_ZERO | GFP_THISNODE,
|
|
|
|
0);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!page)
|
|
|
|
goto out_cleanup;
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[1]
|
|
|
|
= (struct profile_hit *)page_address(page);
|
2006-09-25 23:31:45 -07:00
|
|
|
page = alloc_pages_node(node,
|
|
|
|
GFP_KERNEL | __GFP_ZERO | GFP_THISNODE,
|
|
|
|
0);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!page)
|
|
|
|
goto out_cleanup;
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[0]
|
|
|
|
= (struct profile_hit *)page_address(page);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
out_cleanup:
|
|
|
|
prof_on = 0;
|
2005-05-01 08:58:47 -07:00
|
|
|
smp_mb();
|
2008-05-09 00:39:44 -07:00
|
|
|
on_each_cpu(profile_nop, NULL, 1);
|
2005-04-16 15:20:36 -07:00
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
struct page *page;
|
|
|
|
|
|
|
|
if (per_cpu(cpu_profile_hits, cpu)[0]) {
|
|
|
|
page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[0]);
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[0] = NULL;
|
|
|
|
__free_page(page);
|
|
|
|
}
|
|
|
|
if (per_cpu(cpu_profile_hits, cpu)[1]) {
|
|
|
|
page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
|
|
|
|
per_cpu(cpu_profile_hits, cpu)[1] = NULL;
|
|
|
|
__free_page(page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define create_hash_tables() ({ 0; })
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int __init create_proc_profile(void)
|
|
|
|
{
|
|
|
|
struct proc_dir_entry *entry;
|
|
|
|
|
|
|
|
if (!prof_on)
|
|
|
|
return 0;
|
|
|
|
if (create_hash_tables())
|
|
|
|
return -1;
|
2008-04-29 01:02:31 -07:00
|
|
|
entry = proc_create("profile", S_IWUSR | S_IRUGO,
|
|
|
|
NULL, &proc_profile_operations);
|
2008-01-25 13:08:33 -07:00
|
|
|
if (!entry)
|
2005-04-16 15:20:36 -07:00
|
|
|
return 0;
|
|
|
|
entry->size = (1+prof_len) * sizeof(atomic_t);
|
|
|
|
hotcpu_notifier(profile_cpu_callback, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
module_init(create_proc_profile);
|
|
|
|
#endif /* CONFIG_PROC_FS */
|