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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 12 Dec 2019 15:18:05 +0000
From:   Song Liu <songliubraving@...com>
To:     Peter Zijlstra <peterz@...radead.org>
CC:     open list <linux-kernel@...r.kernel.org>,
        Kernel Team <Kernel-team@...com>,
        Arnaldo Carvalho de Melo <acme@...hat.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Alexey Budankov <alexey.budankov@...ux.intel.com>,
        Namhyung Kim <namhyung@...nel.org>, Tejun Heo <tj@...nel.org>
Subject: Re: [PATCH v8] perf: Sharing PMU counters across compatible events



> On Dec 12, 2019, at 5:42 AM, Peter Zijlstra <peterz@...radead.org> wrote:
> 
> On Fri, Dec 06, 2019 at 04:24:47PM -0800, Song Liu wrote:
>> +/* Remove dup_master for the event */
>> +static void perf_event_remove_dup(struct perf_event *event,
>> +				  struct perf_event_context *ctx)
>> +
>> +{
>> +	struct perf_event *tmp, *new_master;
>> +	int count;
>> +
>> +	/* no sharing */
>> +	if (!event->dup_master)
>> +		return;
>> +
>> +	WARN_ON_ONCE(event->state != PERF_EVENT_STATE_INACTIVE &&
>> +		     event->state != PERF_EVENT_STATE_OFF);
>> +
>> +	/* this event is not the master */
>> +	if (event->dup_master != event) {
>> +		event->dup_master = NULL;
>> +		return;
>> +	}
>> +
>> +	/* this event is the master */
>> +	perf_event_exit_dup_master(event);
>> +
>> +	count = 0;
>> +	new_master = NULL;
>> +	list_for_each_entry(tmp, &ctx->event_list, event_entry) {
>> +		WARN_ON_ONCE(tmp->state > PERF_EVENT_STATE_INACTIVE);
>> +		if (tmp->dup_master == event) {
>> +			count++;
>> +			if (!new_master)
>> +				new_master = tmp;
>> +		}
>> +	}
>> +
>> +	if (!count)
>> +		return;
>> +
>> +	if (count == 1) {
>> +		/* no more sharing */
>> +		new_master->dup_master = NULL;
>> +		return;
>> +	}
>> +
>> +	perf_event_init_dup_master(new_master);
>> +
>> +	/* switch to new_master */
>> +	list_for_each_entry(tmp, &ctx->event_list, event_entry)
>> +		if (tmp->dup_master == event)
>> +			tmp->dup_master = new_master;
>> +}
> 
> I'm thinking you can do that in a single iteration:
> 
> 	list_for_each_entry(tmp, &ctx->event_list, event_entry) {
> 		if (tmp->dup_master != event)
> 			continue;
> 
> 		if (!new_master)
> 			new_master = tmp;
> 
> 		tmp->dup_master = new_master;
> 		count++;
> 	}
> 
> 	if (count == 1)
> 		new_master->dup_master = NULL;
> 	else
> 		perf_event_init_dup_master(new_master);
> 
> Hmm?

This should work. Let me fix in v9. 

Thanks,
Song

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ