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: <YFCZEesJdSJsaxQh@hirez.programming.kicks-ass.net>
Date:   Tue, 16 Mar 2021 12:40:01 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     kan.liang@...ux.intel.com
Cc:     mingo@...nel.org, acme@...hat.com, linux-kernel@...r.kernel.org,
        alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
        eranian@...gle.com, namhyung@...nel.org, ak@...ux.intel.com
Subject: Re: [PATCH 1/5] perf/x86/intel/uncore: Parse uncore discovery tables

On Fri, Mar 12, 2021 at 08:34:34AM -0800, kan.liang@...ux.intel.com wrote:
> +static struct intel_uncore_discovery_type *
> +search_uncore_discovery_type(u16 type_id)
> +{
> +	struct rb_node *node = discovery_tables.rb_node;
> +	struct intel_uncore_discovery_type *type;
> +
> +	while (node) {
> +		type = rb_entry(node, struct intel_uncore_discovery_type, node);
> +
> +		if (type->type > type_id)
> +			node = node->rb_left;
> +		else if (type->type < type_id)
> +			node = node->rb_right;
> +		else
> +			return type;
> +	}
> +
> +	return NULL;
> +}
> +
> +static struct intel_uncore_discovery_type *
> +add_uncore_discovery_type(struct uncore_unit_discovery *unit)
> +{
> +	struct intel_uncore_discovery_type *type, *cur;
> +	struct rb_node **node = &discovery_tables.rb_node;
> +	struct rb_node *parent = *node;
> +
> +	if (unit->access_type >= UNCORE_ACCESS_MAX) {
> +		pr_warn("Unsupported access type %d\n", unit->access_type);
> +		return NULL;
> +	}
> +
> +	type = kzalloc(sizeof(struct intel_uncore_discovery_type), GFP_KERNEL);
> +	if (!type)
> +		return NULL;
> +
> +	type->box_ctrl_die = kcalloc(__uncore_max_dies, sizeof(u64), GFP_KERNEL);
> +	if (!type->box_ctrl_die)
> +		goto free_type;
> +
> +	type->access_type = unit->access_type;
> +	num_discovered_types[type->access_type]++;
> +	type->type = unit->box_type;
> +
> +	while (*node) {
> +		parent = *node;
> +		cur = rb_entry(parent, struct intel_uncore_discovery_type, node);
> +
> +		if (cur->type > type->type)
> +			node = &parent->rb_left;
> +		else
> +			node = &parent->rb_right;
> +	}
> +
> +	rb_link_node(&type->node, parent, node);
> +	rb_insert_color(&type->node, &discovery_tables);
> +
> +	return type;
> +
> +free_type:
> +	kfree(type);
> +
> +	return NULL;
> +
> +}

I'm thinking this can use some of this:

  2d24dd5798d0 ("rbtree: Add generic add and find helpers")

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ