Re: [PATCH] perf: Fix multi-segment problem of perf_event_intel_uncore
From: Peter Zijlstra
Date: Thu Jul 02 2015 - 07:17:35 EST
On Thu, Jul 02, 2015 at 05:01:40AM +0900, Taku Izumi wrote:
> + raw_spin_lock(&pci2phy_map_lock);
> + list_for_each_entry(map, &pci2phy_map_head, list) {
> + if (map->segment == pci_domain_nr(pdev->bus)) {
> + phys_id = map->pbus_to_physid[pdev->bus->number];
> + break;
> + }
> + }
> + raw_spin_unlock(&pci2phy_map_lock);
> + raw_spin_lock(&pci2phy_map_lock);
> + list_for_each_entry(map, &pci2phy_map_head, list) {
> + if (map->segment == pci_domain_nr(pdev->bus)) {
> + phys_id = map->pbus_to_physid[pdev->bus->number];
> + break;
> + }
> + }
> + raw_spin_unlock(&pci2phy_map_lock);
> + raw_spin_lock(&pci2phy_map_lock);
> + list_for_each_entry(map, &pci2phy_map_head, list) {
> + if (map->segment == segment) {
> + found = true;
> + break;
> + }
> + }
> + if (!found) {
> + map = kmalloc(sizeof(struct pci2phy_map), GFP_KERNEL);
> + if (map) {
> + map->segment = segment;
> + map->pbus_to_physid[bus] = 0;
> + list_add_tail(&map->list, &pci2phy_map_head);
> + }
> + } else {
> + map->pbus_to_physid[bus] = 0;
> + }
> + raw_spin_unlock(&pci2phy_map_lock);
> + raw_spin_lock(&pci2phy_map_lock);
> + list_for_each_entry(map, &pci2phy_map_head, list) {
> + if (map->segment == segment) {
> + found = true;
> + break;
> + }
> + }
> + if (!found) {
> + map = kmalloc(sizeof(struct pci2phy_map), GFP_KERNEL);
> + if (!map) {
> + err = -ENOMEM;
> + break;
> + }
> + map->segment = segment;
> + list_add_tail(&map->list, &pci2phy_map_head);
> + }
> + raw_spin_unlock(&pci2phy_map_lock);
You'd think they invent something to avoid repetitions like that.. Oh
wait..
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/