bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/18] Mutex wrapper, locking and memory leak fixes
@ 2022-08-24 15:38 Ian Rogers
  2022-08-24 15:38 ` [PATCH v3 01/18] perf mutex: Wrapped usage of mutex and cond Ian Rogers
                   ` (18 more replies)
  0 siblings, 19 replies; 49+ messages in thread
From: Ian Rogers @ 2022-08-24 15:38 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Thomas Gleixner, Darren Hart, Davidlohr Bueso,
	André Almeida, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Weiguo Li, Athira Rajeev, Thomas Richter, Ravi Bangoria,
	Dario Petrillo, Hewenliang, yaowenbin, Wenyu Liu, Song Liu,
	Andrii Nakryiko, Dave Marchevsky, Leo Yan, Kim Phillips,
	Pavithra Gurushankar, Alexandre Truong, Quentin Monnet,
	William Cohen, Andres Freund, Adrian Hunter, Martin Liška,
	Colin Ian King, James Clark, Fangrui Song, Stephane Eranian,
	Kajol Jain, Alexey Bayduraev, Riccardo Mancini, Andi Kleen,
	Masami Hiramatsu, Zechuan Chen, Jason Wang, Christophe JAILLET,
	Remi Bernon, linux-kernel, linux-perf-users, bpf, llvm
  Cc: Ian Rogers

When fixing a locking race and memory leak in:
https://lore.kernel.org/linux-perf-users/20211118193714.2293728-1-irogers@google.com/

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/20220727111954.105118-1-gpavithrasha@gmail.com/

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.

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                    | 109 +++++++++++++++++++
 tools/perf/util/probe-event.c              |   3 +
 tools/perf/util/symbol.c                   |   4 +-
 tools/perf/util/top.h                      |   5 +-
 41 files changed, 570 insertions(+), 323 deletions(-)
 create mode 100644 tools/perf/util/mutex.c
 create mode 100644 tools/perf/util/mutex.h

-- 
2.37.2.609.g9ff673ca1a-goog


^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2022-08-27  7:11 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24 15:38 [PATCH v3 00/18] Mutex wrapper, locking and memory leak fixes Ian Rogers
2022-08-24 15:38 ` [PATCH v3 01/18] perf mutex: Wrapped usage of mutex and cond Ian Rogers
2022-08-26  8:49   ` Adrian Hunter
2022-08-24 15:38 ` [PATCH v3 02/18] perf bench: Update use of pthread mutex/cond Ian Rogers
2022-08-24 15:38 ` [PATCH v3 03/18] perf tests: Avoid pthread.h inclusion Ian Rogers
2022-08-24 15:38 ` [PATCH v3 04/18] perf hist: Update use of pthread mutex Ian Rogers
2022-08-24 15:38 ` [PATCH v3 05/18] perf bpf: Remove unused pthread.h include Ian Rogers
2022-08-24 15:38 ` [PATCH v3 06/18] perf lock: " Ian Rogers
2022-08-24 15:38 ` [PATCH v3 07/18] perf record: Update use of pthread mutex Ian Rogers
2022-08-24 15:38 ` [PATCH v3 08/18] perf sched: " Ian Rogers
2022-08-24 15:38 ` [PATCH v3 09/18] perf ui: " Ian Rogers
2022-08-26 10:11   ` Adrian Hunter
2022-08-26 16:01     ` Ian Rogers
2022-08-26 10:24   ` Adrian Hunter
2022-08-26 16:02     ` Ian Rogers
2022-08-26 17:22       ` Adrian Hunter
2022-08-26 17:45         ` Ian Rogers
2022-08-26 18:52           ` Adrian Hunter
2022-08-26 19:00             ` Namhyung Kim
2022-08-26 19:20               ` Adrian Hunter
2022-08-26 20:40                 ` Namhyung Kim
2022-08-26 20:52                   ` Ian Rogers
2022-08-27  7:11                     ` Adrian Hunter
2022-08-24 15:38 ` [PATCH v3 10/18] perf mmap: Remove unnecessary pthread.h include Ian Rogers
2022-08-24 15:38 ` [PATCH v3 11/18] perf dso: Update use of pthread mutex Ian Rogers
2022-08-26 10:37   ` Adrian Hunter
2022-08-26 16:05     ` Ian Rogers
2022-08-26 17:34       ` Adrian Hunter
2022-08-26 17:46         ` Ian Rogers
2022-08-24 15:38 ` [PATCH v3 12/18] perf annotate: " Ian Rogers
2022-08-24 15:38 ` [PATCH v3 13/18] perf top: " Ian Rogers
2022-08-24 15:38 ` [PATCH v3 14/18] perf dso: Hold lock when accessing nsinfo Ian Rogers
2022-08-24 15:38 ` [PATCH v3 15/18] perf mutex: Add thread safety annotations Ian Rogers
2022-08-26 11:12   ` Adrian Hunter
2022-08-26 16:45   ` Arnaldo Carvalho de Melo
2022-08-26 17:00     ` Ian Rogers
2022-08-26 19:13       ` Arnaldo Carvalho de Melo
2022-08-24 15:38 ` [PATCH v3 16/18] perf sched: Fixes for thread safety analysis Ian Rogers
2022-08-26 12:12   ` Adrian Hunter
2022-08-26 16:06     ` Ian Rogers
2022-08-26 17:41       ` Adrian Hunter
2022-08-26 17:48         ` Ian Rogers
2022-08-26 18:26           ` Namhyung Kim
2022-08-26 19:35             ` Adrian Hunter
2022-08-26 20:48               ` Namhyung Kim
2022-08-24 15:39 ` [PATCH v3 17/18] perf top: " Ian Rogers
2022-08-24 15:39 ` [PATCH v3 18/18] perf build: Enable -Wthread-safety with clang Ian Rogers
     [not found] ` <CA+JHD906M0truH7wPNZ=eJwdCA=qLhYDonUx_ZQBwJYpiX1hNg@mail.gmail.com>
2022-08-25 16:14   ` [PATCH v3 00/18] Mutex wrapper, locking and memory leak fixes Adrian Hunter
2022-08-26 12:36     ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).