Skip to content

Mutex wrapper, locking and memory leak fixes

Ian Rogers bpf linux-perf-users lkml llvm 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest posting 2/218 patches 2 repliesIn review
  2. v4 posting 1/25 of 18 patches 2 repliesSuperseded
  3. v318 patches 30 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v218 patches4 repliesSuperseded
v16 patches12 repliesSuperseded

Patches in v4 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18perf mutex: Wrapped usage of mutex and condtools/perf/util/Build tools/perf/util/mutex.c tools/perf/util/mutex.h+166 -00 replies
2/18perf bench: Update use of pthread mutex/condtools/perf/bench/epoll-ctl.c tools/perf/bench/epoll-wait.c tools/perf/bench/futex-hash.c +5 more+153 -1710 replies
3/18perf tests: Avoid pthread.h inclusiontools/perf/tests/mmap-basic.c tools/perf/tests/openat-syscall-all-cpus.c tools/perf/tests/perf-record.c+1 -50 replies
4/18perf hist: Update use of pthread mutextools/perf/builtin-top.c tools/perf/util/hist.c tools/perf/util/hist.h+9 -90 replies
5/18perf bpf: Remove unused pthread.h includetools/perf/util/bpf-event.h+0 -10 replies
6/18perf lock: Remove unused pthread.h includetools/perf/builtin-lock.c+0 -10 replies
7/18perf record: Update use of pthread mutextools/perf/builtin-record.c+9 -40 replies
8/18perf sched: Update use of pthread mutextools/perf/builtin-sched.c+32 -350 replies
9/18perf ui: Update use of pthread mutextools/perf/ui/browser.c tools/perf/ui/browsers/annotate.c tools/perf/ui/setup.c +5 more+35 -350 replies
10/18perf mmap: Remove unnecessary pthread.h includetools/perf/util/mmap.h+0 -10 replies
11/18perf dso: Update use of pthread mutextools/perf/util/dso.c tools/perf/util/dso.h tools/perf/util/symbol.c+10 -100 replies
12/18perf annotate: Update use of pthread mutextools/perf/builtin-top.c tools/perf/ui/browsers/annotate.c tools/perf/util/annotate.c +1 more+20 -210 replies
13/18perf top: Update use of pthread mutextools/perf/builtin-top.c tools/perf/util/top.h+12 -110 replies
14/18perf dso: Hold lock when accessing nsinfotools/perf/builtin-inject.c tools/perf/util/annotate.c tools/perf/util/build-id.c +4 more+28 -50 replies
15/18perf mutex: Add thread safety annotationstools/perf/util/mutex.c tools/perf/util/mutex.h+67 -50 replies
16/18perf sched: Fixes for thread safety analysistools/perf/builtin-sched.c+29 -170 replies
17/18perf top: Fixes for thread safety analysistools/perf/builtin-top.c+3 -20 replies
18/18perf build: Enable -Wthread-safety with clangtools/perf/Makefile.config+5 -00 replies

Reviews trailers per patch

None of the 18 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNamhyung Kim
SeriesA-b
1/18
2/18
3/18
4/18
5/18
6/18
7/18
8/18
9/18
10/18
11/18
12/18
13/18
14/18
15/18
16/18
17/18
18/18

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 00/18] Mutex wrapper, locking and memory leak fixes

When fixing a locking race and memory leak in:
https://lore.kernel.org/linux-perf-users/[email protected]/

It was requested that debug mutex code be separated out into its own files. This was, in part, done by Pavithra Gurushankar in:
https://lore.kernel.org/lkml/[email protected]/

These patches fix issues with the previous patches, add in the original dso->nsinfo fix and then build on our mutex wrapper with clang's -Wthread-safety analysis. The analysis found missing unlocks in builtin-sched.c which are fixed and -Wthread-safety is enabled by default when building with clang.

v4. Adds a comment for the trylock result, fixes the new line (missed
in v3) and removes two blank lines as suggested by Adrian Hunter.
v3. Adds a missing new line to the error messages and removes the
pshared argument to mutex_init by having two functions, mutex_init and mutex_init_pshared. These changes were suggested by Adrian Hunter.
v2. Breaks apart changes that s/pthread_mutex/mutex/g and the lock
annotations as requested by Arnaldo and Namhyung. A boolean is added to builtin-sched.c to terminate thread funcs rather than leaving them blocked on delted mutexes.

Ian Rogers (17):
perf bench: Update use of pthread mutex/cond
perf tests: Avoid pthread.h inclusion
perf hist: Update use of pthread mutex
perf bpf: Remove unused pthread.h include
perf lock: Remove unused pthread.h include
perf record: Update use of pthread mutex
perf sched: Update use of pthread mutex
perf ui: Update use of pthread mutex
perf mmap: Remove unnecessary pthread.h include
perf dso: Update use of pthread mutex
perf annotate: Update use of pthread mutex
perf top: Update use of pthread mutex
perf dso: Hold lock when accessing nsinfo
perf mutex: Add thread safety annotations
perf sched: Fixes for thread safety analysis
perf top: Fixes for thread safety analysis
perf build: Enable -Wthread-safety with clang

Pavithra Gurushankar (1):
perf mutex: Wrapped usage of mutex and cond

 tools/perf/Makefile.config                 |   5 +
 tools/perf/bench/epoll-ctl.c               |  33 +++---
 tools/perf/bench/epoll-wait.c              |  33 +++---
 tools/perf/bench/futex-hash.c              |  33 +++---
 tools/perf/bench/futex-lock-pi.c           |  33 +++---
 tools/perf/bench/futex-requeue.c           |  33 +++---
 tools/perf/bench/futex-wake-parallel.c     |  33 +++---
 tools/perf/bench/futex-wake.c              |  33 +++---
 tools/perf/bench/numa.c                    |  93 ++++++----------
 tools/perf/builtin-inject.c                |   4 +
 tools/perf/builtin-lock.c                  |   1 -
 tools/perf/builtin-record.c                |  13 ++-
 tools/perf/builtin-sched.c                 | 105 +++++++++---------
 tools/perf/builtin-top.c                   |  45 ++++----
 tools/perf/tests/mmap-basic.c              |   2 -
 tools/perf/tests/openat-syscall-all-cpus.c |   2 +-
 tools/perf/tests/perf-record.c             |   2 -
 tools/perf/ui/browser.c                    |  20 ++--
 tools/perf/ui/browsers/annotate.c          |  12 +--
 tools/perf/ui/setup.c                      |   5 +-
 tools/perf/ui/tui/helpline.c               |   5 +-
 tools/perf/ui/tui/progress.c               |   8 +-
 tools/perf/ui/tui/setup.c                  |   8 +-
 tools/perf/ui/tui/util.c                   |  18 ++--
 tools/perf/ui/ui.h                         |   4 +-
 tools/perf/util/Build                      |   1 +
 tools/perf/util/annotate.c                 |  15 +--
 tools/perf/util/annotate.h                 |   4 +-
 tools/perf/util/bpf-event.h                |   1 -
 tools/perf/util/build-id.c                 |  12 ++-
 tools/perf/util/dso.c                      |  19 ++--
 tools/perf/util/dso.h                      |   4 +-
 tools/perf/util/hist.c                     |   6 +-
 tools/perf/util/hist.h                     |   4 +-
 tools/perf/util/map.c                      |   3 +
 tools/perf/util/mmap.h                     |   1 -
 tools/perf/util/mutex.c                    | 119 +++++++++++++++++++++
 tools/perf/util/mutex.h                    | 108 +++++++++++++++++++
 tools/perf/util/probe-event.c              |   3 +
 tools/perf/util/symbol.c                   |   4 +-
 tools/perf/util/top.h                      |   5 +-
 41 files changed, 569 insertions(+), 323 deletions(-)
 create mode 100644 tools/perf/util/mutex.c
 create mode 100644 tools/perf/util/mutex.h
Signature · 1 line
2.37.2.672.g94769d06f0-goog