mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Tomas Glozar <tglozar@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	linux-perf-users@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	Wander Costa <wcosta@redhat.com>
Subject: Re: [BUG] perf segfaults when combining --overwrite and intel_pt event
Date: Mon, 28 Apr 2025 13:47:27 +0100	[thread overview]
Message-ID: <20250428124727.GE551819@e132581.arm.com> (raw)
In-Reply-To: <CAP4=nvQ_7oS5ZAsKmOd_ORg0tyHS=B+i2m63K=TLg22rTEiRGQ@mail.gmail.com>

On Mon, Apr 28, 2025 at 12:45:41PM +0200, Tomas Glozar wrote:

> Thank you for looking at this. The initial segfault on writing to
> read-only page is fixed,

Thanks a lot for testing, Tomas!

> however, perf now segfaults in a different place:


> (gdb) r
> Starting program: /home/tglozar/dev/linux/tools/perf/perf record
> --overwrite -a -e intel_pt/cyc,noretcomp/k sleep 5
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> [Detaching after fork from child process 424037]
> [New Thread 0x7ffff2df46c0 (LWP 424038)]
> [ perf record: Woken up 1 times to write data ]
> Thread 1 "perf" received signal SIGSEGV, Segmentation fault.
> intel_pt_info_fill (itr=0x7a1e40, session=0x794ef0,
> auxtrace_info=0x7cdfd0, priv_size=144) at arch/x86/util/intel-pt.c:361
> 361             pc = session->evlist->mmap[0].core.base;

Yes, this is a different issue, it would be fixed by:

diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 8f235d8b67b6..42f0dbfa973c 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -322,7 +322,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
 	struct intel_pt_recording *ptr =
 			container_of(itr, struct intel_pt_recording, itr);
 	struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;
-	struct perf_event_mmap_page *pc;
+	struct perf_event_mmap_page *pc = NULL;
 	struct perf_tsc_conversion tc = { .time_mult = 0, };
 	bool cap_user_time_zero = false, per_cpu_mmaps;
 	u64 tsc_bit, mtc_bit, mtc_freq_bits, cyc_bit, noretcomp_bit;
@@ -358,7 +358,11 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
 	if (!session->evlist->core.nr_mmaps)
 		return -EINVAL;
 
-	pc = session->evlist->mmap[0].core.base;
+	if (session->evlist->mmap)
+		pc = session->evlist->mmap[0].core.base;
+	else if (session->evlist->mmap_ovw)
+		pc = session->evlist->mmap_ovw[0].core.base;
+
 	if (pc) {
 		err = perf_read_tsc_conversion(pc, &tc);
 		if (err) {

I would leave this fix to the Intel-PT developers, who know this part
best.

Thanks,
Leo

  reply	other threads:[~2025-04-28 12:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28  9:07 Tomas Glozar
2025-04-28 10:12 ` Leo Yan
2025-04-28 10:45   ` Tomas Glozar
2025-04-28 12:47     ` Leo Yan [this message]
2025-04-28 14:16       ` Tomas Glozar
2025-04-29  9:56         ` Leo Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250428124727.GE551819@e132581.arm.com \
    --to=leo.yan@arm.com \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglozar@redhat.com \
    --cc=wcosta@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®