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]
Message-ID: <fa962d7c-2a6d-bb33-50b0-9d8f0057e8ab@linux.intel.com>
Date:   Wed, 30 Aug 2017 11:30:26 +0300
From:   Alexey Budankov <alexey.budankov@...ux.intel.com>
To:     Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Kan Liang <kan.liang@...el.com>,
        Dmitri Prokhorov <Dmitry.Prohorov@...el.com>,
        Valery Cherepennikov <valery.cherepennikov@...el.com>,
        Mark Rutland <mark.rutland@....com>,
        Stephane Eranian <eranian@...gle.com>,
        David Carrillo-Cisneros <davidcc@...gle.com>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups

On 29.08.2017 16:51, Alexander Shishkin wrote:
> Alexey Budankov <alexey.budankov@...ux.intel.com> writes:
> 
>> Now I figured that not all indexed events are always located under 
>> the root with the same cpu, and it depends on the order of insertion
>> e.g. with insertion order 01,02,03,14,15,16 we get this:
>>
>>      02
>>     /  \
>>    01  14
>>       /  \
>>      03  15
>>            \
>>            16
>>
>> and it is unclear how to iterate cpu==0 part of tree in this case.
> 
> Using this example, rb_next() should take you through the nodes in this
> order (assuming you start with 01): 01, 02, 03, 14, etc. So you iterate
> while event->cpu==cpu using rb_next() and you should be fine.

Well, indeed we get the most left leaf (03) in rb_next() for the case above.

> 
>> Iterating cpu specific subtree like this:
>>
>> #define for_each_group_event(event, group, cpu, pmu, field)	 \
>> 	for (event = rb_entry_safe(group_first(group, cpu, pmu), \
>> 				   typeof(*event), field);	 \
>> 	     event && event->cpu == cpu && event->pmu == pmu;	 \
>> 	     event = rb_entry_safe(rb_next(&event->field),	 \
>> 				   typeof(*event), field))
> 
> Afaict, this assumes that you are also ordering on event->pmu, which
> should be reflected in your _less function. And also assuming that
> group_first() is doing the right thing. Can we see the code?

I didn't do ordering by PMU for this patch set. Yet more I implemented 
groups_first() like this:

static struct perf_event *
perf_event_groups_first(struct perf_event_groups *groups, int cpu)
{
	struct perf_event *node_event = NULL;
	struct rb_node *node = NULL;

	node = groups->tree.rb_node;

	while (node) {
		node_event = container_of(node,
				struct perf_event, group_node);

		if (cpu < node_event->cpu) {
			node = node->rb_left;
		} else if (cpu > node_event->cpu) {
			node = node->rb_right;
		} else {
			node = node->rb_left;
		}
	}

	return node_event;
}

and it doesn't work as expected for case above with cpu == 1.

I corrected the code above to this:

static struct perf_event *
perf_event_groups_first(struct perf_event_groups *groups, int cpu)
{
	struct perf_event *node_event = NULL, *match = NULL;
	struct rb_node *node = NULL;

	node = groups->tree.rb_node;

	while (node) {
		node_event = container_of(node,
				struct perf_event, group_node);

		if (cpu < node_event->cpu) {
			node = node->rb_left;
		} else if (cpu > node_event->cpu) {
			node = node->rb_right;
		} else {
			match = node_event;
			node = node->rb_left;
		}
	}

	return match;
}

but now struggling with silent oopses which I guess are not 
related to multiplexing at all.

Please look at v8 for a while. It addresses your comments for v7.

> 
> Regards,
> --
> Alex
> 

Thanks,
Alexey

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ