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: <20200108220103.GB12995@krava>
Date:   Wed, 8 Jan 2020 23:01:03 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Mark Rutland <mark.rutland@....com>,
        Stephane Eranian <eranian@...gle.com>,
        LKML <linux-kernel@...r.kernel.org>,
        linux-perf-users@...r.kernel.org
Subject: Re: [PATCH 4/9] perf tools: Maintain cgroup hierarchy

On Tue, Jan 07, 2020 at 10:34:56PM +0900, Namhyung Kim wrote:

SNIP

> +	while (*p != NULL) {
> +		parent = *p;
> +		cgrp = rb_entry(parent, struct cgroup, node);
> +
> +		if (cgrp->id == id)
> +			return cgrp;
> +
> +		if (cgrp->id < id)
> +			p = &(*p)->rb_left;
> +		else
> +			p = &(*p)->rb_right;
> +	}
> +
> +	cgrp = malloc(sizeof(*cgrp));
> +	if (cgrp == NULL)
> +		return NULL;
> +
> +	cgrp->name = strdup(path);
> +	if (cgrp->name == NULL) {
> +		free(cgrp);
> +		return NULL;
> +	}
> +
> +	cgrp->fd = -1;
> +	cgrp->id = id;
> +	refcount_set(&cgrp->refcnt, 1);
> +
> +	rb_link_node(&cgrp->node, parent, p);
> +	rb_insert_color(&cgrp->node, &cgroup_tree);
> +
> +	return cgrp;
> +}
> +
> +struct cgroup *cgroup__find_by_path(const char *path)
> +{
> +	struct rb_node *node;
> +
> +	node = rb_first(&cgroup_tree);
> +	while (node) {
> +		struct cgroup *cgrp = rb_entry(node, struct cgroup, node);
> +
> +		if (!strcmp(cgrp->name, path))
> +			return cgrp;

you have it sorted on ids, but only search by path,
why don't we sort it on path right away?

jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ