All of lore.kernel.org
 help / color / mirror / Atom feed
* [perf] perf_event_open() sometimes returning 0
@ 2020-01-02 18:55 Vince Weaver
  2020-01-02 19:22 ` Vince Weaver
  0 siblings, 1 reply; 8+ messages in thread
From: Vince Weaver @ 2020-01-02 18:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim

Hello

so I was tracking down some odd behavior in the perf_fuzzer which turns 
out to be because perf_even_open() sometimes returns 0 (indicating a file 
descriptor of 0) even though as far as I can tell stdin is still open.

Before I waste too much time trying to track this down, is this a known 
issue?

Some sample strace output:

perf_event_open({type=PERF_TYPE_RAW, size=0x78 /* PERF_ATTR_SIZE_??? */, config=0x1313, ...}, 0, 3, -1, PERF_FLAG_FD_NO_GROUP) = 0
perf_event_open({type=PERF_TYPE_SOFTWARE, size=0x78 /* PERF_ATTR_SIZE_??? */, config=PERF_COUNT_SW_DUMMY, ...}, -1, 3, -1, PERF_FLAG_FD_NO_GROUP|PERF_FLAG_FD_OUTPUT) = 0
perf_event_open({type=PERF_TYPE_SOFTWARE, size=0x78 /* PERF_ATTR_SIZE_??? */, config=PERF_COUNT_SW_PAGE_FAULTS_MIN, ...}, 158266, 2, -1, PERF_FLAG_FD_CLOEXEC) = 0
perf_event_open({type=PERF_TYPE_HW_CACHE, size=0x78 /* PERF_ATTR_SIZE_??? */, config=PERF_COUNT_HW_CACHE_DTLB|PERF_COUNT_HW_CACHE_OP_READ<<8|PERF_COUNT_HW_CACHE_RESULT_MISS<<16, ...}, 0, 4, -1, PERF_FLAG_FD_NO_GROUP|PERF_FLAG_FD_CLOEXEC) = 0
perf_event_open({type=PERF_TYPE_RAW, size=0x78 /* PERF_ATTR_SIZE_??? */, config=0, ...}, -1, 0, -1, PERF_FLAG_FD_OUTPUT|PERF_FLAG_FD_CLOEXEC) = 0

On my Haswell system (running current git) I can reproduce things with a 
single call:

	memset(&pe[0],0,sizeof(struct perf_event_attr));
	pe[0].type=PERF_TYPE_RAW;
	pe[0].size=120;
	pe[0].config=0x0ULL;
	pe[0].sample_period=0x4777c3ULL;
	pe[0].sample_type=PERF_SAMPLE_STREAM_ID; /* 200 */
	pe[0].read_format=PERF_FORMAT_TOTAL_TIME_RUNNING|PERF_FORMAT_ID|PERF_FORMAT_GROUP; /* e */
	pe[0].inherit=1;
	pe[0].exclude_hv=1;
	pe[0].exclude_idle=1;
	pe[0].enable_on_exec=1;
	pe[0].watermark=1;
	pe[0].precise_ip=0; /* arbitrary skid */
	pe[0].mmap_data=1;
	pe[0].exclude_guest=1;
	pe[0].exclude_callchain_kernel=1;
	pe[0].mmap2=1;
	pe[0].comm_exec=1;
	pe[0].context_switch=1;
	pe[0].bpf_event=1;
	pe[0].wakeup_watermark=47545;
	pe[0].bp_type=HW_BREAKPOINT_EMPTY;
	pe[0].branch_sample_type=PERF_SAMPLE_BRANCH_KERNEL|PERF_SAMPLE_BRANCH_ANY_RETURN|PERF_SAMPLE_BRANCH_COND|0x800ULL;
	pe[0].sample_regs_user=42ULL;
	pe[0].sample_stack_user=0xfffffffd;
	pe[0].aux_watermark=25443;
	pe[0].aux_sample_size=8192;

	fd[0]=perf_event_open(&pe[0],
				-1, /* current thread */
				0, /* Only cpu 0 */
				-1, /* New Group Leader */
				PERF_FLAG_FD_OUTPUT|PERF_FLAG_FD_CLOEXEC /*a*/ );


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

end of thread, other threads:[~2020-01-19 13:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-02 18:55 [perf] perf_event_open() sometimes returning 0 Vince Weaver
2020-01-02 19:22 ` Vince Weaver
2020-01-06 12:03   ` [PATCH] perf: correctly handle failed perf_get_aux_event() (was: Re: [perf] perf_event_open() sometimes returning 0) Mark Rutland
2020-01-06 18:09     ` Vince Weaver
2020-01-16 16:45       ` Vince Weaver
2020-01-18 18:05         ` [PATCH, v5.4] perf: Correctly handle failed perf_get_aux_event() Ingo Molnar
2020-01-19 13:28           ` Greg Kroah-Hartman
2020-01-07  7:39     ` [PATCH] perf: correctly handle failed perf_get_aux_event() (was: Re: [perf] perf_event_open() sometimes returning 0) Alexander Shishkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.