linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/5] perf parse-regs: Refactor arch related functions
@ 2023-05-20  2:55 Leo Yan
  2023-05-20  2:55 ` [PATCH v1 1/5] perf parse-regs: Refactor arch register parsing functions Leo Yan
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Leo Yan @ 2023-05-20  2:55 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, John Garry, Will Deacon, James Clark,
	Mike Leach, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Ian Rogers,
	Adrian Hunter, Guo Ren, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Eric Lin, Kan Liang, Qi Liu, Sandipan Das, linux-kernel,
	linux-arm-kernel, linux-perf-users, linux-csky, linux-riscv
  Cc: Leo Yan

The register parsing have two levels: one level is under 'arch' folder,
another level is under 'util' folder.  A good design is 'arch' folder
handles architecture specific operations and provides APIs for upper
layer, on the other hand, 'util' folder should be general and simply
calls APIs to talk to arch layer.

The current code mixes these two layers, e.g. util/perf_regs.h includes
architecture's perf_regs.h, so it implicitly couples with specific
architecture during building time.  Furthermore, util/perf_regs.c
includes all architectures' perf_regs.h, this is easily to cause conflict
due to duplicated definitions from any two different archs.

So this patch series is to refactor arch related functions for register
parsing:

Firstly, it creates a new folder util/perf-regs-arch and uses dedicated
source file for every arch, note, all of these source files will be
built in tool to support cross analysis (e.g. we can run perf on x86
machine for parsing aarch64's perf data file).

Secondly, rather than directly referring macros, we introduce new
functions, these functions are provided by architecture and then will be
invoked by perf common code.  At the end, we can generalize the register
parsing in 'util' folder.

This patch series has been compiled successfully on my Arm64 and x86
machine.


Leo Yan (5):
  perf parse-regs: Refactor arch register parsing functions
  perf parse-regs: Introduce functions arch__reg_{ip|sp}()
  perf parse-regs: Remove unused macros PERF_REG_{IP|SP}
  perf parse-regs: Remove PERF_REGS_{MAX|MASK} from common code
  perf parse-regs: Move out arch specific header from util/perf_regs.h

 tools/perf/arch/arm/include/perf_regs.h       |   3 -
 tools/perf/arch/arm/util/perf_regs.c          |  21 +
 tools/perf/arch/arm/util/unwind-libdw.c       |   1 +
 tools/perf/arch/arm64/include/perf_regs.h     |   3 -
 tools/perf/arch/arm64/util/machine.c          |   1 +
 tools/perf/arch/arm64/util/perf_regs.c        |  16 +
 tools/perf/arch/arm64/util/unwind-libdw.c     |   1 +
 tools/perf/arch/csky/include/perf_regs.h      |   3 -
 tools/perf/arch/csky/util/perf_regs.c         |  21 +
 tools/perf/arch/csky/util/unwind-libdw.c      |   1 +
 tools/perf/arch/mips/include/perf_regs.h      |   2 -
 tools/perf/arch/mips/util/perf_regs.c         |  21 +
 tools/perf/arch/powerpc/include/perf_regs.h   |   3 -
 tools/perf/arch/powerpc/util/perf_regs.c      |  16 +
 tools/perf/arch/powerpc/util/unwind-libdw.c   |   1 +
 tools/perf/arch/riscv/include/perf_regs.h     |   3 -
 tools/perf/arch/riscv/util/perf_regs.c        |  21 +
 tools/perf/arch/riscv/util/unwind-libdw.c     |   1 +
 tools/perf/arch/s390/include/perf_regs.h      |   3 -
 tools/perf/arch/s390/util/perf_regs.c         |  21 +
 tools/perf/arch/s390/util/unwind-libdw.c      |   1 +
 tools/perf/arch/x86/include/perf_regs.h       |   2 -
 tools/perf/arch/x86/util/perf_regs.c          |  16 +
 tools/perf/arch/x86/util/unwind-libdw.c       |   1 +
 tools/perf/util/Build                         |   1 +
 tools/perf/util/evsel.c                       |   2 +-
 tools/perf/util/perf-regs-arch/Build          |   8 +
 .../util/perf-regs-arch/perf_regs_aarch64.c   |  86 +++
 .../perf/util/perf-regs-arch/perf_regs_arm.c  |  50 ++
 .../perf/util/perf-regs-arch/perf_regs_csky.c |  90 +++
 .../perf/util/perf-regs-arch/perf_regs_mips.c |  77 +++
 .../util/perf-regs-arch/perf_regs_powerpc.c   | 135 ++++
 .../util/perf-regs-arch/perf_regs_riscv.c     |  82 +++
 .../perf/util/perf-regs-arch/perf_regs_s390.c |  86 +++
 .../perf/util/perf-regs-arch/perf_regs_x86.c  |  88 +++
 tools/perf/util/perf_regs.c                   | 646 +-----------------
 tools/perf/util/perf_regs.h                   |  18 +-
 tools/perf/util/unwind-libdw.c                |   2 +-
 tools/perf/util/unwind.h                      |   4 +-
 39 files changed, 887 insertions(+), 671 deletions(-)
 create mode 100644 tools/perf/util/perf-regs-arch/Build
 create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_aarch64.c
 create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_arm.c
 create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_csky.c
 create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_mips.c
 create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_powerpc.c
 create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_riscv.c
 create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_s390.c
 create mode 100644 tools/perf/util/perf-regs-arch/perf_regs_x86.c

-- 
2.39.2


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

end of thread, other threads:[~2023-05-23  6:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-20  2:55 [PATCH v1 0/5] perf parse-regs: Refactor arch related functions Leo Yan
2023-05-20  2:55 ` [PATCH v1 1/5] perf parse-regs: Refactor arch register parsing functions Leo Yan
2023-05-20  2:55 ` [PATCH v1 2/5] perf parse-regs: Introduce functions arch__reg_{ip|sp}() Leo Yan
2023-05-22  8:57   ` James Clark
2023-05-22 12:07     ` Leo Yan
2023-05-22 16:34       ` James Clark
2023-05-22 18:08   ` Ian Rogers
2023-05-23  6:49     ` Leo Yan
2023-05-20  2:55 ` [PATCH v1 3/5] perf parse-regs: Remove unused macros PERF_REG_{IP|SP} Leo Yan
2023-05-20  2:55 ` [PATCH v1 4/5] perf parse-regs: Remove PERF_REGS_{MAX|MASK} from common code Leo Yan
2023-05-20  2:55 ` [PATCH v1 5/5] perf parse-regs: Move out arch specific header from util/perf_regs.h Leo Yan

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).