1. 08 10月, 2012 6 次提交
    • O
      uprobes: Fix prepare_uprobe() race with itself · 4710f05f
      Oleg Nesterov 提交于
      install_breakpoint() is called under mm->mmap_sem, this protects
      set_swbp() but not prepare_uprobe(). Two or more different tasks
      can call install_breakpoint()->prepare_uprobe() at the same time,
      this leads to numerous problems if UPROBE_COPY_INSN is not set.
      
      Just for example, the second copy_insn() can corrupt the already
      analyzed/fixuped uprobe->arch.insn and race with handle_swbp().
      
      This patch simply adds uprobe->copy_mutex to serialize this code.
      We could probably reuse ->consumer_rwsem, but this would mean that
      consumer->handler() can not use mm->mmap_sem, not good.
      
      Note: this is another temporary ugly hack until we move this logic
      into uprobe_register().
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Acked-by: NSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      4710f05f
    • O
      uprobes: Introduce prepare_uprobe() · cb9a19fe
      Oleg Nesterov 提交于
      Preparation. Extract the copy_insn/arch_uprobe_analyze_insn code
      from install_breakpoint() into the new helper, prepare_uprobe().
      
      And move uprobe->flags defines from uprobes.h to uprobes.c, nobody
      else can use them anyway.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Acked-by: NSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      cb9a19fe
    • O
      uprobes: Fix handle_swbp() vs unregister() + register() race · 142b18dd
      Oleg Nesterov 提交于
      Strictly speaking this race was added by me in 56bb4cf6. However
      I think that this bug is just another indication that we should
      move copy_insn/uprobe_analyze_insn code from install_breakpoint()
      to uprobe_register(), there are a lot of other reasons for that.
      Until then, add a hack to close the race.
      
      A task can hit uprobe U1, but before it calls find_uprobe() this
      uprobe can be unregistered *AND* another uprobe U2 can be added to
      uprobes_tree at the same inode/offset. In this case handle_swbp()
      will use the not-fully-initialized U2, in particular its arch.insn
      for xol.
      
      Add the additional !UPROBE_COPY_INSN check into handle_swbp(),
      if this flag is not set we simply restart as if the new uprobe was
      not inserted yet. This is not very nice, we need barriers, but we
      will remove this hack when we change uprobe_register().
      
      Note: with or without this patch install_breakpoint() can race with
      itself, yet another reson to kill UPROBE_COPY_INSN altogether. And
      even the usage of uprobe->flags is not safe. See the next patches.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Acked-by: NSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      142b18dd
    • O
      uprobes: Do not delete uprobe if uprobe_unregister() fails · 076a365b
      Oleg Nesterov 提交于
      delete_uprobe() must not be called if register_for_each_vma(false)
      fails to remove all breakpoints, __uprobe_unregister() is correct.
      The problem is that register_for_each_vma(false) always returns 0
      and thus this logic does not work.
      
      1. Change verify_opcode() to return 0 rather than -EINVAL when
         unregister detects the !is_swbp insn, we can treat this case
         as success and currently unregister paths ignore the error
         code anyway.
      
      2. Change remove_breakpoint() to propagate the error code from
         write_opcode().
      
      3. Change register_for_each_vma(is_register => false) to remove
         as much breakpoints as possible but return non-zero if
         remove_breakpoint() fails at least once.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Acked-by: NSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      076a365b
    • O
      uprobes: Don't return success if alloc_uprobe() fails · a5f658b7
      Oleg Nesterov 提交于
      If alloc_uprobe() fails uprobe_register() should return ENOMEM, not 0.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Acked-by: NSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      a5f658b7
    • O
      uprobes/x86: Only rep+nop can be emulated correctly · b64b9c93
      Oleg Nesterov 提交于
      __skip_sstep() correctly detects the "nontrivial" nop insns,
      but since it doesn't update regs->ip we can not really skip
      "0x0f 0x1f | 0x0f 0x19 | 0x87 0xc0", the probed application
      is killed by SIGILL'ed handle_swbp().
      
      Remove these additional checks. If we want to implement this
      correctly we need to know the full insn length to update ->ip.
      
      rep* + nop is fine even without updating ->ip.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Acked-by: NSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      b64b9c93
  2. 30 9月, 2012 12 次提交
  3. 28 9月, 2012 2 次提交
  4. 27 9月, 2012 12 次提交
  5. 26 9月, 2012 5 次提交
  6. 25 9月, 2012 3 次提交
    • N
      tools lib traceevent: Fix error path on pevent_parse_event · f1b2256d
      Namhyung Kim 提交于
      If __pevent_parse_format() succeeded but add_event() failed, 'ret' didn't
      have a proper error code.  Set it to PEVENT_ERRNO__MEM_ALLOC_FAILED.
      
      In addition, at that point 'event' also has fields and format
      information and they all need to be freed.  Call pevent_free_format() to
      handle it.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1348575919-4954-1-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f1b2256d
    • N
      perf test: Fix build failure · af9da88f
      Namhyung Kim 提交于
      The commit 6a6cd11d ("perf test: Add test for the sched tracepoint
      format fields") added following build error:
      
          CC builtin-test.o
        builtin-test.c: In function ‘perf_evsel__test_field’:
        builtin-test.c:1216:6: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
        builtin-test.c: In function ‘perf_evsel__tp_sched_test’:
        builtin-test.c:1242:6: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
        cc1: all warnings being treated as errors
        make: *** [builtin-test.o] Error 1
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1348539628-3821-1-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      af9da88f
    • I
      Merge tag 'perf-core-for-mingo' of... · f74eb728
      Ingo Molnar 提交于
      Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
       * Convert the trace builtins to use the growing evsel/evlist
         tracepoint infrastructure, removing several open coded constructs
         like switch like series of strcmp to dispatch events, etc.
         Basically what had already been showcased in 'perf sched'.
      
       * Add evsel constructor for tracepoints, that uses libtraceevent
         just to parse the /format events file, use it in a new 'perf test'
         to make sure the libtraceevent format parsing regressions can
         be more readily caught.
      
       * Some strange errors were happening in some builds, but not on the
         next, reported by several people, problem was some parser related
         files, generated during the build, didn't had proper make deps,
         fix from Eric Sandeen.
      
       * Fix some compiling errors on 32-bit, from Feng Tang.
      
       * Don't use sscanf extension %as, not available on bionic, reimplementation
         by Irina Tirdea.
      
       * Fix bfd.h/libbfd detection with recent binutils, from Markus Trippelsdorf.
      
       * Introduce struct and cache information about the environment where a
         perf.data file was captured, from Namhyung Kim.
      
       * Fix several error paths in libtraceevent, from Namhyung Kim.
      
         Print event causing perf_event_open() to fail in 'perf record',
         from Stephane Eranian.
      
       * New 'kvm' analysis tool, from Xiao Guangrong.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f74eb728