Subject: linux-next: manual merge of the perf tree with the origin tree

From: Mark Brown <[email-masked]>
Date: Thu, 21 May 2026 11:18:43 +0100

Hi all,

Today's linux-next merge of the perf tree got a conflict in:

  tools/perf/builtin-trace.c

between commit:

  552636b9317c8 ("perf trace: Add beautifier script for fsmount flags")

from the origin tree and commit:

  537609924c437 ("perf trace beauty: Make beauty generated C code standalone .o files")

from the perf tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

This is obviously not the right merge but it builds.

diff --combined tools/perf/builtin-trace.c
index 48615ddccd93a,0730c1d9f0b3a..0000000000000
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@@ -60,12 -60,13 +60,13 @@@
  #include "callchain.h"
  #include "print_binary.h"
  #include "string2.h"
- #include "syscalltbl.h"
+ #include "trace/beauty/syscalltbl.h"
  #include "../perf.h"
  #include "trace_augment.h"
  #include "dwarf-regs.h"
  
  #include <errno.h>
+ #include <sys/stat.h>
  #include <inttypes.h>
  #include <poll.h>
  #include <signal.h>
@@@ -217,6 -218,7 +218,7 @@@ struct trace 
  	bool			kernel_syscallchains;
  	s16			args_alignment;
  	bool			show_tstamp;
+ 	bool			show_cpu;
  	bool			show_duration;
  	bool			show_zeros;
  	bool			show_arg_names;
@@@ -234,6 -236,16 +236,16 @@@
  	const char		*uid_str;
  };
  
+ bool trace__show_zeros(const struct trace *trace)
+ {
+ 	return trace->show_zeros;
+ }
+ 
+ struct machine *trace__host(const struct trace *trace)
+ {
+ 	return trace->host;
+ }
+ 
  static void trace__load_vmlinux_btf(struct trace *trace __maybe_unused)
  {
  #ifdef HAVE_LIBBPF_SUPPORT
@@@ -535,12 -547,12 +547,12 @@@ out_delete
  	return NULL;
  }
  
- #define perf_evsel__sc_tp_uint(evsel, name, sample) \
- 	({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
+ #define perf_evsel__sc_tp_uint(name, sample) \
+ 	({ struct syscall_tp *fields = __evsel__syscall_tp(sample->evsel); \
  	   fields->name.integer(&fields->name, sample); })
  
- #define perf_evsel__sc_tp_ptr(evsel, name, sample) \
- 	({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
+ #define perf_evsel__sc_tp_ptr(name, sample) \
+ 	({ struct syscall_tp *fields = __evsel__syscall_tp(sample->evsel); \
  	   fields->name.pointer(&fields->name, sample); })
  
  size_t strarray__scnprintf_suffix(struct strarray *sa, char *bf, size_t size, const char *intfmt, bool show_suffix, int val)
@@@ -771,9 -783,10 +783,10 @@@ static const char *bpf_cmd[] = 
  };
  static DEFINE_STRARRAY(bpf_cmd, "BPF_");
  
- #include "trace/beauty/generated/fsconfig_arrays.c"
- 
- static DEFINE_STRARRAY(fsconfig_cmds, "FSCONFIG_");
+ static const char *fsmount_flags[] = {
+ 	[1] = "CLOEXEC",
+ };
+ static DEFINE_STRARRAY(fsmount_flags, "FSMOUNT_");
  
  static const char *epoll_ctl_ops[] = { "ADD", "DEL", "MOD", };
  static DEFINE_STRARRAY_OFFSET(epoll_ctl_ops, "EPOLL_CTL_", 1);
@@@ -1123,21 -1136,6 +1136,6 @@@ static bool syscall_arg__strtoul_btf_ty
  	    .parm	= &strarray__##array, \
  	    .show_zero	= true, }
  
- #include "trace/beauty/eventfd.c"
- #include "trace/beauty/futex_op.c"
- #include "trace/beauty/futex_val3.c"
- #include "trace/beauty/mmap.c"
- #include "trace/beauty/mode_t.c"
- #include "trace/beauty/msg_flags.c"
- #include "trace/beauty/open_flags.c"
- #include "trace/beauty/perf_event_open.c"
- #include "trace/beauty/pid.c"
- #include "trace/beauty/sched_policy.c"
- #include "trace/beauty/seccomp.c"
- #include "trace/beauty/signum.c"
- #include "trace/beauty/socket_type.c"
- #include "trace/beauty/waitid_options.c"
- 
  static const struct syscall_fmt syscall_fmts[] = {
  	{ .name	    = "access",
  	  .arg = { [1] = { .scnprintf = SCA_ACCMODE,  /* mode */ }, }, },
@@@ -1197,9 -1195,7 +1195,9 @@@
  	{ .name     = "fsconfig",
  	  .arg = { [1] = STRARRAY(cmd, fsconfig_cmds), }, },
  	{ .name     = "fsmount",
 -	  .arg = { [1] = STRARRAY_FLAGS(flags, fsmount_flags),
 +	  .arg = { [1] = { .scnprintf = SCA_FSMOUNT_FLAGS, /* fsmount_flags */
 +			   .strtoul   = STUL_STRARRAYS,
 +			   .show_zero = true, },
  		   [2] = { .scnprintf = SCA_FSMOUNT_ATTR_FLAGS, /* attr_flags */ }, }, },
  	{ .name     = "fspick",
  	  .arg = { [0] = { .scnprintf = SCA_FDAT,	  /* dfd */ },
@@@ -1528,6 -1524,7 +1526,7 @@@ static size_t fprintf_duration(unsigne
   */
  struct thread_trace {
  	u64		  entry_time;
+ 	u32		  entry_cpu;
  	bool		  entry_pending;
  	unsigned long	  nr_events;
  	unsigned long	  pfmaj, pfmin;
@@@ -1890,6 -1887,27 +1889,27 @@@ static size_t trace__fprintf_tstamp(str
  	return fprintf(fp, "         ? ");
  }
  
+ /**
+  * trace__fprintf_cpu - Print the CPU ID to a given file stream
+  * @cpu: The CPU ID to print
+  * @fp: The file stream to write to
+  *
+  * Formats and prints the specified CPU ID enclosed in brackets
+  * (e.g., "[003] ") to the provided file pointer. It is used to
+  * align and display the CPU ID consistently within the trace output.
+  *
+  * Return: The number of characters printed.
+  */
+ static size_t trace__fprintf_cpu(u32 cpu, FILE *fp)
+ {
+ 	size_t printed = 0;
+ 
+ 	if (cpu != (u32)-1)
+ 		printed += fprintf(fp, "[%03u] ", cpu);
+ 
+ 	return printed;
+ }
+ 
  static pid_t workload_pid = -1;
  static volatile sig_atomic_t done = false;
  static volatile sig_atomic_t interrupted = false;
@@@ -1920,12 -1938,15 +1940,15 @@@ static size_t trace__fprintf_comm_tid(s
  }
  
  static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thread,
- 					u64 duration, bool duration_calculated, u64 tstamp, FILE *fp)
+ 					u64 duration, bool duration_calculated,
+ 					u64 tstamp, u32 cpu, FILE *fp)
  {
  	size_t printed = 0;
  
  	if (trace->show_tstamp)
  		printed = trace__fprintf_tstamp(trace, tstamp, fp);
+ 	if (trace->show_cpu && cpu != (u32)-1)
+ 		printed += trace__fprintf_cpu(cpu, fp);
  	if (trace->show_duration)
  		printed += fprintf_duration(duration, duration_calculated, fp);
  	return printed + trace__fprintf_comm_tid(trace, thread, fp);
@@@ -2579,7 -2600,7 +2602,7 @@@ static struct syscall *trace__find_sysc
  	return sc;
  }
  
- typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel,
+ typedef int (*tracepoint_handler)(struct trace *trace,
  				  union perf_event *event,
  				  struct perf_sample *sample);
  
@@@ -2704,7 -2725,9 +2727,9 @@@ static int trace__printf_interrupted_en
  	if (!ttrace->entry_pending)
  		return 0;
  
- 	printed  = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output);
+ 	printed = trace__fprintf_entry_head(trace, trace->current, 0, false,
+ 					    ttrace->entry_time, ttrace->entry_cpu,
+ 					    trace->output);
  	printed += len = fprintf(trace->output, "%s)", ttrace->entry_str);
  
  	if (len < trace->args_alignment - 4)
@@@ -2718,8 -2741,8 +2743,8 @@@
  	return printed;
  }
  
- static int trace__fprintf_sample(struct trace *trace, struct evsel *evsel,
- 				 struct perf_sample *sample, struct thread *thread)
+ static int trace__fprintf_sample(struct trace *trace, struct perf_sample *sample,
+ 				 struct thread *thread)
  {
  	int printed = 0;
  
@@@ -2727,7 -2750,7 +2752,7 @@@
  		double ts = (double)sample->time / NSEC_PER_MSEC;
  
  		printed += fprintf(trace->output, "%22s %10.3f %s %d/%d [%d]\n",
- 				   evsel__name(evsel), ts,
+ 				   evsel__name(sample->evsel), ts,
  				   thread__comm_str(thread),
  				   sample->pid, sample->tid, sample->cpu);
  	}
@@@ -2774,15 -2797,16 +2799,16 @@@ static void *syscall__augmented_args(st
  	return NULL;
  }
  
- static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
+ static int trace__sys_enter(struct trace *trace,
  			    union perf_event *event __maybe_unused,
  			    struct perf_sample *sample)
  {
+ 	struct evsel *evsel = sample->evsel;
  	char *msg;
  	void *args;
  	int printed = 0;
  	struct thread *thread;
- 	int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
+ 	int id = perf_evsel__sc_tp_uint(id, sample), err = -1;
  	int augmented_args_size = 0, e_machine;
  	void *augmented_args = NULL;
  	struct syscall *sc;
@@@ -2797,9 -2821,9 +2823,9 @@@
  	if (ttrace == NULL)
  		goto out_put;
  
- 	trace__fprintf_sample(trace, evsel, sample, thread);
+ 	trace__fprintf_sample(trace, sample, thread);
  
- 	args = perf_evsel__sc_tp_ptr(evsel, args, sample);
+ 	args = perf_evsel__sc_tp_ptr(args, sample);
  
  	if (ttrace->entry_str == NULL) {
  		ttrace->entry_str = malloc(trace__entry_str_size);
@@@ -2822,6 -2846,7 +2848,7 @@@
  	if (evsel != trace->syscalls.events.sys_enter)
  		augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size, trace->raw_augmented_syscalls_args_size);
  	ttrace->entry_time = sample->time;
+ 	ttrace->entry_cpu = sample->cpu;
  	msg = ttrace->entry_str;
  	printed += scnprintf(msg + printed, trace__entry_str_size - printed, "%s(", sc->name);
  
@@@ -2832,7 -2857,9 +2859,9 @@@
  		if (!(trace->duration_filter || trace->summary_only || trace->failure_only || trace->min_stack)) {
  			int alignment = 0;
  
- 			trace__fprintf_entry_head(trace, thread, 0, false, ttrace->entry_time, trace->output);
+ 			trace__fprintf_entry_head(trace, thread, 0, false,
+ 						  ttrace->entry_time,
+ 						  sample->cpu, trace->output);
  			printed = fprintf(trace->output, "%s)", ttrace->entry_str);
  			if (trace->args_alignment > printed)
  				alignment = trace->args_alignment - printed;
@@@ -2854,12 -2881,11 +2883,11 @@@ out_put
  	return err;
  }
  
- static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
- 				    struct perf_sample *sample)
+ static int trace__fprintf_sys_enter(struct trace *trace, struct perf_sample *sample)
  {
  	struct thread_trace *ttrace;
  	struct thread *thread;
- 	int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
+ 	int id = perf_evsel__sc_tp_uint(id, sample), err = -1;
  	struct syscall *sc;
  	char msg[1024];
  	void *args, *augmented_args = NULL;
@@@ -2869,7 -2895,7 +2897,7 @@@
  
  	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
  	e_machine = thread__e_machine(thread, trace->host, /*e_flags=*/NULL);
- 	sc = trace__syscall_info(trace, evsel, e_machine, id);
+ 	sc = trace__syscall_info(trace, sample->evsel, e_machine, id);
  	if (sc == NULL)
  		goto out_put;
  	ttrace = thread__trace(thread, trace);
@@@ -2880,7 -2906,7 +2908,7 @@@
  	if (ttrace == NULL)
  		goto out_put;
  
- 	args = perf_evsel__sc_tp_ptr(evsel, args, sample);
+ 	args = perf_evsel__sc_tp_ptr(args, sample);
  	augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size, trace->raw_augmented_syscalls_args_size);
  	printed += syscall__scnprintf_args(sc, msg, sizeof(msg), args, augmented_args, augmented_args_size, trace, thread);
  	fprintf(trace->output, "%.*s", (int)printed, msg);
@@@ -2890,10 -2916,11 +2918,11 @@@ out_put
  	return err;
  }
  
- static int trace__resolve_callchain(struct trace *trace, struct evsel *evsel,
+ static int trace__resolve_callchain(struct trace *trace,
  				    struct perf_sample *sample,
  				    struct callchain_cursor *cursor)
  {
+ 	struct evsel *evsel = sample->evsel;
  	struct addr_location al;
  	int max_stack = evsel->core.attr.sample_max_stack ?
  			evsel->core.attr.sample_max_stack :
@@@ -2904,7 -2931,7 +2933,7 @@@
  	if (machine__resolve(trace->host, &al, sample) < 0)
  		goto out;
  
- 	err = thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL, NULL, max_stack);
+ 	err = thread__resolve_callchain(al.thread, cursor, sample, NULL, NULL, max_stack);
  out:
  	addr_location__exit(&al);
  	return err;
@@@ -2920,15 -2947,16 +2949,16 @@@ static int trace__fprintf_callchain(str
  	return sample__fprintf_callchain(sample, 38, print_opts, get_tls_callchain_cursor(), symbol_conf.bt_stop_list, trace->output);
  }
  
- static int trace__sys_exit(struct trace *trace, struct evsel *evsel,
+ static int trace__sys_exit(struct trace *trace,
  			   union perf_event *event __maybe_unused,
  			   struct perf_sample *sample)
  {
+ 	struct evsel *evsel = sample->evsel;
  	long ret;
  	u64 duration = 0;
  	bool duration_calculated = false;
  	struct thread *thread;
- 	int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0, printed = 0;
+ 	int id = perf_evsel__sc_tp_uint(id, sample), err = -1, callchain_ret = 0, printed = 0;
  	int alignment = trace->args_alignment, e_machine;
  	struct syscall *sc;
  	struct thread_trace *ttrace;
@@@ -2942,9 -2970,9 +2972,9 @@@
  	if (ttrace == NULL)
  		goto out_put;
  
- 	trace__fprintf_sample(trace, evsel, sample, thread);
+ 	trace__fprintf_sample(trace, sample, thread);
  
- 	ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
+ 	ret = perf_evsel__sc_tp_uint(ret, sample);
  
  	if (trace->summary)
  		thread__update_stats(thread, ttrace, id, sample, ret, trace);
@@@ -2966,7 -2994,7 +2996,7 @@@
  	if (sample->callchain) {
  		struct callchain_cursor *cursor = get_tls_callchain_cursor();
  
- 		callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
+ 		callchain_ret = trace__resolve_callchain(trace, sample, cursor);
  		if (callchain_ret == 0) {
  			if (cursor->nr < trace->min_stack)
  				goto out;
@@@ -2977,7 -3005,9 +3007,9 @@@
  	if (trace->summary_only || (ret >= 0 && trace->failure_only))
  		goto out;
  
- 	trace__fprintf_entry_head(trace, thread, duration, duration_calculated, ttrace->entry_time, trace->output);
+ 	trace__fprintf_entry_head(trace, thread, duration,
+ 				  duration_calculated, ttrace->entry_time,
+ 				  sample->cpu, trace->output);
  
  	if (ttrace->entry_pending) {
  		printed = fprintf(trace->output, "%s", ttrace->entry_str);
@@@ -3058,7 -3088,7 +3090,7 @@@ out_put
  	return err;
  }
  
- static int trace__vfs_getname(struct trace *trace, struct evsel *evsel,
+ static int trace__vfs_getname(struct trace *trace,
  			      union perf_event *event __maybe_unused,
  			      struct perf_sample *sample)
  {
@@@ -3067,7 -3097,7 +3099,7 @@@
  	size_t filename_len, entry_str_len, to_move;
  	ssize_t remaining_space;
  	char *pos;
- 	const char *filename = evsel__rawptr(evsel, sample, "pathname");
+ 	const char *filename = perf_sample__strval(sample, "pathname");
  
  	if (!thread)
  		goto out;
@@@ -3119,11 -3149,11 +3151,11 @@@ out
  	return 0;
  }
  
- static int trace__sched_stat_runtime(struct trace *trace, struct evsel *evsel,
+ static int trace__sched_stat_runtime(struct trace *trace,
  				     union perf_event *event __maybe_unused,
  				     struct perf_sample *sample)
  {
-         u64 runtime = evsel__intval(evsel, sample, "runtime");
+ 	u64 runtime = perf_sample__intval(sample, "runtime");
  	double runtime_ms = (double)runtime / NSEC_PER_MSEC;
  	struct thread *thread = machine__findnew_thread(trace->host,
  							sample->pid,
@@@ -3141,11 -3171,11 +3173,11 @@@ out_put
  
  out_dump:
  	fprintf(trace->output, "%s: comm=%s,pid=%u,runtime=%" PRIu64 ",vruntime=%" PRIu64 ")\n",
- 	       evsel->name,
- 	       evsel__strval(evsel, sample, "comm"),
- 	       (pid_t)evsel__intval(evsel, sample, "pid"),
+ 	       sample->evsel->name,
+ 	       perf_sample__strval(sample, "comm"),
+ 	       (pid_t)perf_sample__intval(sample, "pid"),
  	       runtime,
- 	       evsel__intval(evsel, sample, "vruntime"));
+ 	       perf_sample__intval(sample, "vruntime"));
  	goto out_put;
  }
  
@@@ -3181,9 -3211,10 +3213,10 @@@ static void bpf_output__fprintf(struct 
  	++trace->nr_events_printed;
  }
  
- static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
+ static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sample *sample,
  				       struct thread *thread, void *augmented_args, int augmented_args_size)
  {
+ 	struct evsel *evsel = sample->evsel;
  	char bf[2048];
  	size_t size = sizeof(bf);
  	const struct tep_event *tp_format = evsel__tp_format(evsel);
@@@ -3251,10 -3282,11 +3284,11 @@@
  	return fprintf(trace->output, "%.*s", (int)printed, bf);
  }
  
- static int trace__event_handler(struct trace *trace, struct evsel *evsel,
+ static int trace__event_handler(struct trace *trace,
  				union perf_event *event __maybe_unused,
  				struct perf_sample *sample)
  {
+ 	struct evsel *evsel = sample->evsel;
  	struct thread *thread;
  	int callchain_ret = 0;
  
@@@ -3266,7 -3298,7 +3300,7 @@@
  	if (sample->callchain) {
  		struct callchain_cursor *cursor = get_tls_callchain_cursor();
  
- 		callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
+ 		callchain_ret = trace__resolve_callchain(trace, sample, cursor);
  		if (callchain_ret == 0) {
  			if (cursor->nr < trace->min_stack)
  				goto out;
@@@ -3277,6 -3309,9 +3311,9 @@@
  	trace__printf_interrupted_entry(trace);
  	trace__fprintf_tstamp(trace, sample->time, trace->output);
  
+ 	if (trace->show_cpu)
+ 		trace__fprintf_cpu(sample->cpu, trace->output);
+ 
  	if (trace->trace_syscalls && trace->show_duration)
  		fprintf(trace->output, "(         ): ");
  
@@@ -3284,7 -3319,7 +3321,7 @@@
  		trace__fprintf_comm_tid(trace, thread, trace->output);
  
  	if (evsel == trace->syscalls.events.bpf_output) {
- 		int id = perf_evsel__sc_tp_uint(evsel, id, sample);
+ 		int id = perf_evsel__sc_tp_uint(id, sample);
  		int e_machine = thread
  			? thread__e_machine(thread, trace->host, /*e_flags=*/NULL)
  			: EM_HOST;
@@@ -3292,7 -3327,7 +3329,7 @@@
  
  		if (sc) {
  			fprintf(trace->output, "%s(", sc->name);
- 			trace__fprintf_sys_enter(trace, evsel, sample);
+ 			trace__fprintf_sys_enter(trace, sample);
  			fputc(')', trace->output);
  			goto newline;
  		}
@@@ -3312,13 -3347,13 +3349,13 @@@
  		const struct tep_event *tp_format = evsel__tp_format(evsel);
  
  		if (tp_format && (strncmp(tp_format->name, "sys_enter_", 10) ||
- 				  trace__fprintf_sys_enter(trace, evsel, sample))) {
+ 				  trace__fprintf_sys_enter(trace, sample))) {
  			if (trace->libtraceevent_print) {
  				event_format__fprintf(tp_format, sample->cpu,
  						      sample->raw_data, sample->raw_size,
  						      trace->output);
  			} else {
- 				trace__fprintf_tp_fields(trace, evsel, sample, thread, NULL, 0);
+ 				trace__fprintf_tp_fields(trace, sample, thread, NULL, 0);
  			}
  		}
  	}
@@@ -3360,7 -3395,6 +3397,6 @@@ static void print_location(FILE *f, str
  }
  
  static int trace__pgfault(struct trace *trace,
- 			  struct evsel *evsel,
  			  union perf_event *event __maybe_unused,
  			  struct perf_sample *sample)
  {
@@@ -3377,7 -3411,7 +3413,7 @@@
  	if (sample->callchain) {
  		struct callchain_cursor *cursor = get_tls_callchain_cursor();
  
- 		callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
+ 		callchain_ret = trace__resolve_callchain(trace, sample, cursor);
  		if (callchain_ret == 0) {
  			if (cursor->nr < trace->min_stack)
  				goto out_put;
@@@ -3389,7 -3423,7 +3425,7 @@@
  	if (ttrace == NULL)
  		goto out_put;
  
- 	if (evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ) {
+ 	if (sample->evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ) {
  		ttrace->pfmaj++;
  		trace->pfmaj++;
  	} else {
@@@ -3402,10 -3436,11 +3438,11 @@@
  
  	thread__find_symbol(thread, sample->cpumode, sample->ip, &al);
  
- 	trace__fprintf_entry_head(trace, thread, 0, true, sample->time, trace->output);
+ 	trace__fprintf_entry_head(trace, thread, 0, true, sample->time,
+ 				  sample->cpu, trace->output);
  
  	fprintf(trace->output, "%sfault [",
- 		evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ?
+ 		sample->evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ?
  		"maj" : "min");
  
  	print_location(trace->output, sample, &al, false, true);
@@@ -3430,7 -3465,8 +3467,8 @@@
  	if (callchain_ret > 0)
  		trace__fprintf_callchain(trace, sample);
  	else if (callchain_ret < 0)
- 		pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evsel));
+ 		pr_err("Problem processing %s callchain, skipping...\n",
+ 		       evsel__name(sample->evsel));
  
  	++trace->nr_events_printed;
  out:
@@@ -3442,7 -3478,6 +3480,6 @@@ out_put
  }
  
  static void trace__set_base_time(struct trace *trace,
- 				 struct evsel *evsel,
  				 struct perf_sample *sample)
  {
  	/*
@@@ -3454,17 -3489,17 +3491,17 @@@
  	 * appears in our event stream (vfs_getname comes to mind).
  	 */
  	if (trace->base_time == 0 && !trace->full_time &&
- 	    (evsel->core.attr.sample_type & PERF_SAMPLE_TIME))
+ 	    (sample->evsel->core.attr.sample_type & PERF_SAMPLE_TIME))
  		trace->base_time = sample->time;
  }
  
  static int trace__process_sample(const struct perf_tool *tool,
  				 union perf_event *event,
  				 struct perf_sample *sample,
- 				 struct evsel *evsel,
  				 struct machine *machine __maybe_unused)
  {
  	struct trace *trace = container_of(tool, struct trace, tool);
+ 	struct evsel *evsel = sample->evsel;
  	struct thread *thread;
  	int err = 0;
  
@@@ -3474,11 -3509,11 +3511,11 @@@
  	if (thread && thread__is_filtered(thread))
  		goto out;
  
- 	trace__set_base_time(trace, evsel, sample);
+ 	trace__set_base_time(trace, sample);
  
  	if (handler) {
  		++trace->nr_events;
- 		handler(trace, evsel, event, sample);
+ 		handler(trace, event, sample);
  	}
  out:
  	thread__put(thread);
@@@ -3620,32 -3655,34 +3657,34 @@@ static void evlist__free_syscall_tp_fie
  static void trace__handle_event(struct trace *trace, union perf_event *event, struct perf_sample *sample)
  {
  	const u32 type = event->header.type;
- 	struct evsel *evsel;
  
  	if (type != PERF_RECORD_SAMPLE) {
  		trace__process_event(trace, trace->host, event, sample);
  		return;
  	}
  
- 	evsel = evlist__id2evsel(trace->evlist, sample->id);
- 	if (evsel == NULL) {
+ 	if (sample->evsel == NULL)
+ 		sample->evsel = evlist__id2evsel(trace->evlist, sample->id);
+ 
+ 	if (sample->evsel == NULL) {
  		fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sample->id);
  		return;
  	}
  
- 	if (evswitch__discard(&trace->evswitch, evsel))
+ 	if (evswitch__discard(&trace->evswitch, sample->evsel))
  		return;
  
- 	trace__set_base_time(trace, evsel, sample);
+ 	trace__set_base_time(trace, sample);
  
- 	if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT &&
+ 	if (sample->evsel->core.attr.type == PERF_TYPE_TRACEPOINT &&
  	    sample->raw_data == NULL) {
  		fprintf(trace->output, "%s sample with no payload for tid: %d, cpu %d, raw_size=%d, skipping...\n",
- 		       evsel__name(evsel), sample->tid,
+ 		       evsel__name(sample->evsel), sample->tid,
  		       sample->cpu, sample->raw_size);
  	} else {
- 		tracepoint_handler handler = evsel->handler;
- 		handler(trace, evsel, event, sample);
+ 		tracepoint_handler handler = sample->evsel->handler;
+ 
+ 		handler(trace, event, sample);
  	}
  
  	if (trace->nr_events_printed >= trace->max_events && trace->max_events != ULONG_MAX)
@@@ -5429,6 -5466,7 +5468,7 @@@ int cmd_trace(int argc, const char **ar
  	OPT_CALLBACK('m', "mmap-pages", &trace.opts.mmap_pages, "pages",
  		     "number of mmap data pages", evlist__parse_mmap_pages),
  	OPT_STRING('u', "uid", &trace.uid_str, "user", "user to profile"),
+ 	OPT_BOOLEAN(0, "show-cpu", &trace.show_cpu, "show cpu id"),
  	OPT_CALLBACK(0, "duration", &trace, "float",
  		     "show only events with duration > N.M ms",
  		     trace__set_duration),
@@@ -5563,6 -5601,9 +5603,9 @@@
  			goto out;
  	}
  
+ 	if (trace.show_cpu)
+ 		trace.opts.sample_cpu = true;
+ 
  	if ((nr_cgroups || trace.cgroup) && !trace.opts.target.system_wide) {
  		usage_with_options_msg(trace_usage, trace_options,
  				       "cgroup monitoring only available in system-wide mode");
@@@ -60,12 -60,13 +60,13 @@@
  #include "callchain.h"
  #include "print_binary.h"
  #include "string2.h"
- #include "syscalltbl.h"
+ #include "trace/beauty/syscalltbl.h"
  #include "../perf.h"
  #include "trace_augment.h"
  #include "dwarf-regs.h"
  
  #include <errno.h>
+ #include <sys/stat.h>
  #include <inttypes.h>
  #include <poll.h>
  #include <signal.h>
@@@ -217,6 -218,7 +218,7 @@@ struct trace 
  	bool			kernel_syscallchains;
  	s16			args_alignment;
  	bool			show_tstamp;
+ 	bool			show_cpu;
  	bool			show_duration;
  	bool			show_zeros;
  	bool			show_arg_names;
@@@ -234,6 -236,16 +236,16 @@@
  	const char		*uid_str;
  };
  
+ bool trace__show_zeros(const struct trace *trace)
+ {
+ 	return trace->show_zeros;
+ }
+ 
+ struct machine *trace__host(const struct trace *trace)
+ {
+ 	return trace->host;
+ }
+ 
  static void trace__load_vmlinux_btf(struct trace *trace __maybe_unused)
  {
  #ifdef HAVE_LIBBPF_SUPPORT
@@@ -535,12 -547,12 +547,12 @@@ out_delete
  	return NULL;
  }
  
- #define perf_evsel__sc_tp_uint(evsel, name, sample) \
- 	({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
+ #define perf_evsel__sc_tp_uint(name, sample) \
+ 	({ struct syscall_tp *fields = __evsel__syscall_tp(sample->evsel); \
  	   fields->name.integer(&fields->name, sample); })
  
- #define perf_evsel__sc_tp_ptr(evsel, name, sample) \
- 	({ struct syscall_tp *fields = __evsel__syscall_tp(evsel); \
+ #define perf_evsel__sc_tp_ptr(name, sample) \
+ 	({ struct syscall_tp *fields = __evsel__syscall_tp(sample->evsel); \
  	   fields->name.pointer(&fields->name, sample); })
  
  size_t strarray__scnprintf_suffix(struct strarray *sa, char *bf, size_t size, const char *intfmt, bool show_suffix, int val)
@@@ -771,9 -783,10 +783,10 @@@ static const char *bpf_cmd[] = 
  };
  static DEFINE_STRARRAY(bpf_cmd, "BPF_");
  
- #include "trace/beauty/generated/fsconfig_arrays.c"
- 
- static DEFINE_STRARRAY(fsconfig_cmds, "FSCONFIG_");
+ static const char *fsmount_flags[] = {
+ 	[1] = "CLOEXEC",
+ };
+ static DEFINE_STRARRAY(fsmount_flags, "FSMOUNT_");
  
  static const char *epoll_ctl_ops[] = { "ADD", "DEL", "MOD", };
  static DEFINE_STRARRAY_OFFSET(epoll_ctl_ops, "EPOLL_CTL_", 1);
@@@ -1123,21 -1136,6 +1136,6 @@@ static bool syscall_arg__strtoul_btf_ty
  	    .parm	= &strarray__##array, \
  	    .show_zero	= true, }
  
- #include "trace/beauty/eventfd.c"
- #include "trace/beauty/futex_op.c"
- #include "trace/beauty/futex_val3.c"
- #include "trace/beauty/mmap.c"
- #include "trace/beauty/mode_t.c"
- #include "trace/beauty/msg_flags.c"
- #include "trace/beauty/open_flags.c"
- #include "trace/beauty/perf_event_open.c"
- #include "trace/beauty/pid.c"
- #include "trace/beauty/sched_policy.c"
- #include "trace/beauty/seccomp.c"
- #include "trace/beauty/signum.c"
- #include "trace/beauty/socket_type.c"
- #include "trace/beauty/waitid_options.c"
- 
  static const struct syscall_fmt syscall_fmts[] = {
  	{ .name	    = "access",
  	  .arg = { [1] = { .scnprintf = SCA_ACCMODE,  /* mode */ }, }, },
@@@ -1197,9 -1195,7 +1195,9 @@@
  	{ .name     = "fsconfig",
  	  .arg = { [1] = STRARRAY(cmd, fsconfig_cmds), }, },
  	{ .name     = "fsmount",
 -	  .arg = { [1] = STRARRAY_FLAGS(flags, fsmount_flags),
 +	  .arg = { [1] = { .scnprintf = SCA_FSMOUNT_FLAGS, /* fsmount_flags */
 +			   .strtoul   = STUL_STRARRAYS,
 +			   .show_zero = true, },
  		   [2] = { .scnprintf = SCA_FSMOUNT_ATTR_FLAGS, /* attr_flags */ }, }, },
  	{ .name     = "fspick",
  	  .arg = { [0] = { .scnprintf = SCA_FDAT,	  /* dfd */ },
@@@ -1528,6 -1524,7 +1526,7 @@@ static size_t fprintf_duration(unsigne
   */
  struct thread_trace {
  	u64		  entry_time;
+ 	u32		  entry_cpu;
  	bool		  entry_pending;
  	unsigned long	  nr_events;
  	unsigned long	  pfmaj, pfmin;
@@@ -1890,6 -1887,27 +1889,27 @@@ static size_t trace__fprintf_tstamp(str
  	return fprintf(fp, "         ? ");
  }
  
+ /**
+  * trace__fprintf_cpu - Print the CPU ID to a given file stream
+  * @cpu: The CPU ID to print
+  * @fp: The file stream to write to
+  *
+  * Formats and prints the specified CPU ID enclosed in brackets
+  * (e.g., "[003] ") to the provided file pointer. It is used to
+  * align and display the CPU ID consistently within the trace output.
+  *
+  * Return: The number of characters printed.
+  */
+ static size_t trace__fprintf_cpu(u32 cpu, FILE *fp)
+ {
+ 	size_t printed = 0;
+ 
+ 	if (cpu != (u32)-1)
+ 		printed += fprintf(fp, "[%03u] ", cpu);
+ 
+ 	return printed;
+ }
+ 
  static pid_t workload_pid = -1;
  static volatile sig_atomic_t done = false;
  static volatile sig_atomic_t interrupted = false;
@@@ -1920,12 -1938,15 +1940,15 @@@ static size_t trace__fprintf_comm_tid(s
  }
  
  static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thread,
- 					u64 duration, bool duration_calculated, u64 tstamp, FILE *fp)
+ 					u64 duration, bool duration_calculated,
+ 					u64 tstamp, u32 cpu, FILE *fp)
  {
  	size_t printed = 0;
  
  	if (trace->show_tstamp)
  		printed = trace__fprintf_tstamp(trace, tstamp, fp);
+ 	if (trace->show_cpu && cpu != (u32)-1)
+ 		printed += trace__fprintf_cpu(cpu, fp);
  	if (trace->show_duration)
  		printed += fprintf_duration(duration, duration_calculated, fp);
  	return printed + trace__fprintf_comm_tid(trace, thread, fp);
@@@ -2579,7 -2600,7 +2602,7 @@@ static struct syscall *trace__find_sysc
  	return sc;
  }
  
- typedef int (*tracepoint_handler)(struct trace *trace, struct evsel *evsel,
+ typedef int (*tracepoint_handler)(struct trace *trace,
  				  union perf_event *event,
  				  struct perf_sample *sample);
  
@@@ -2704,7 -2725,9 +2727,9 @@@ static int trace__printf_interrupted_en
  	if (!ttrace->entry_pending)
  		return 0;
  
- 	printed  = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output);
+ 	printed = trace__fprintf_entry_head(trace, trace->current, 0, false,
+ 					    ttrace->entry_time, ttrace->entry_cpu,
+ 					    trace->output);
  	printed += len = fprintf(trace->output, "%s)", ttrace->entry_str);
  
  	if (len < trace->args_alignment - 4)
@@@ -2718,8 -2741,8 +2743,8 @@@
  	return printed;
  }
  
- static int trace__fprintf_sample(struct trace *trace, struct evsel *evsel,
- 				 struct perf_sample *sample, struct thread *thread)
+ static int trace__fprintf_sample(struct trace *trace, struct perf_sample *sample,
+ 				 struct thread *thread)
  {
  	int printed = 0;
  
@@@ -2727,7 -2750,7 +2752,7 @@@
  		double ts = (double)sample->time / NSEC_PER_MSEC;
  
  		printed += fprintf(trace->output, "%22s %10.3f %s %d/%d [%d]\n",
- 				   evsel__name(evsel), ts,
+ 				   evsel__name(sample->evsel), ts,
  				   thread__comm_str(thread),
  				   sample->pid, sample->tid, sample->cpu);
  	}
@@@ -2774,15 -2797,16 +2799,16 @@@ static void *syscall__augmented_args(st
  	return NULL;
  }
  
- static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
+ static int trace__sys_enter(struct trace *trace,
  			    union perf_event *event __maybe_unused,
  			    struct perf_sample *sample)
  {
+ 	struct evsel *evsel = sample->evsel;
  	char *msg;
  	void *args;
  	int printed = 0;
  	struct thread *thread;
- 	int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
+ 	int id = perf_evsel__sc_tp_uint(id, sample), err = -1;
  	int augmented_args_size = 0, e_machine;
  	void *augmented_args = NULL;
  	struct syscall *sc;
@@@ -2797,9 -2821,9 +2823,9 @@@
  	if (ttrace == NULL)
  		goto out_put;
  
- 	trace__fprintf_sample(trace, evsel, sample, thread);
+ 	trace__fprintf_sample(trace, sample, thread);
  
- 	args = perf_evsel__sc_tp_ptr(evsel, args, sample);
+ 	args = perf_evsel__sc_tp_ptr(args, sample);
  
  	if (ttrace->entry_str == NULL) {
  		ttrace->entry_str = malloc(trace__entry_str_size);
@@@ -2822,6 -2846,7 +2848,7 @@@
  	if (evsel != trace->syscalls.events.sys_enter)
  		augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size, trace->raw_augmented_syscalls_args_size);
  	ttrace->entry_time = sample->time;
+ 	ttrace->entry_cpu = sample->cpu;
  	msg = ttrace->entry_str;
  	printed += scnprintf(msg + printed, trace__entry_str_size - printed, "%s(", sc->name);
  
@@@ -2832,7 -2857,9 +2859,9 @@@
  		if (!(trace->duration_filter || trace->summary_only || trace->failure_only || trace->min_stack)) {
  			int alignment = 0;
  
- 			trace__fprintf_entry_head(trace, thread, 0, false, ttrace->entry_time, trace->output);
+ 			trace__fprintf_entry_head(trace, thread, 0, false,
+ 						  ttrace->entry_time,
+ 						  sample->cpu, trace->output);
  			printed = fprintf(trace->output, "%s)", ttrace->entry_str);
  			if (trace->args_alignment > printed)
  				alignment = trace->args_alignment - printed;
@@@ -2854,12 -2881,11 +2883,11 @@@ out_put
  	return err;
  }
  
- static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
- 				    struct perf_sample *sample)
+ static int trace__fprintf_sys_enter(struct trace *trace, struct perf_sample *sample)
  {
  	struct thread_trace *ttrace;
  	struct thread *thread;
- 	int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
+ 	int id = perf_evsel__sc_tp_uint(id, sample), err = -1;
  	struct syscall *sc;
  	char msg[1024];
  	void *args, *augmented_args = NULL;
@@@ -2869,7 -2895,7 +2897,7 @@@
  
  	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
  	e_machine = thread__e_machine(thread, trace->host, /*e_flags=*/NULL);
- 	sc = trace__syscall_info(trace, evsel, e_machine, id);
+ 	sc = trace__syscall_info(trace, sample->evsel, e_machine, id);
  	if (sc == NULL)
  		goto out_put;
  	ttrace = thread__trace(thread, trace);
@@@ -2880,7 -2906,7 +2908,7 @@@
  	if (ttrace == NULL)
  		goto out_put;
  
- 	args = perf_evsel__sc_tp_ptr(evsel, args, sample);
+ 	args = perf_evsel__sc_tp_ptr(args, sample);
  	augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size, trace->raw_augmented_syscalls_args_size);
  	printed += syscall__scnprintf_args(sc, msg, sizeof(msg), args, augmented_args, augmented_args_size, trace, thread);
  	fprintf(trace->output, "%.*s", (int)printed, msg);
@@@ -2890,10 -2916,11 +2918,11 @@@ out_put
  	return err;
  }
  
- static int trace__resolve_callchain(struct trace *trace, struct evsel *evsel,
+ static int trace__resolve_callchain(struct trace *trace,
  				    struct perf_sample *sample,
  				    struct callchain_cursor *cursor)
  {
+ 	struct evsel *evsel = sample->evsel;
  	struct addr_location al;
  	int max_stack = evsel->core.attr.sample_max_stack ?
  			evsel->core.attr.sample_max_stack :
@@@ -2904,7 -2931,7 +2933,7 @@@
  	if (machine__resolve(trace->host, &al, sample) < 0)
  		goto out;
  
- 	err = thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL, NULL, max_stack);
+ 	err = thread__resolve_callchain(al.thread, cursor, sample, NULL, NULL, max_stack);
  out:
  	addr_location__exit(&al);
  	return err;
@@@ -2920,15 -2947,16 +2949,16 @@@ static int trace__fprintf_callchain(str
  	return sample__fprintf_callchain(sample, 38, print_opts, get_tls_callchain_cursor(), symbol_conf.bt_stop_list, trace->output);
  }
  
- static int trace__sys_exit(struct trace *trace, struct evsel *evsel,
+ static int trace__sys_exit(struct trace *trace,
  			   union perf_event *event __maybe_unused,
  			   struct perf_sample *sample)
  {
+ 	struct evsel *evsel = sample->evsel;
  	long ret;
  	u64 duration = 0;
  	bool duration_calculated = false;
  	struct thread *thread;
- 	int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1, callchain_ret = 0, printed = 0;
+ 	int id = perf_evsel__sc_tp_uint(id, sample), err = -1, callchain_ret = 0, printed = 0;
  	int alignment = trace->args_alignment, e_machine;
  	struct syscall *sc;
  	struct thread_trace *ttrace;
@@@ -2942,9 -2970,9 +2972,9 @@@
  	if (ttrace == NULL)
  		goto out_put;
  
- 	trace__fprintf_sample(trace, evsel, sample, thread);
+ 	trace__fprintf_sample(trace, sample, thread);
  
- 	ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
+ 	ret = perf_evsel__sc_tp_uint(ret, sample);
  
  	if (trace->summary)
  		thread__update_stats(thread, ttrace, id, sample, ret, trace);
@@@ -2966,7 -2994,7 +2996,7 @@@
  	if (sample->callchain) {
  		struct callchain_cursor *cursor = get_tls_callchain_cursor();
  
- 		callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
+ 		callchain_ret = trace__resolve_callchain(trace, sample, cursor);
  		if (callchain_ret == 0) {
  			if (cursor->nr < trace->min_stack)
  				goto out;
@@@ -2977,7 -3005,9 +3007,9 @@@
  	if (trace->summary_only || (ret >= 0 && trace->failure_only))
  		goto out;
  
- 	trace__fprintf_entry_head(trace, thread, duration, duration_calculated, ttrace->entry_time, trace->output);
+ 	trace__fprintf_entry_head(trace, thread, duration,
+ 				  duration_calculated, ttrace->entry_time,
+ 				  sample->cpu, trace->output);
  
  	if (ttrace->entry_pending) {
  		printed = fprintf(trace->output, "%s", ttrace->entry_str);
@@@ -3058,7 -3088,7 +3090,7 @@@ out_put
  	return err;
  }
  
- static int trace__vfs_getname(struct trace *trace, struct evsel *evsel,
+ static int trace__vfs_getname(struct trace *trace,
  			      union perf_event *event __maybe_unused,
  			      struct perf_sample *sample)
  {
@@@ -3067,7 -3097,7 +3099,7 @@@
  	size_t filename_len, entry_str_len, to_move;
  	ssize_t remaining_space;
  	char *pos;
- 	const char *filename = evsel__rawptr(evsel, sample, "pathname");
+ 	const char *filename = perf_sample__strval(sample, "pathname");
  
  	if (!thread)
  		goto out;
@@@ -3119,11 -3149,11 +3151,11 @@@ out
  	return 0;
  }
  
- static int trace__sched_stat_runtime(struct trace *trace, struct evsel *evsel,
+ static int trace__sched_stat_runtime(struct trace *trace,
  				     union perf_event *event __maybe_unused,
  				     struct perf_sample *sample)
  {
-         u64 runtime = evsel__intval(evsel, sample, "runtime");
+ 	u64 runtime = perf_sample__intval(sample, "runtime");
  	double runtime_ms = (double)runtime / NSEC_PER_MSEC;
  	struct thread *thread = machine__findnew_thread(trace->host,
  							sample->pid,
@@@ -3141,11 -3171,11 +3173,11 @@@ out_put
  
  out_dump:
  	fprintf(trace->output, "%s: comm=%s,pid=%u,runtime=%" PRIu64 ",vruntime=%" PRIu64 ")\n",
- 	       evsel->name,
- 	       evsel__strval(evsel, sample, "comm"),
- 	       (pid_t)evsel__intval(evsel, sample, "pid"),
+ 	       sample->evsel->name,
+ 	       perf_sample__strval(sample, "comm"),
+ 	       (pid_t)perf_sample__intval(sample, "pid"),
  	       runtime,
- 	       evsel__intval(evsel, sample, "vruntime"));
+ 	       perf_sample__intval(sample, "vruntime"));
  	goto out_put;
  }
  
@@@ -3181,9 -3211,10 +3213,10 @@@ static void bpf_output__fprintf(struct 
  	++trace->nr_events_printed;
  }
  
- static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel, struct perf_sample *sample,
+ static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sample *sample,
  				       struct thread *thread, void *augmented_args, int augmented_args_size)
  {
+ 	struct evsel *evsel = sample->evsel;
  	char bf[2048];
  	size_t size = sizeof(bf);
  	const struct tep_event *tp_format = evsel__tp_format(evsel);
@@@ -3251,10 -3282,11 +3284,11 @@@
  	return fprintf(trace->output, "%.*s", (int)printed, bf);
  }
  
- static int trace__event_handler(struct trace *trace, struct evsel *evsel,
+ static int trace__event_handler(struct trace *trace,
  				union perf_event *event __maybe_unused,
  				struct perf_sample *sample)
  {
+ 	struct evsel *evsel = sample->evsel;
  	struct thread *thread;
  	int callchain_ret = 0;
  
@@@ -3266,7 -3298,7 +3300,7 @@@
  	if (sample->callchain) {
  		struct callchain_cursor *cursor = get_tls_callchain_cursor();
  
- 		callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
+ 		callchain_ret = trace__resolve_callchain(trace, sample, cursor);
  		if (callchain_ret == 0) {
  			if (cursor->nr < trace->min_stack)
  				goto out;
@@@ -3277,6 -3309,9 +3311,9 @@@
  	trace__printf_interrupted_entry(trace);
  	trace__fprintf_tstamp(trace, sample->time, trace->output);
  
+ 	if (trace->show_cpu)
+ 		trace__fprintf_cpu(sample->cpu, trace->output);
+ 
  	if (trace->trace_syscalls && trace->show_duration)
  		fprintf(trace->output, "(         ): ");
  
@@@ -3284,7 -3319,7 +3321,7 @@@
  		trace__fprintf_comm_tid(trace, thread, trace->output);
  
  	if (evsel == trace->syscalls.events.bpf_output) {
- 		int id = perf_evsel__sc_tp_uint(evsel, id, sample);
+ 		int id = perf_evsel__sc_tp_uint(id, sample);
  		int e_machine = thread
  			? thread__e_machine(thread, trace->host, /*e_flags=*/NULL)
  			: EM_HOST;
@@@ -3292,7 -3327,7 +3329,7 @@@
  
  		if (sc) {
  			fprintf(trace->output, "%s(", sc->name);
- 			trace__fprintf_sys_enter(trace, evsel, sample);
+ 			trace__fprintf_sys_enter(trace, sample);
  			fputc(')', trace->output);
  			goto newline;
  		}
@@@ -3312,13 -3347,13 +3349,13 @@@
  		const struct tep_event *tp_format = evsel__tp_format(evsel);
  
  		if (tp_format && (strncmp(tp_format->name, "sys_enter_", 10) ||
- 				  trace__fprintf_sys_enter(trace, evsel, sample))) {
+ 				  trace__fprintf_sys_enter(trace, sample))) {
  			if (trace->libtraceevent_print) {
  				event_format__fprintf(tp_format, sample->cpu,
  						      sample->raw_data, sample->raw_size,
  						      trace->output);
  			} else {
- 				trace__fprintf_tp_fields(trace, evsel, sample, thread, NULL, 0);
+ 				trace__fprintf_tp_fields(trace, sample, thread, NULL, 0);
  			}
  		}
  	}
@@@ -3360,7 -3395,6 +3397,6 @@@ static void print_location(FILE *f, str
  }
  
  static int trace__pgfault(struct trace *trace,
- 			  struct evsel *evsel,
  			  union perf_event *event __maybe_unused,
  			  struct perf_sample *sample)
  {
@@@ -3377,7 -3411,7 +3413,7 @@@
  	if (sample->callchain) {
  		struct callchain_cursor *cursor = get_tls_callchain_cursor();
  
- 		callchain_ret = trace__resolve_callchain(trace, evsel, sample, cursor);
+ 		callchain_ret = trace__resolve_callchain(trace, sample, cursor);
  		if (callchain_ret == 0) {
  			if (cursor->nr < trace->min_stack)
  				goto out_put;
@@@ -3389,7 -3423,7 +3425,7 @@@
  	if (ttrace == NULL)
  		goto out_put;
  
- 	if (evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ) {
+ 	if (sample->evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ) {
  		ttrace->pfmaj++;
  		trace->pfmaj++;
  	} else {
@@@ -3402,10 -3436,11 +3438,11 @@@
  
  	thread__find_symbol(thread, sample->cpumode, sample->ip, &al);
  
- 	trace__fprintf_entry_head(trace, thread, 0, true, sample->time, trace->output);
+ 	trace__fprintf_entry_head(trace, thread, 0, true, sample->time,
+ 				  sample->cpu, trace->output);
  
  	fprintf(trace->output, "%sfault [",
- 		evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ?
+ 		sample->evsel->core.attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ ?
  		"maj" : "min");
  
  	print_location(trace->output, sample, &al, false, true);
@@@ -3430,7 -3465,8 +3467,8 @@@
  	if (callchain_ret > 0)
  		trace__fprintf_callchain(trace, sample);
  	else if (callchain_ret < 0)
- 		pr_err("Problem processing %s callchain, skipping...\n", evsel__name(evsel));
+ 		pr_err("Problem processing %s callchain, skipping...\n",
+ 		       evsel__name(sample->evsel));
  
  	++trace->nr_events_printed;
  out:
@@@ -3442,7 -3478,6 +3480,6 @@@ out_put
  }
  
  static void trace__set_base_time(struct trace *trace,
- 				 struct evsel *evsel,
  				 struct perf_sample *sample)
  {
  	/*
@@@ -3454,17 -3489,17 +3491,17 @@@
  	 * appears in our event stream (vfs_getname comes to mind).
  	 */
  	if (trace->base_time == 0 && !trace->full_time &&
- 	    (evsel->core.attr.sample_type & PERF_SAMPLE_TIME))
+ 	    (sample->evsel->core.attr.sample_type & PERF_SAMPLE_TIME))
  		trace->base_time = sample->time;
  }
  
  static int trace__process_sample(const struct perf_tool *tool,
  				 union perf_event *event,
  				 struct perf_sample *sample,
- 				 struct evsel *evsel,
  				 struct machine *machine __maybe_unused)
  {
  	struct trace *trace = container_of(tool, struct trace, tool);
+ 	struct evsel *evsel = sample->evsel;
  	struct thread *thread;
  	int err = 0;
  
@@@ -3474,11 -3509,11 +3511,11 @@@
  	if (thread && thread__is_filtered(thread))
  		goto out;
  
- 	trace__set_base_time(trace, evsel, sample);
+ 	trace__set_base_time(trace, sample);
  
  	if (handler) {
  		++trace->nr_events;
- 		handler(trace, evsel, event, sample);
+ 		handler(trace, event, sample);
  	}
  out:
  	thread__put(thread);
@@@ -3620,32 -3655,34 +3657,34 @@@ static void evlist__free_syscall_tp_fie
  static void trace__handle_event(struct trace *trace, union perf_event *event, struct perf_sample *sample)
  {
  	const u32 type = event->header.type;
- 	struct evsel *evsel;
  
  	if (type != PERF_RECORD_SAMPLE) {
  		trace__process_event(trace, trace->host, event, sample);
  		return;
  	}
  
- 	evsel = evlist__id2evsel(trace->evlist, sample->id);
- 	if (evsel == NULL) {
+ 	if (sample->evsel == NULL)
+ 		sample->evsel = evlist__id2evsel(trace->evlist, sample->id);
+ 
+ 	if (sample->evsel == NULL) {
  		fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sample->id);
  		return;
  	}
  
- 	if (evswitch__discard(&trace->evswitch, evsel))
+ 	if (evswitch__discard(&trace->evswitch, sample->evsel))
  		return;
  
- 	trace__set_base_time(trace, evsel, sample);
+ 	trace__set_base_time(trace, sample);
  
- 	if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT &&
+ 	if (sample->evsel->core.attr.type == PERF_TYPE_TRACEPOINT &&
  	    sample->raw_data == NULL) {
  		fprintf(trace->output, "%s sample with no payload for tid: %d, cpu %d, raw_size=%d, skipping...\n",
- 		       evsel__name(evsel), sample->tid,
+ 		       evsel__name(sample->evsel), sample->tid,
  		       sample->cpu, sample->raw_size);
  	} else {
- 		tracepoint_handler handler = evsel->handler;
- 		handler(trace, evsel, event, sample);
+ 		tracepoint_handler handler = sample->evsel->handler;
+ 
+ 		handler(trace, event, sample);
  	}
  
  	if (trace->nr_events_printed >= trace->max_events && trace->max_events != ULONG_MAX)
@@@ -5429,6 -5466,7 +5468,7 @@@ int cmd_trace(int argc, const char **ar
  	OPT_CALLBACK('m', "mmap-pages", &trace.opts.mmap_pages, "pages",
  		     "number of mmap data pages", evlist__parse_mmap_pages),
  	OPT_STRING('u', "uid", &trace.uid_str, "user", "user to profile"),
+ 	OPT_BOOLEAN(0, "show-cpu", &trace.show_cpu, "show cpu id"),
  	OPT_CALLBACK(0, "duration", &trace, "float",
  		     "show only events with duration > N.M ms",
  		     trace__set_duration),
@@@ -5563,6 -5601,9 +5603,9 @@@
  			goto out;
  	}
  
+ 	if (trace.show_cpu)
+ 		trace.opts.sample_cpu = true;
+ 
  	if ((nr_cgroups || trace.cgroup) && !trace.opts.target.system_wide) {
  		usage_with_options_msg(trace_usage, trace_options,
  				       "cgroup monitoring only available in system-wide mode");