lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 20 Dec 2012 17:04:04 +0800
From:	chenggang <>
Cc:	chenggang <>,
	David Ahern <>,
	Arjan van de Ven <>,
	Namhyung Kim <>,
	Yanmin Zhang <>,
	Wu Fengguang <>,
	Mike Galbraith <>,
	Paul Mackerras <>,
	Peter Zijlstra <>,
	Ingo Molnar <>,
	Arnaldo Carvalho de Melo <>,
	Andrew Morton <>,
	Chenggang Qin <>
Subject: [PATCH 0/5] perf top: Add the function that make the 'perf top -p $pid' can be aware of the new threads.

This patch set add the function that make the 'perf top -p $pid' could be aware
of the dynamic fork threads. The perf top{record} tools are not aware of the new
threads that forked by the target threads, while we use 'perf top{record} -p
$pid' model. Some critical structures, such as, thread_map, mmap, fd, pollfd,
id, are fixed in some arrays at the initialization phase. These structures
cannot be extended easily for the new threads. And, for some performance
reasons, the event inherit mechanism is forbidden in the '-p $pid' model.
So, these structures should be modified to a flexible form at low performance
penalty (especially the CPU utilization). Bitmap is a simple choice. A larger
thread_map->map[] can be allocate at the initialization phase, such as 32. When
the number of new threads is over 32, the size of this array can be extend
doubled by realloc. The bitmap is used to record which position in the map[] is
occupied by a thread, and which position can be used by the next new thread. I
insert a bitmap field in thread_map, and modified other related code in
thread_map.c, xyarray.c, evlist.c, evsel.c etc.
The fork and exit events (PERF_RECORD_FORK & PERF_RECORD_EXIT) can be caught
while we read events from the exist mmaps. Then, we can allocate resources, open
fd, record event id, and make a mmap for the new forked threads without
excessive cost. We can easily release related resources for the exited threads
This function has been already implemented for 'perf top -p $pid' in the patch
[5/5] of this patch set. Next step, the 'perf record -p $pid' should be changed
use the interfaces in evlist & evsel modified by this patch set. Just like the
'perf top'.

Cc: David Ahern <>
Cc: Arjan van de Ven <>
Cc: Namhyung Kim <>
Cc: Yanmin Zhang <>
Cc: Wu Fengguang <>
Cc: Mike Galbraith <>
Cc: Paul Mackerras <>
Cc: Peter Zijlstra <>
Cc: Ingo Molnar <>
Cc: Arnaldo Carvalho de Melo <>
Cc: Andrew Morton <>
Signed-off-by: Chenggang Qin <>

chenggang (5):
  perf tools: Add some functions to bitops.h to support more bitmap operations.
  perf tools: Add xyarray__realloc function in xyarray.c to expend xyarray.
  perf tools: Add bitmap filed to thread_map to support new threads aware.
  perf tools: Change some interfaces of evlist & evsel to support thread's
	      creation and destroy with thread_map's bitmap.
  perf top: Add the function to make 'perf top -p $pid' could be aware of new
	    forked thread.

 tools/perf/builtin-record.c               |   25 ++-
 tools/perf/builtin-stat.c                 |    7 +-
 tools/perf/builtin-top.c                  |  149 +++++++++++++++++-
 tools/perf/tests/mmap-basic.c             |    4 +-
 tools/perf/tests/open-syscall-all-cpus.c  |    2 +-
 tools/perf/tests/open-syscall-tp-fields.c |    3 +-
 tools/perf/tests/open-syscall.c           |    3 +-
 tools/perf/tests/perf-record.c            |    2 +-
 tools/perf/util/evlist.c                  |  236 +++++++++++++++++++++++------
 tools/perf/util/evlist.h                  |   39 +++--
 tools/perf/util/evsel.c                   |  164 +++++++++++++++++---
 tools/perf/util/evsel.h                   |   38 +++--
 tools/perf/util/include/linux/bitops.h    |   85 +++++++++--
 tools/perf/util/python.c                  |    3 +-
 tools/perf/util/thread_map.c              |  171 +++++++++++----------
 tools/perf/util/thread_map.h              |    8 +
 tools/perf/util/xyarray.c                 |   26 ++++
 tools/perf/util/xyarray.h                 |    2 +
 18 files changed, 755 insertions(+), 212 deletions(-)


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

Powered by blists - more mailing lists