From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752645AbbIPI5a (ORCPT ); Wed, 16 Sep 2015 04:57:30 -0400 Received: from casper.infradead.org ([85.118.1.10]:50406 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751985AbbIPI52 (ORCPT ); Wed, 16 Sep 2015 04:57:28 -0400 Date: Wed, 16 Sep 2015 10:52:05 +0200 From: Peter Zijlstra To: Taku Izumi 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 Message-ID: <20150916085205.GA3816@twins.programming.kicks-ass.net> References: <1442420232-15478-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: <1442420232-15478-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 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.