linux/tools/perf/python
Ian Rogers b1f968c965 perf python: Port export-to-postgresql to perf module
Port export-to-postgresql.py to a standalone script in
tools/perf/python/ using the perf module and libpq via ctypes.

Improvements compared to the legacy script:
- Remove the dependency on PySide/QtSql for database creation and DDL
  execution by driving libpq directly via ctypes (PQconnectdb, PQexec,
  PQputCopyData, PQputCopyEnd) and streaming binary PostgreSQL COPY
  files in PostgresExporter, enabling export on headless servers without
  Qt installed.
- Harden database connection and SQL identifier handling by rejecting
  URI ('://') and connection-parameter ('=') injection strings in
  setup_db() and connect(), escaping single quotes and backslashes in
  connection strings, and quoting SQL identifiers (quote_ident).
- Support Intel PT and instruction trace export via
  perf.session(itrace=...) and perf.call_return callbacks, reconstructing
  relational call_paths and calls tables (including id=0 placeholder
  rows and callfk/returnfk foreign keys) and unpacking synthesized PT
  payloads (ptwrite, cbr, mwait, pwre, exstop, pwrx).
- Use a dedicated context_switch ID counter so context-switch exports
  do not advance sample database IDs out of sync with call_return
  references.

Update Documentation/db-export.txt and add a shell test
(test_export_to_postgresql_python.sh) to verify the standalone exporter.

Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-26 20:49:31 +02:00
..
arm-cs-trace-disasm.py perf python: Port arm-cs-trace-disasm to perf module 2026-09-26 20:49:30 +02:00
check-perf-trace.py perf python: Port check-perf-trace to perf module 2026-09-26 20:49:30 +02:00
compaction-times.py perf python: Port compaction-times to perf module 2026-09-26 20:49:30 +02:00
counting.py perf python: Improve perf script -l descriptions 2026-09-26 20:49:27 +02:00
event_analyzing_sample.py perf python: Port event_analyzing_sample to perf module 2026-09-26 20:49:29 +02:00
export-to-postgresql.py perf python: Port export-to-postgresql to perf module 2026-09-26 20:49:31 +02:00
export-to-sqlite.py perf python: Port export-to-sqlite to perf module 2026-09-26 20:49:31 +02:00
failed-syscalls-by-pid.py perf python: Port failed-syscalls-by-pid to perf module 2026-09-26 20:49:29 +02:00
failed-syscalls.py perf python: Port failed-syscalls from Perl to perf module 2026-09-26 20:49:29 +02:00
flamegraph.py perf python: Port flamegraph to perf module 2026-09-26 20:49:28 +02:00
futex-contention.py perf python: Port futex-contention to perf module 2026-09-26 20:49:29 +02:00
gecko.py perf python: Port gecko to perf module 2026-09-26 20:49:28 +02:00
ilist.py perf python: Clean up pylint warnings in ilist.py 2026-09-26 20:49:27 +02:00
intel-pt-events.py perf python: Port intel-pt-events and libxed to perf module 2026-09-26 20:49:30 +02:00
libxed.py perf python: Port intel-pt-events and libxed to perf module 2026-09-26 20:49:30 +02:00
mem-phys-addr.py perf python: Port mem-phys-addr to perf module 2026-09-26 20:49:28 +02:00
net_dropmonitor.py perf python: Port net_dropmonitor to perf module 2026-09-26 20:49:30 +02:00
netdev-times.py perf python: Port netdev-times to perf module 2026-09-26 20:49:30 +02:00
perf_live.py perf python: Allow KeyboardInterrupt to propagate in LiveSession 2026-09-26 20:49:27 +02:00
perf.pyi perf python: Add Intel PT call_return and itrace capability 2026-09-26 20:49:27 +02:00
powerpc-hcalls.py perf python: Port powerpc-hcalls to perf module 2026-09-26 20:49:30 +02:00
rw-by-file.py perf python: Port rw-by-file from Perl to perf module 2026-09-26 20:49:29 +02:00
rw-by-pid.py perf python: Port rw-by-pid from Perl to perf module 2026-09-26 20:49:29 +02:00
rwtop.py perf python: Port rwtop from Perl to perf module 2026-09-26 20:49:29 +02:00
sched-migration.py perf python: Port sched-migration and SchedGui to perf module 2026-09-26 20:49:30 +02:00
SchedGui.py perf python: Port sched-migration and SchedGui to perf module 2026-09-26 20:49:30 +02:00
sctop.py perf python: Port sctop to perf module 2026-09-26 20:49:29 +02:00
stackcollapse.py perf python: Port stackcollapse to perf module 2026-09-26 20:49:28 +02:00
stat-cpi.py perf python: Port stat-cpi to perf module 2026-09-26 20:49:28 +02:00
syscall-counts-by-pid.py perf python: Port syscall-counts-by-pid to perf module 2026-09-26 20:49:29 +02:00
syscall-counts.py perf python: Port syscall-counts to perf module 2026-09-26 20:49:29 +02:00
task-analyzer.py perf python: Port task-analyzer to perf module 2026-09-26 20:49:30 +02:00
tracepoint.py perf python: Improve perf script -l descriptions 2026-09-26 20:49:27 +02:00
treport.py perf python: Clean up pylint warnings in treport.py 2026-09-26 20:49:27 +02:00
twatch.py perf python: Improve perf script -l descriptions 2026-09-26 20:49:27 +02:00
wakeup-latency.py perf python: Port wakeup-latency from Perl to perf module 2026-09-26 20:49:30 +02:00