lkml.org 
[lkml]   [2015]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4] perf, x86: Fix multi-segment problem of perf_event_intel_uncore
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.


\
 
 \ /
  Last update: 2015-09-16 11:21    [W:0.054 / U:1.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site