From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org,
alexander.shishkin@linux.intel.com, jolsa@redhat.com,
eranian@google.com, namhyung@kernel.org, ak@linux.intel.com
Subject: Re: [PATCH 1/5] perf/x86/intel/uncore: Parse uncore discovery tables
Date: Tue, 16 Mar 2021 08:29:44 -0400 [thread overview]
Message-ID: <23df70de-e63c-e64d-bc6e-2b4608911c29@linux.intel.com> (raw)
In-Reply-To: <YFCZEesJdSJsaxQh@hirez.programming.kicks-ass.net>
On 3/16/2021 7:40 AM, Peter Zijlstra wrote:
> On Fri, Mar 12, 2021 at 08:34:34AM -0800, kan.liang@linux.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")
>
Sure, I will use the generic rbtree framework in V2.
Thanks,
Kan
next prev parent reply other threads:[~2021-03-16 12:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 16:34 [PATCH 0/5] Uncore PMON discovery mechanism support kan.liang
2021-03-12 16:34 ` [PATCH 1/5] perf/x86/intel/uncore: Parse uncore discovery tables kan.liang
2021-03-16 11:40 ` Peter Zijlstra
2021-03-16 12:29 ` Liang, Kan [this message]
2021-03-16 11:43 ` Peter Zijlstra
2021-03-16 12:42 ` Liang, Kan
2021-03-16 14:05 ` Peter Zijlstra
2021-03-16 14:53 ` Liang, Kan
2021-03-12 16:34 ` [PATCH 2/5] perf/x86/intel/uncore: Generic support for the MSR type of uncore blocks kan.liang
2021-03-12 16:34 ` [PATCH 3/5] perf/x86/intel/uncore: Rename uncore_notifier to uncore_pci_sub_notifier kan.liang
2021-03-12 16:34 ` [PATCH 4/5] perf/x86/intel/uncore: Generic support for the PCI type of uncore blocks kan.liang
2021-03-12 16:34 ` [PATCH 5/5] perf/x86/intel/uncore: Generic support for the MMIO " kan.liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23df70de-e63c-e64d-bc6e-2b4608911c29@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.