1. 13 4月, 2010 3 次提交
  2. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      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: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  3. 13 3月, 2010 4 次提交
    • C
      mips: use generic ptrace_resume code · 55436c91
      Christoph Hellwig 提交于
      Use the generic ptrace_resume code for PTRACE_SYSCALL, PTRACE_CONT and
      PTRACE_KILL.
      
      Also the TIF_SYSCALL_TRACE thread flag is now cleared on PTRACE_KILL which
      it previously wasn't which is consistent with all architectures using the
      modern ptrace code.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Roland McGrath <roland@redhat.com>
      Acked-by: NRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      55436c91
    • C
      Add generic sys_olduname() · 5cacdb4a
      Christoph Hellwig 提交于
      Add generic implementations of the old and really old uname system calls.
      Note that sh only implements sys_olduname but not sys_oldolduname, but I'm
      not going to bother with another ifdef for that special case.
      
      m32r implemented an old uname but never wired it up, so kill it, too.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Hirokazu Takata <takata@linux-m32r.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Andreas Schwab <schwab@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5cacdb4a
    • C
      improve sys_newuname() for compat architectures · e28cbf22
      Christoph Hellwig 提交于
      On an architecture that supports 32-bit compat we need to override the
      reported machine in uname with the 32-bit value.  Instead of doing this
      separately in every architecture introduce a COMPAT_UTS_MACHINE define in
      <asm/compat.h> and apply it directly in sys_newuname().
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Hirokazu Takata <takata@linux-m32r.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Andreas Schwab <schwab@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e28cbf22
    • C
      Add generic sys_ipc wrapper · baed7fc9
      Christoph Hellwig 提交于
      Add a generic implementation of the ipc demultiplexer syscall.  Except for
      s390 and sparc64 all implementations of the sys_ipc are nearly identical.
      
      There are slight differences in the types of the parameters, where mips
      and powerpc as the only 64-bit architectures with sys_ipc use unsigned
      long for the "third" argument as it gets casted to a pointer later, while
      it traditionally is an "int" like most other paramters.  frv goes even
      further and uses unsigned long for all parameters execept for "ptr" which
      is a pointer type everywhere.  The change from int to unsigned long for
      "third" and back to "int" for the others on frv should be fine due to the
      in-register calling conventions for syscalls (we already had a similar
      issue with the generic sys_ptrace), but I'd prefer to have the arch
      maintainers looks over this in details.
      
      Except for that h8300, m68k and m68knommu lack an impplementation of the
      semtimedop sub call which this patch adds, and various architectures have
      gets used - at least on i386 it seems superflous as the compat code on
      x86-64 and ia64 doesn't even bother to implement it.
      
      [akpm@linux-foundation.org: add sys_ipc to sys_ni.c]
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Hirokazu Takata <takata@linux-m32r.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Reviewed-by: NH. Peter Anvin <hpa@zytor.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Andreas Schwab <schwab@linux-m68k.org>
      Acked-by: NJesper Nilsson <jesper.nilsson@axis.com>
      Acked-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NKyle McMartin <kyle@mcmartin.ca>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      baed7fc9
  4. 27 2月, 2010 15 次提交
  5. 11 2月, 2010 2 次提交
  6. 03 2月, 2010 1 次提交
  7. 28 1月, 2010 1 次提交
    • D
      MIPS: PowerTV: Fix support for timer interrupts with > 64 external IRQs · 010c108d
      David VomLehn 提交于
      The MIPS processor is limited to 64 external interrupt sources. Using a
      greater number without IRQ sharing requires reading platform-specific
      registers. On such platforms, reading the IntCtl register to determine
      which interrupt corresponds to a timer interrupt will not work.
      
      On MIPSR2 systems there is a solution - the TI bit in the Cause register,
      specifically indicates that a timer interrupt has occured. This patch uses
      that bit to detect interrupts for MIPSR2 processors, which may be expected
      to work regardless of how the timer interrupt may be routed in the hardware.
      
      Signed-off-by: David VomLehn (dvomlehn@cisco.com)
      To: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/804/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      010c108d
  8. 17 12月, 2009 13 次提交
    • R
      cf72e947
    • D
      MIPS: Fix and enhance built-in kernel command line · 6acc7d48
      Dmitri Vorobiev 提交于
      Currently, MIPS kernels silently overwrite kernel command-line parameters
      hardcoded in CONFIG_CMDLINE by the ones received from firmware.  Therefore,
      using firmware remains the only reliable method to transfer the
      command-line parameters, which is not always desirable or convenient, and
      the CONFIG_CMDLINE option is thereby effectively rendered useless.
      
      This patch fixes the problem described above and introduces a more flexible
      scheme of handling the kernel command line, in a manner identical to what is
      currently used for x86.  The default behavior, i.e. when CONFIG_CMDLINE_BOOL
      is not defined, retains the existing semantics, and firmware command-line
      arguments override the hardcoded ones.
      
      [Ralf: I fixed up all the defconfig files so the stay unaffected by this
      change.]
      Signed-off-by: NDmitri Vorobiev <dmitri.vorobiev@movial.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/689/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      6acc7d48
    • R
      MIPS: Cleanup signal code initialization · 137f6f3e
      Ralf Baechle 提交于
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/709/
      137f6f3e
    • R
      MIPS: Modularize COP2 handling · 69f3a7de
      Ralf Baechle 提交于
      Away with the daemons of ifdef; get ready for future COP2 users.
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      Patchwork: http://patchwork.linux-mips.org/patch/708/
      69f3a7de
    • W
      MIPS: Tracing: Make function graph tracer work with -mmcount-ra-address · 7326c4e5
      Wu Zhangjin 提交于
      That thread "MIPS: Add option to pass return address location to
      _mcount" from "David Daney <ddaney@caviumnetworks.com>" have added a new
      option -mmcount-ra-address to gcc(4.5) for MIPS to transfer the location
      of the return address to _mcount.
      
      Benefit from this new feature, function graph tracer on MIPS will be
      easier and safer to hijack the return address of the kernel function,
      which will save some overhead and make the whole thing more reliable.
      
      In this patch, at first, try to enable the option -mmcount-ra-address in
      arch/mips/Makefile with cc-option, if gcc support it, it will be
      enabled, otherwise, no side effect.
      
      and then, we need to support this new option of gcc 4.5 and also support
      the old gcc versions.
      
      with _mcount in the old gcc versions, it's not easy to get the location
      of return address(tracing: add function graph tracer support for MIPS),
         so, we do it in a C function: ftrace_get_parent_addr(ftrace.c), but
         with -mmcount-ra-address, only several instructions need to get what
         we want, so, I put into asm(mcount.S). and also, as the $12(t0) is
         used by -mmcount-ra-address for transferring the localtion of return
         address to _mcount, we need to save it into the stack and restore it
         when enabled dynamic function tracer, 'Cause we have called
         "ftrace_call" before "ftrace_graph_caller", which may destroy
         $12(t0).
      
      (Thanks to David for providing that -mcount-ra-address and giving the
       idea of KBUILD_MCOUNT_RA_ADDRESS, both of them have made the whole
       thing more beautiful!)
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/681/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      7326c4e5
    • W
      MIPS: Tracing: Reserve $12(t0) for mcount-ra-address of gcc 4.5 · fc49a3be
      Wu Zhangjin 提交于
      A new option -mmcount-ra-address for gcc 4.5 have been sent by David
      Daney <ddaney@caviumnetworks.com> in the thread "MIPS: Add option to
      pass return address location to _mcount", which help to record the
      location of the return address(ra) for the function graph tracer of MIPS
      to hijack the return address easier and safer. that option used the
      $12(t0) register by default, so, we reserve it for it, and use t1,t2,t3
      instead of t0,t1,t2.
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/680/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      fc49a3be
    • W
      MIPS: Tracing: Make ftrace for MIPS work without -fno-omit-frame-pointer · 046199ca
      Wu Zhangjin 提交于
      When remove the -fno-omit-frame-pointer, gcc will not save the frame
      pointer for us, we need to save one ourselves.
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/679/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      046199ca
    • W
      MIPS: Tracing: Add dynamic function graph tracer for MIPS · e17ff5fe
      Wu Zhangjin 提交于
      This patch make function graph tracer work with dynamic function tracer.
      
      To share the source code of dynamic function tracer(MCOUNT_SAVE_REGS),
      and avoid restoring the whole saved registers, we need to restore the ra
      register from the stack.
      
      (NOTE: This not work with 32bit! need to ensure why!)
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/678/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      e17ff5fe
    • W
      MIPS: Tracing: Add function graph tracer support for MIPS · 29c5d346
      Wu Zhangjin 提交于
      The implementation of function graph tracer for MIPS is a little
      different from X86.
      
      in MIPS, gcc(with -pg) only transfer the caller's return address(at) and
      the _mcount's return address(ra) to us.
      
      For the kernel part without -mlong-calls:
      
      move at, ra
      jal _mcount
      
      For the module part with -mlong-calls:
      
      lui v1, hi16bit_of_mcount
      addiu v1, v1, low16bit_of_mcount
      move at, ra
      jal _mcount
      
      Without -mlong-calls,
      
      if the function is a leaf, it will not save the return address(ra):
      
      ffffffff80101298 <au1k_wait>:
      ffffffff80101298:       67bdfff0        daddiu  sp,sp,-16
      ffffffff8010129c:       ffbe0008        sd      s8,8(sp)
      ffffffff801012a0:       03a0f02d        move    s8,sp
      ffffffff801012a4:       03e0082d        move    at,ra
      ffffffff801012a8:       0c042930        jal     ffffffff8010a4c0 <_mcount>
      ffffffff801012ac:       00020021        nop
      
      so, we can hijack it directly in _mcount, but if the function is non-leaf, the
      return address is saved in the stack.
      
      ffffffff80133030 <copy_process>:
      ffffffff80133030:       67bdff50        daddiu  sp,sp,-176
      ffffffff80133034:       ffbe00a0        sd      s8,160(sp)
      ffffffff80133038:       03a0f02d        move    s8,sp
      ffffffff8013303c:       ffbf00a8        sd      ra,168(sp)
      ffffffff80133040:       ffb70098        sd      s7,152(sp)
      ffffffff80133044:       ffb60090        sd      s6,144(sp)
      ffffffff80133048:       ffb50088        sd      s5,136(sp)
      ffffffff8013304c:       ffb40080        sd      s4,128(sp)
      ffffffff80133050:       ffb30078        sd      s3,120(sp)
      ffffffff80133054:       ffb20070        sd      s2,112(sp)
      ffffffff80133058:       ffb10068        sd      s1,104(sp)
      ffffffff8013305c:       ffb00060        sd      s0,96(sp)
      ffffffff80133060:       03e0082d        move    at,ra
      ffffffff80133064:       0c042930        jal     ffffffff8010a4c0 <_mcount>
      ffffffff80133068:       00020021        nop
      
      but we can not get the exact stack address(which saved ra) directly in
      _mcount, we need to search the content of at register in the stack space
      or search the "s{d,w} ra, offset(sp)" instruction in the text. 'Cause we
      can not prove there is only a match in the stack space, so, we search
      the text instead.
      
      as we can see, if the first instruction above "move at, ra" is not a
      store instruction, there should be a leaf function, so we hijack the at
      register directly via putting &return_to_handler into it, otherwise, we
      search the "s{d,w} ra, offset(sp)" instruction to get the stack offset,
      and then the stack address. we use the above copy_process() as an
      example, we at last find "ffbf00a8", 0xa8 is the stack offset, we plus
      it with s8(fp), that is the stack address, we hijack the content via
      writing the &return_to_handler in.
      
      If with -mlong-calls, since there are two more instructions above "move
      at, ra", so, we can move the pointer to the position above "lui v1,
      hi16bit_of_mcount".
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/677/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      29c5d346
    • W
      MIPS: Tracing: Add IRQENTRY_EXIT section for MIPS · 8f99a162
      Wu Zhangjin 提交于
      This patch add a new section for MIPS to record the block of the hardirq
      handling for function graph tracer(print_graph_irq) via adding the
      __irq_entry annotation to the the entrypoints of the hardirqs(the block
      with irq_enter()...irq_exit()).
      
      Thanks goes to Steven & Frederic Weisbecker for their feedbacks.
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Reviewed-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Patchwork: http://patchwork.linux-mips.org/patch/676/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      8f99a162
    • W
      MIPS: Tracing: Add dynamic function tracer support · 538f1952
      Wu Zhangjin 提交于
      With dynamic function tracer, by default, _mcount is defined as an
      "empty" function, it returns directly without any more action . When
      enabling it in user-space, it will jump to a real tracing
      function(ftrace_caller), and do the real job for us.
      
      Differ from the static function tracer, dynamic function tracer provides
      two functions ftrace_make_call()/ftrace_make_nop() to enable/disable the
      tracing of some indicated kernel functions(set_ftrace_filter).
      
      In the -v4 version, the implementation of this support is basically the same as
      X86 version does: _mcount is implemented as an empty function and ftrace_caller
      is implemented as a real tracing function respectively.
      
      But in this version, to support module tracing with the help of
      -mlong-calls in arch/mips/Makefile:
      
      MODFLAGS += -mlong-calls.
      
      The stuff becomes a little more complex. We need to cope with two
      different type of calling to _mcount.
      
      For the kernel part, the calling to _mcount(result of "objdump -hdr
      vmlinux"). is like this:
      
      	108:   03e0082d        move    at,ra
      	10c:   0c000000        jal     0 <fpcsr_pending>
                              10c: R_MIPS_26  _mcount
                              10c: R_MIPS_NONE        *ABS*
                              10c: R_MIPS_NONE        *ABS*
      	110:   00020021        nop
      
      For the module with -mlong-calls, it looks like this:
      
      	c:	3c030000 	lui	v1,0x0
      			c: R_MIPS_HI16	_mcount
      			c: R_MIPS_NONE	*ABS*
      			c: R_MIPS_NONE	*ABS*
      	10:	64630000 	daddiu	v1,v1,0
      			10: R_MIPS_LO16	_mcount
      			10: R_MIPS_NONE	*ABS*
      			10: R_MIPS_NONE	*ABS*
      	14:	03e0082d 	move	at,ra
      	18:	0060f809 	jalr	v1
      
      In the kernel version, there is only one "_mcount" string for every
      kernel function, so, we just need to match this one in mcount_regex of
      scripts/recordmcount.pl, but in the module version, we need to choose
      one of the two to match. Herein, I choose the first one with
      "R_MIPS_HI16 _mcount".
      
      and In the kernel verion, without module tracing support, we just need
      to replace "jal _mcount" by "jal ftrace_caller" to do real tracing, and
      filter the tracing of some kernel functions via replacing it by a nop
      instruction.
      
      but as we have described before, the instruction "jal ftrace_caller" only left
      32bit length for the address of ftrace_caller, it will fail when calling from
      the module space. so, herein, we must replace something else.
      
      the basic idea is loading the address of ftrace_caller to v1 via changing these
      two instructions:
      
      	lui	v1,0x0
      	addiu	v1,v1,0
      
      If we want to enable the tracing, we need to replace the above instructions to:
      
      	lui	v1, HI_16BIT_ftrace_caller
      	addiu	v1, v1, LOW_16BIT_ftrace_caller
      
      If we want to stop the tracing of the indicated kernel functions, we
      just need to replace the "jalr v1" to a nop instruction. but we need to
      replace two instructions and encode the above two instructions
      oursevles.
      
      Is there a simpler solution? Yes! Here it is, in this version, we put _mcount
      and ftrace_caller together, which means the address of _mcount and
      ftrace_caller is the same:
      
      _mcount:
      ftrace_caller:
      	j	ftrace_stub
      	 nop
      
      	...(do real tracing here)...
      
      ftrace_stub:
      	jr	ra
      	 move	ra, at
      
      By default, the kernel functions call _mcount, and then jump to ftrace_stub and
      return. and when we want to do real tracing, we just need to remove that "j
      ftrace_stub", and it will run through the two "nop" instructions and then do
      the real tracing job.
      
      what about filtering job? we just need to do this:
      
      	 lui v1, hi_16bit_of_mcount        <--> b 1f (0x10000004)
      	 addiu v1, v1, low_16bit_of_mcount
      	 move at, ra
      	 jalr v1
      	 nop
      	 				     1f: (rec->ip + 12)
      
      In linux-mips64, there will be some local symbols, whose name are
      prefixed by $L, which need to be filtered. thanks goes to Steven for
      writing the mips64-specific function_regex.
      
      In a conclusion, with RISC, things becomes easier with such a "stupid"
      trick, RISC is something like K.I.S.S, and also, there are lots of
      "simple" tricks in the whole ftrace support, thanks goes to Steven and
      the other folks for providing such a wonderful tracing framework!
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/675/Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      538f1952
    • W
      MIPS: Tracing: Enable HAVE_FUNCTION_TRACE_MCOUNT_TEST for MIPS · 69a7d1b3
      Wu Zhangjin 提交于
      There is an exisiting common ftrace_test_stop_func() in
      kernel/trace/ftrace.c, which is used to check the global variable
      ftrace_trace_stop to determine whether stop the function tracing.
      
      This patch implepment the MIPS specific one to speedup the procedure.
      
      Thanks goes to Zhang Le for Cleaning it up.
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/673/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      69a7d1b3
    • W
      MIPS: Tracing: Add static function tracer support for MIPS · d2bb0762
      Wu Zhangjin 提交于
      If -pg of gcc is enabled with CONFIG_FUNCTION_TRACER=y. a calling to
      _mcount will be inserted into each kernel function. so, there is a
      possibility to trace the kernel functions in _mcount.
      
      This patch add the MIPS specific _mcount support for static function
      tracing. by default, ftrace_trace_function is initialized as
      ftrace_stub(an empty function), so, the default _mcount will introduce
      very little overhead. after enabling ftrace in user-space, it will jump
      to a real tracing function and do static function tracing for us.
      
      and -ffunction-sections is incompatible with -pg, so, disable it when
      ftracer is enabled.
      Signed-off-by: NWu Zhangjin <wuzhangjin@gmail.com>
      Reviewed-by: NSteven Rostedt <rostedt@goodmis.org>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      Cc: zhangfx@lemote.com
      Cc: Wu Zhangjin <wuzhangjin@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: http://patchwork.linux-mips.org/patch/672/Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
      d2bb0762