lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251013140806.GL3245006@noisy.programming.kicks-ass.net>
Date: Mon, 13 Oct 2025 16:08:06 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Thaumy Cheng <thaumy.love@...il.com>
Cc: Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Kan Liang <kan.liang@...ux.intel.com>,
	linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 RESEND] perf/core: Fix missing read event generation
 on task exit

On Thu, Oct 09, 2025 at 12:35:30AM +0800, Thaumy Cheng wrote:

> @@ -13995,13 +13997,16 @@ static void sync_child_event(struct perf_event *child_event)
>  }
> 
>  static void
> -perf_event_exit_event(struct perf_event *event,
> -		      struct perf_event_context *ctx, bool revoke)
> +perf_event_detach_event(struct perf_event *event,
> +		      struct perf_event_context *ctx, bool revoke, bool exit)
>  {
>  	struct perf_event *parent_event = event->parent;
> -	unsigned long detach_flags = DETACH_EXIT;
> +	unsigned long detach_flags = 0;
>  	unsigned int attach_state;
> 
> +	if (exit)
> +		detach_flags |= DETACH_EXIT;
> +

Urgh, at that point just pass in the right DETACH_flag directly,
something like:

perf_event_detach_event(struct perf_event *event,
			struct perf_event_context *ctx,
			unsigned long detach_flags);

	perf_event_detach_event(event, ctx, DETACH_EXIT);

	perf_event_detach_event(event, ctx, DETACH_REVOKE);



>  	if (parent_event) {
>  		/*
>  		 * Do not destroy the 'original' grouping; because of the
> @@ -14077,6 +14082,17 @@ static void perf_event_exit_task_context(struct task_struct *task, bool exit)
>  	 */
>  	mutex_lock(&ctx->mutex);
> 
> +	/*
> +	 * Report the task dead after unscheduling the events so that we
> +	 * won't get any samples after PERF_RECORD_EXIT. We can however still
> +	 * get a few PERF_RECORD_READ events.
> +	 */
> +	if (exit)
> +		perf_event_task(task, ctx, 0);
> +
> +	list_for_each_entry_safe(child_event, next, &ctx->event_list, event_entry)
> +		perf_event_detach_event(child_event, ctx, false, exit);
> +
>  	/*
>  	 * In a single ctx::lock section, de-schedule the events and detach the
>  	 * context from the task such that we cannot ever get it scheduled back

This can't be right; read the comment you moved and then look where we
unschedule the event.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ