linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	Indu Bhagat <indu.bhagat@oracle.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-perf-users@vger.kernel.org, Mark Brown <broonie@kernel.org>,
	linux-toolchains@vger.kernel.org
Subject: Re: [PATCH RFC 04/10] perf: Introduce deferred user callchains
Date: Wed, 15 Nov 2023 08:13:31 -0800	[thread overview]
Message-ID: <ZVTuK5VRQfY1JOEY@google.com> (raw)
In-Reply-To: <CAM9d7chgoiwc3ZfQ8SzO7gV0oQOKMK3bJAdxa63Pzgcqo4i7tQ@mail.gmail.com>

On Mon, Nov 13, 2023 at 08:56:39AM -0800, Namhyung Kim wrote:
> On Sat, Nov 11, 2023 at 10:49 AM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
> >
> > On Fri, Nov 10, 2023 at 10:57:58PM -0800, Namhyung Kim wrote:
> > > Anyway I'm not sure it can support these additional samples for
> > > deferred callchains without breaking the existing perf tools.
> > > Anyway it doesn't know PERF_CONTEXT_USER_DEFERRED at least.
> > > I think this should be controlled by a new feature bit in the
> > > perf_event_attr.
> > >
> > > Then we might add a breaking change to have a special
> > > sample record for the deferred callchains and sample ID only.
> >
> > Sounds like a good idea.  I'll need to study the code to figure out how
> > to do that on the perf tool side.  Or would you care to write a patch?
> 
> Sure, I'd be happy to write one.

I think we can start with something like the below.
The sample id (attr.sample_type) should have
IDENTIFIER | TID | TIME to enable defer_callchain
in order to match sample and callchain records.

Thanks,
Namhyung


---8<---
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 39c6a250dd1b..a3765ff59798 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -456,7 +456,8 @@ struct perf_event_attr {
 				inherit_thread :  1, /* children only inherit if cloned with CLONE_THREAD */
 				remove_on_exec :  1, /* event is removed from task on exec */
 				sigtrap        :  1, /* send synchronous SIGTRAP on event */
-				__reserved_1   : 26;
+				defer_callchain:  1, /* generate DEFERRED_CALLCHAINS records for userspace */
+				__reserved_1   : 25;
 
 	union {
 		__u32		wakeup_events;	  /* wakeup every n events */
@@ -1207,6 +1208,20 @@ enum perf_event_type {
 	 */
 	PERF_RECORD_AUX_OUTPUT_HW_ID		= 21,
 
+	/*
+	 * Deferred user stack callchains (for SFrame).  Previous samples would
+	 * have kernel callchains only and they need to be stitched with this
+	 * to make full callchains.
+	 *
+	 * struct {
+	 *	struct perf_event_header	header;
+	 *	u64				nr;
+	 *	u64				ips[nr];
+	 *	struct sample_id		sample_id;
+	 * };
+	 */
+	PERF_RECORD_DEFERRED_CALLCHAINS		= 22,
+
 	PERF_RECORD_MAX,			/* non-ABI */
 };
 

  parent reply	other threads:[~2023-11-15 16:13 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09  0:41 [PATCH RFC 00/10] perf: user space sframe unwinding Josh Poimboeuf
2023-11-09  0:41 ` [PATCH RFC 01/10] perf: Remove get_perf_callchain() 'init_nr' argument Josh Poimboeuf
2023-11-11  6:09   ` Namhyung Kim
2023-11-09  0:41 ` [PATCH RFC 02/10] perf: Remove get_perf_callchain() 'crosstask' argument Josh Poimboeuf
2023-11-11  6:11   ` Namhyung Kim
2023-11-11 20:53     ` Jordan Rome
2023-11-09  0:41 ` [PATCH RFC 03/10] perf: Simplify get_perf_callchain() user logic Josh Poimboeuf
2023-11-11  6:11   ` Namhyung Kim
2023-11-09  0:41 ` [PATCH RFC 04/10] perf: Introduce deferred user callchains Josh Poimboeuf
2023-11-11  6:57   ` Namhyung Kim
2023-11-11 18:49     ` Josh Poimboeuf
2023-11-11 18:54       ` Josh Poimboeuf
2023-11-13 16:56       ` Namhyung Kim
2023-11-13 17:21         ` Peter Zijlstra
2023-11-13 17:48           ` Namhyung Kim
2023-11-13 18:49             ` Peter Zijlstra
2023-11-13 19:16               ` Namhyung Kim
2023-11-15 16:13         ` Namhyung Kim [this message]
2023-11-20 14:03           ` Peter Zijlstra
2023-11-09  0:41 ` [PATCH RFC 05/10] perf/x86: Add HAVE_PERF_CALLCHAIN_DEFERRED Josh Poimboeuf
2023-11-09  0:41 ` [PATCH RFC 06/10] unwind: Introduce generic user space unwinding interfaces Josh Poimboeuf
2023-11-09  0:41 ` [PATCH RFC 07/10] unwind/x86: Add HAVE_USER_UNWIND Josh Poimboeuf
2023-11-09  0:41 ` [PATCH RFC 08/10] perf/x86: Use user_unwind interface Josh Poimboeuf
2023-11-09  0:41 ` [PATCH RFC 09/10] unwind: Introduce SFrame user space unwinding Josh Poimboeuf
2023-11-09 19:31   ` Indu Bhagat
2023-11-09 19:37     ` Josh Poimboeuf
2023-11-09 19:49       ` Steven Rostedt
2023-11-09 19:53         ` Josh Poimboeuf
2023-11-09  0:41 ` [PATCH RFC 10/10] unwind/x86/64: Add HAVE_USER_UNWIND_SFRAME Josh Poimboeuf
2023-11-09  0:45 ` [PATCH RFC 00/10] perf: user space sframe unwinding Josh Poimboeuf

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=ZVTuK5VRQfY1JOEY@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=indu.bhagat@oracle.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).