From: Peter Zijlstra <peterz@infradead.org>
To: Taku Izumi <izumi.taku@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, acme@kernel.org,
hpa@zytor.com, x86@kernel.org, jolsa@redhat.com
Subject: Re: [PATCH v4] perf, x86: Fix multi-segment problem of perf_event_intel_uncore
Date: Wed, 16 Sep 2015 10:52:05 +0200 [thread overview]
Message-ID: <20150916085205.GA3816@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1442420232-15478-1-git-send-email-izumi.taku@jp.fujitsu.com>
On Thu, Sep 17, 2015 at 01:17:12AM +0900, Taku Izumi wrote:
> +struct pci2phy_map {
> + struct list_head list;
> + int segment;
> + int pbus_to_physid[256];
> +};
> +struct pci2phy_map *__find_pci2phy_map(int segment)
> +{
> + struct pci2phy_map *map, *alloc = NULL;
> +
> + lockdep_assert_held(&pci2phy_map_lock);
> +
> +lookup:
> + list_for_each_entry(map, &pci2phy_map_head, list) {
> + if (map->segment == segment)
> + goto end;
> + }
> +
> + if (!alloc) {
> + raw_spin_unlock(&pci2phy_map_lock);
> + alloc = kmalloc(sizeof(struct pci2phy_map), GFP_KERNEL);
Do we want kzalloc() ? we unconditionally initialize the list and
segment thingies, but that array is not initialized here. Or is there a
better/safer value to initialize that array with?
Looking at uncore_pcibus_to_physid(), -1 might be a good value to use.
> + raw_spin_lock(&pci2phy_map_lock);
> +
> + if (!alloc)
> + return NULL;
> +
> + goto lookup;
> + }
> +
> + map = alloc;
> + alloc = NULL;
> + map->segment = segment;
> + list_add_tail(&map->list, &pci2phy_map_head);
> +
> +end:
> + kfree(alloc);
> + return map;
> +}
Other than that I think the patch looks OK now.
prev parent reply other threads:[~2015-09-16 8:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 16:17 Taku Izumi
2015-09-16 8:52 ` Peter Zijlstra [this message]
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=20150916085205.GA3816@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=hpa@zytor.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome