Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752897AbbGBLRc (ORCPT ); Thu, 2 Jul 2015 07:17:32 -0400 Received: from casper.infradead.org ([85.118.1.10]:45434 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752590AbbGBLR0 (ORCPT ); Thu, 2 Jul 2015 07:17:26 -0400 Date: Thu, 2 Jul 2015 13:17:18 +0200 From: Peter Zijlstra To: Taku Izumi Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, acme@kernel.org, kan.liang@intel.com, ak@linux.intel.com, eranian@google.com Subject: Re: [PATCH] perf: Fix multi-segment problem of perf_event_intel_uncore Message-ID: <20150702111718.GZ19282@twins.programming.kicks-ass.net> References: <1435780900-23889-1-git-send-email-izumi.taku@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1435780900-23889-1-git-send-email-izumi.taku@jp.fujitsu.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1868 Lines: 63 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/