2008-05-13 03:20:56 +08:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Copyright (C) IBM Corporation, 2005
|
|
|
|
* Jeff Muizelaar, 2006, 2007
|
|
|
|
* Pekka Paalanen, 2008 <pq@iki.fi>
|
|
|
|
*
|
|
|
|
* Derived from the read-mod example from relay-examples by Tom Zanussi.
|
|
|
|
*/
|
2009-12-10 02:45:37 +08:00
|
|
|
|
2009-12-14 15:24:03 +08:00
|
|
|
#define pr_fmt(fmt) "mmiotrace: " fmt
|
2009-12-10 02:45:37 +08:00
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
#define DEBUG 1
|
|
|
|
|
2016-07-14 08:18:55 +08:00
|
|
|
#include <linux/moduleparam.h>
|
2008-05-13 03:20:56 +08:00
|
|
|
#include <linux/debugfs.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2008-05-13 03:20:57 +08:00
|
|
|
#include <linux/uaccess.h>
|
2008-05-13 03:21:03 +08:00
|
|
|
#include <linux/io.h>
|
2008-05-13 03:20:56 +08:00
|
|
|
#include <linux/kallsyms.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <linux/mmiotrace.h>
|
|
|
|
#include <asm/e820.h> /* for ISA_START_ADDRESS */
|
2011-07-27 07:09:06 +08:00
|
|
|
#include <linux/atomic.h>
|
2008-05-13 03:20:57 +08:00
|
|
|
#include <linux/percpu.h>
|
2008-05-13 03:21:02 +08:00
|
|
|
#include <linux/cpu.h>
|
2008-05-13 03:20:56 +08:00
|
|
|
|
|
|
|
#include "pf_in.h"
|
|
|
|
|
|
|
|
struct trap_reason {
|
|
|
|
unsigned long addr;
|
|
|
|
unsigned long ip;
|
|
|
|
enum reason_type type;
|
|
|
|
int active_traces;
|
|
|
|
};
|
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
struct remap_trace {
|
|
|
|
struct list_head list;
|
|
|
|
struct kmmio_probe probe;
|
2008-05-13 03:21:03 +08:00
|
|
|
resource_size_t phys;
|
2008-05-13 03:20:57 +08:00
|
|
|
unsigned long id;
|
|
|
|
};
|
|
|
|
|
2008-05-13 03:20:56 +08:00
|
|
|
/* Accessed per-cpu. */
|
2008-05-13 03:20:57 +08:00
|
|
|
static DEFINE_PER_CPU(struct trap_reason, pf_reason);
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
static DEFINE_PER_CPU(struct mmiotrace_rw, cpu_trace);
|
2008-05-13 03:20:56 +08:00
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
static DEFINE_MUTEX(mmiotrace_mutex);
|
|
|
|
static DEFINE_SPINLOCK(trace_lock);
|
|
|
|
static atomic_t mmiotrace_enabled;
|
|
|
|
static LIST_HEAD(trace_list); /* struct remap_trace */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locking in this file:
|
|
|
|
* - mmiotrace_mutex enforces enable/disable_mmiotrace() critical sections.
|
|
|
|
* - mmiotrace_enabled may be modified only when holding mmiotrace_mutex
|
|
|
|
* and trace_lock.
|
|
|
|
* - Routines depending on is_enabled() must take trace_lock.
|
|
|
|
* - trace_list users must hold trace_lock.
|
2008-09-17 03:00:34 +08:00
|
|
|
* - is_enabled() guarantees that mmio_trace_{rw,mapping} are allowed.
|
2008-05-13 03:20:57 +08:00
|
|
|
* - pre/post callbacks assume the effect of is_enabled() being true.
|
|
|
|
*/
|
2008-05-13 03:20:56 +08:00
|
|
|
|
|
|
|
/* module parameters */
|
2008-05-13 03:20:57 +08:00
|
|
|
static unsigned long filter_offset;
|
2012-01-13 07:02:18 +08:00
|
|
|
static bool nommiotrace;
|
|
|
|
static bool trace_pc;
|
2008-05-13 03:20:56 +08:00
|
|
|
|
|
|
|
module_param(filter_offset, ulong, 0);
|
|
|
|
module_param(nommiotrace, bool, 0);
|
|
|
|
module_param(trace_pc, bool, 0);
|
|
|
|
|
|
|
|
MODULE_PARM_DESC(filter_offset, "Start address of traced mappings.");
|
|
|
|
MODULE_PARM_DESC(nommiotrace, "Disable actual MMIO tracing.");
|
|
|
|
MODULE_PARM_DESC(trace_pc, "Record address of faulting instructions.");
|
2008-05-13 03:20:57 +08:00
|
|
|
|
|
|
|
static bool is_enabled(void)
|
|
|
|
{
|
|
|
|
return atomic_read(&mmiotrace_enabled);
|
|
|
|
}
|
2008-05-13 03:20:56 +08:00
|
|
|
|
|
|
|
static void print_pte(unsigned long address)
|
|
|
|
{
|
2008-05-13 03:21:14 +08:00
|
|
|
unsigned int level;
|
2008-05-13 03:20:56 +08:00
|
|
|
pte_t *pte = lookup_address(address, &level);
|
|
|
|
|
|
|
|
if (!pte) {
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_err("Error in %s: no pte for page 0x%08lx\n",
|
|
|
|
__func__, address);
|
2008-05-13 03:20:56 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level == PG_LEVEL_2M) {
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_emerg("4MB pages are not currently supported: 0x%08lx\n",
|
|
|
|
address);
|
2008-05-13 03:20:56 +08:00
|
|
|
BUG();
|
|
|
|
}
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_info("pte for 0x%lx: 0x%llx 0x%llx\n",
|
|
|
|
address,
|
2008-05-13 03:20:59 +08:00
|
|
|
(unsigned long long)pte_val(*pte),
|
|
|
|
(unsigned long long)pte_val(*pte) & _PAGE_PRESENT);
|
2008-05-13 03:20:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For some reason the pre/post pairs have been called in an
|
|
|
|
* unmatched order. Report and die.
|
|
|
|
*/
|
|
|
|
static void die_kmmio_nesting_error(struct pt_regs *regs, unsigned long addr)
|
|
|
|
{
|
2008-05-13 03:20:57 +08:00
|
|
|
const struct trap_reason *my_reason = &get_cpu_var(pf_reason);
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_emerg("unexpected fault for address: 0x%08lx, last fault for address: 0x%08lx\n",
|
|
|
|
addr, my_reason->addr);
|
2008-05-13 03:20:56 +08:00
|
|
|
print_pte(addr);
|
2008-05-13 03:20:57 +08:00
|
|
|
print_symbol(KERN_EMERG "faulting IP is at %s\n", regs->ip);
|
|
|
|
print_symbol(KERN_EMERG "last faulting IP was at %s\n", my_reason->ip);
|
2008-05-13 03:20:56 +08:00
|
|
|
#ifdef __i386__
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
pr_emerg("eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n",
|
2009-12-10 02:45:37 +08:00
|
|
|
regs->ax, regs->bx, regs->cx, regs->dx);
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
pr_emerg("esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n",
|
2009-12-10 02:45:37 +08:00
|
|
|
regs->si, regs->di, regs->bp, regs->sp);
|
2008-05-13 03:20:56 +08:00
|
|
|
#else
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
pr_emerg("rax: %016lx rcx: %016lx rdx: %016lx\n",
|
2009-12-10 02:45:37 +08:00
|
|
|
regs->ax, regs->cx, regs->dx);
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
pr_emerg("rsi: %016lx rdi: %016lx rbp: %016lx rsp: %016lx\n",
|
2009-12-10 02:45:37 +08:00
|
|
|
regs->si, regs->di, regs->bp, regs->sp);
|
2008-05-13 03:20:56 +08:00
|
|
|
#endif
|
2008-05-13 03:20:57 +08:00
|
|
|
put_cpu_var(pf_reason);
|
2008-05-13 03:20:56 +08:00
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pre(struct kmmio_probe *p, struct pt_regs *regs,
|
|
|
|
unsigned long addr)
|
|
|
|
{
|
2008-05-13 03:20:57 +08:00
|
|
|
struct trap_reason *my_reason = &get_cpu_var(pf_reason);
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
struct mmiotrace_rw *my_trace = &get_cpu_var(cpu_trace);
|
2008-05-13 03:20:56 +08:00
|
|
|
const unsigned long instptr = instruction_pointer(regs);
|
|
|
|
const enum reason_type type = get_ins_type(instptr);
|
2008-05-13 03:21:03 +08:00
|
|
|
struct remap_trace *trace = p->private;
|
2008-05-13 03:20:56 +08:00
|
|
|
|
|
|
|
/* it doesn't make sense to have more than one active trace per cpu */
|
2008-05-13 03:20:57 +08:00
|
|
|
if (my_reason->active_traces)
|
2008-05-13 03:20:56 +08:00
|
|
|
die_kmmio_nesting_error(regs, addr);
|
|
|
|
else
|
2008-05-13 03:20:57 +08:00
|
|
|
my_reason->active_traces++;
|
2008-05-13 03:20:56 +08:00
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
my_reason->type = type;
|
|
|
|
my_reason->addr = addr;
|
|
|
|
my_reason->ip = instptr;
|
2008-05-13 03:20:56 +08:00
|
|
|
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
my_trace->phys = addr - trace->probe.addr + trace->phys;
|
|
|
|
my_trace->map_id = trace->id;
|
2008-05-13 03:20:56 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Only record the program counter when requested.
|
|
|
|
* It may taint clean-room reverse engineering.
|
|
|
|
*/
|
|
|
|
if (trace_pc)
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
my_trace->pc = instptr;
|
2008-05-13 03:20:56 +08:00
|
|
|
else
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
my_trace->pc = 0;
|
2008-05-13 03:20:56 +08:00
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
/*
|
|
|
|
* XXX: the timestamp recorded will be *after* the tracing has been
|
|
|
|
* done, not at the time we hit the instruction. SMP implications
|
|
|
|
* on event ordering?
|
|
|
|
*/
|
2008-05-13 03:20:56 +08:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case REG_READ:
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
my_trace->opcode = MMIO_READ;
|
|
|
|
my_trace->width = get_ins_mem_width(instptr);
|
2008-05-13 03:20:56 +08:00
|
|
|
break;
|
|
|
|
case REG_WRITE:
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
my_trace->opcode = MMIO_WRITE;
|
|
|
|
my_trace->width = get_ins_mem_width(instptr);
|
|
|
|
my_trace->value = get_ins_reg_val(instptr, regs);
|
2008-05-13 03:20:56 +08:00
|
|
|
break;
|
|
|
|
case IMM_WRITE:
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
my_trace->opcode = MMIO_WRITE;
|
|
|
|
my_trace->width = get_ins_mem_width(instptr);
|
|
|
|
my_trace->value = get_ins_imm_val(instptr);
|
2008-05-13 03:20:56 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
unsigned char *ip = (unsigned char *)instptr;
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
my_trace->opcode = MMIO_UNKNOWN_OP;
|
|
|
|
my_trace->width = 0;
|
|
|
|
my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
|
2008-05-13 03:20:57 +08:00
|
|
|
*(ip + 2);
|
2008-05-13 03:20:56 +08:00
|
|
|
}
|
|
|
|
}
|
2008-05-13 03:20:57 +08:00
|
|
|
put_cpu_var(cpu_trace);
|
|
|
|
put_cpu_var(pf_reason);
|
2008-05-13 03:20:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void post(struct kmmio_probe *p, unsigned long condition,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
2008-05-13 03:20:57 +08:00
|
|
|
struct trap_reason *my_reason = &get_cpu_var(pf_reason);
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
struct mmiotrace_rw *my_trace = &get_cpu_var(cpu_trace);
|
2008-05-13 03:20:56 +08:00
|
|
|
|
|
|
|
/* this should always return the active_trace count to 0 */
|
2008-05-13 03:20:57 +08:00
|
|
|
my_reason->active_traces--;
|
|
|
|
if (my_reason->active_traces) {
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_emerg("unexpected post handler");
|
2008-05-13 03:20:56 +08:00
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
switch (my_reason->type) {
|
2008-05-13 03:20:56 +08:00
|
|
|
case REG_READ:
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
my_trace->value = get_ins_reg_val(my_reason->ip, regs);
|
2008-05-13 03:20:56 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-13 03:20:57 +08:00
|
|
|
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
mmio_trace_rw(my_trace);
|
2008-05-13 03:20:57 +08:00
|
|
|
put_cpu_var(cpu_trace);
|
|
|
|
put_cpu_var(pf_reason);
|
2008-05-13 03:20:56 +08:00
|
|
|
}
|
|
|
|
|
2008-05-13 03:21:03 +08:00
|
|
|
static void ioremap_trace_core(resource_size_t offset, unsigned long size,
|
2008-05-13 03:20:56 +08:00
|
|
|
void __iomem *addr)
|
|
|
|
{
|
2008-05-13 03:20:57 +08:00
|
|
|
static atomic_t next_id;
|
2008-05-13 03:20:56 +08:00
|
|
|
struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
|
2008-05-13 03:21:03 +08:00
|
|
|
/* These are page-unaligned. */
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
struct mmiotrace_map map = {
|
|
|
|
.phys = offset,
|
|
|
|
.virt = (unsigned long)addr,
|
|
|
|
.len = size,
|
|
|
|
.opcode = MMIO_PROBE
|
2008-05-13 03:20:56 +08:00
|
|
|
};
|
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
if (!trace) {
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_err("kmalloc failed in ioremap\n");
|
2008-05-13 03:20:57 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:20:56 +08:00
|
|
|
*trace = (struct remap_trace) {
|
|
|
|
.probe = {
|
|
|
|
.addr = (unsigned long)addr,
|
|
|
|
.len = size,
|
|
|
|
.pre_handler = pre,
|
|
|
|
.post_handler = post,
|
2008-05-13 03:21:03 +08:00
|
|
|
.private = trace
|
2008-05-13 03:20:57 +08:00
|
|
|
},
|
|
|
|
.phys = offset,
|
|
|
|
.id = atomic_inc_return(&next_id)
|
2008-05-13 03:20:56 +08:00
|
|
|
};
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
map.map_id = trace->id;
|
2008-05-13 03:20:56 +08:00
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
spin_lock_irq(&trace_lock);
|
2008-09-17 02:54:16 +08:00
|
|
|
if (!is_enabled()) {
|
|
|
|
kfree(trace);
|
2008-05-13 03:20:57 +08:00
|
|
|
goto not_enabled;
|
2008-09-17 02:54:16 +08:00
|
|
|
}
|
2008-05-13 03:20:57 +08:00
|
|
|
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
mmio_trace_mapping(&map);
|
2008-05-13 03:20:56 +08:00
|
|
|
list_add_tail(&trace->list, &trace_list);
|
|
|
|
if (!nommiotrace)
|
|
|
|
register_kmmio_probe(&trace->probe);
|
2008-05-13 03:20:57 +08:00
|
|
|
|
|
|
|
not_enabled:
|
|
|
|
spin_unlock_irq(&trace_lock);
|
2008-05-13 03:20:56 +08:00
|
|
|
}
|
|
|
|
|
2008-05-13 03:21:03 +08:00
|
|
|
void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
|
|
|
|
void __iomem *addr)
|
2008-05-13 03:20:56 +08:00
|
|
|
{
|
2008-05-13 03:20:57 +08:00
|
|
|
if (!is_enabled()) /* recheck and proper locking in *_core() */
|
2008-05-13 03:20:56 +08:00
|
|
|
return;
|
|
|
|
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_debug("ioremap_*(0x%llx, 0x%lx) = %p\n",
|
|
|
|
(unsigned long long)offset, size, addr);
|
2008-05-13 03:20:57 +08:00
|
|
|
if ((filter_offset) && (offset != filter_offset))
|
2008-05-13 03:20:56 +08:00
|
|
|
return;
|
2008-05-13 03:20:57 +08:00
|
|
|
ioremap_trace_core(offset, size, addr);
|
2008-05-13 03:20:56 +08:00
|
|
|
}
|
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
static void iounmap_trace_core(volatile void __iomem *addr)
|
2008-05-13 03:20:56 +08:00
|
|
|
{
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
struct mmiotrace_map map = {
|
|
|
|
.phys = 0,
|
|
|
|
.virt = (unsigned long)addr,
|
|
|
|
.len = 0,
|
|
|
|
.opcode = MMIO_UNPROBE
|
2008-05-13 03:20:56 +08:00
|
|
|
};
|
|
|
|
struct remap_trace *trace;
|
|
|
|
struct remap_trace *tmp;
|
2008-05-13 03:20:57 +08:00
|
|
|
struct remap_trace *found_trace = NULL;
|
|
|
|
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_debug("Unmapping %p.\n", addr);
|
2008-05-13 03:20:56 +08:00
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
spin_lock_irq(&trace_lock);
|
|
|
|
if (!is_enabled())
|
|
|
|
goto not_enabled;
|
|
|
|
|
2008-05-13 03:20:56 +08:00
|
|
|
list_for_each_entry_safe(trace, tmp, &trace_list, list) {
|
|
|
|
if ((unsigned long)addr == trace->probe.addr) {
|
|
|
|
if (!nommiotrace)
|
|
|
|
unregister_kmmio_probe(&trace->probe);
|
|
|
|
list_del(&trace->list);
|
2008-05-13 03:20:57 +08:00
|
|
|
found_trace = trace;
|
2008-05-13 03:20:56 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-13 03:20:57 +08:00
|
|
|
map.map_id = (found_trace) ? found_trace->id : -1;
|
|
|
|
mmio_trace_mapping(&map);
|
2008-05-13 03:20:57 +08:00
|
|
|
|
|
|
|
not_enabled:
|
|
|
|
spin_unlock_irq(&trace_lock);
|
|
|
|
if (found_trace) {
|
|
|
|
synchronize_rcu(); /* unregister_kmmio_probe() requirement */
|
|
|
|
kfree(found_trace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmiotrace_iounmap(volatile void __iomem *addr)
|
|
|
|
{
|
|
|
|
might_sleep();
|
|
|
|
if (is_enabled()) /* recheck and proper locking in *_core() */
|
|
|
|
iounmap_trace_core(addr);
|
2008-05-13 03:20:56 +08:00
|
|
|
}
|
|
|
|
|
2008-09-17 03:00:34 +08:00
|
|
|
int mmiotrace_printk(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
va_list args;
|
|
|
|
unsigned long flags;
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&trace_lock, flags);
|
|
|
|
if (is_enabled())
|
|
|
|
ret = mmio_trace_printk(fmt, args);
|
|
|
|
spin_unlock_irqrestore(&trace_lock, flags);
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mmiotrace_printk);
|
|
|
|
|
2008-05-13 03:20:56 +08:00
|
|
|
static void clear_trace_list(void)
|
|
|
|
{
|
|
|
|
struct remap_trace *trace;
|
|
|
|
struct remap_trace *tmp;
|
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
/*
|
|
|
|
* No locking required, because the caller ensures we are in a
|
|
|
|
* critical section via mutex, and is_enabled() is false,
|
|
|
|
* i.e. nothing can traverse or modify this list.
|
|
|
|
* Caller also ensures is_enabled() cannot change.
|
|
|
|
*/
|
|
|
|
list_for_each_entry(trace, &trace_list, list) {
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_notice("purging non-iounmapped trace @0x%08lx, size 0x%lx.\n",
|
|
|
|
trace->probe.addr, trace->probe.len);
|
2008-05-13 03:20:56 +08:00
|
|
|
if (!nommiotrace)
|
|
|
|
unregister_kmmio_probe(&trace->probe);
|
2008-05-13 03:20:57 +08:00
|
|
|
}
|
|
|
|
synchronize_rcu(); /* unregister_kmmio_probe() requirement */
|
|
|
|
|
|
|
|
list_for_each_entry_safe(trace, tmp, &trace_list, list) {
|
2008-05-13 03:20:56 +08:00
|
|
|
list_del(&trace->list);
|
|
|
|
kfree(trace);
|
2008-05-13 03:20:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:21:02 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2009-03-11 14:03:55 +08:00
|
|
|
static cpumask_var_t downed_cpus;
|
2008-05-13 03:21:02 +08:00
|
|
|
|
|
|
|
static void enter_uniprocessor(void)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
int err;
|
|
|
|
|
2009-03-11 14:03:55 +08:00
|
|
|
if (downed_cpus == NULL &&
|
|
|
|
!alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_notice("Failed to allocate mask\n");
|
2009-03-11 14:03:55 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:21:02 +08:00
|
|
|
get_online_cpus();
|
2009-03-11 14:03:55 +08:00
|
|
|
cpumask_copy(downed_cpus, cpu_online_mask);
|
|
|
|
cpumask_clear_cpu(cpumask_first(cpu_online_mask), downed_cpus);
|
2008-05-13 03:21:02 +08:00
|
|
|
if (num_online_cpus() > 1)
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_notice("Disabling non-boot CPUs...\n");
|
2008-05-13 03:21:02 +08:00
|
|
|
put_online_cpus();
|
|
|
|
|
2009-03-11 14:03:55 +08:00
|
|
|
for_each_cpu(cpu, downed_cpus) {
|
2008-05-13 03:21:02 +08:00
|
|
|
err = cpu_down(cpu);
|
2008-05-13 03:21:03 +08:00
|
|
|
if (!err)
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_info("CPU%d is down.\n", cpu);
|
2008-05-13 03:21:03 +08:00
|
|
|
else
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_err("Error taking CPU%d down: %d\n", cpu, err);
|
2008-05-13 03:21:02 +08:00
|
|
|
}
|
2009-03-11 14:03:55 +08:00
|
|
|
out:
|
2008-05-13 03:21:02 +08:00
|
|
|
if (num_online_cpus() > 1)
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_warning("multiple CPUs still online, may miss events.\n");
|
2008-05-13 03:21:02 +08:00
|
|
|
}
|
|
|
|
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 06:23:59 +08:00
|
|
|
static void leave_uniprocessor(void)
|
2008-05-13 03:21:02 +08:00
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
int err;
|
|
|
|
|
2009-03-11 14:03:55 +08:00
|
|
|
if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
|
2008-05-13 03:21:02 +08:00
|
|
|
return;
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_notice("Re-enabling CPUs...\n");
|
2009-03-11 14:03:55 +08:00
|
|
|
for_each_cpu(cpu, downed_cpus) {
|
2008-05-13 03:21:02 +08:00
|
|
|
err = cpu_up(cpu);
|
|
|
|
if (!err)
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_info("enabled CPU%d.\n", cpu);
|
2008-05-13 03:21:02 +08:00
|
|
|
else
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_err("cannot re-enable CPU%d: %d\n", cpu, err);
|
2008-05-13 03:21:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* !CONFIG_HOTPLUG_CPU */
|
|
|
|
static void enter_uniprocessor(void)
|
|
|
|
{
|
|
|
|
if (num_online_cpus() > 1)
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_warning("multiple CPUs are online, may miss events. "
|
|
|
|
"Suggest booting with maxcpus=1 kernel argument.\n");
|
2008-05-13 03:21:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void leave_uniprocessor(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
void enable_mmiotrace(void)
|
2008-05-13 03:20:57 +08:00
|
|
|
{
|
|
|
|
mutex_lock(&mmiotrace_mutex);
|
|
|
|
if (is_enabled())
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (nommiotrace)
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_info("MMIO tracing disabled.\n");
|
2009-04-29 03:17:51 +08:00
|
|
|
kmmio_init();
|
2008-05-13 03:21:02 +08:00
|
|
|
enter_uniprocessor();
|
2008-05-13 03:20:57 +08:00
|
|
|
spin_lock_irq(&trace_lock);
|
|
|
|
atomic_inc(&mmiotrace_enabled);
|
|
|
|
spin_unlock_irq(&trace_lock);
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_info("enabled.\n");
|
2008-05-13 03:20:57 +08:00
|
|
|
out:
|
|
|
|
mutex_unlock(&mmiotrace_mutex);
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:20:57 +08:00
|
|
|
void disable_mmiotrace(void)
|
2008-05-13 03:20:57 +08:00
|
|
|
{
|
|
|
|
mutex_lock(&mmiotrace_mutex);
|
|
|
|
if (!is_enabled())
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
spin_lock_irq(&trace_lock);
|
|
|
|
atomic_dec(&mmiotrace_enabled);
|
|
|
|
BUG_ON(is_enabled());
|
|
|
|
spin_unlock_irq(&trace_lock);
|
|
|
|
|
|
|
|
clear_trace_list(); /* guarantees: no more kmmio callbacks */
|
2008-05-13 03:21:02 +08:00
|
|
|
leave_uniprocessor();
|
2009-04-29 03:17:51 +08:00
|
|
|
kmmio_cleanup();
|
2009-12-10 02:45:37 +08:00
|
|
|
pr_info("disabled.\n");
|
2008-05-13 03:20:57 +08:00
|
|
|
out:
|
|
|
|
mutex_unlock(&mmiotrace_mutex);
|
2008-05-13 03:20:56 +08:00
|
|
|
}
|