From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1426251AbcBRK0w (ORCPT ); Thu, 18 Feb 2016 05:26:52 -0500 Received: from www.linutronix.de ([62.245.132.108]:48723 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1425927AbcBRK0t (ORCPT ); Thu, 18 Feb 2016 05:26:49 -0500 Date: Thu, 18 Feb 2016 11:25:22 +0100 (CET) From: Thomas Gleixner To: Stephane Eranian cc: Peter Zijlstra , Andi Kleen , LKML , Ingo Molnar , Borislav Petkov , Harish Chegondi , Kan Liang , Andi Kleen Subject: Re: [patch 07/11] x86/perf/uncore: Track packages not per cpu data In-Reply-To: Message-ID: References: <20160217132903.767990400@linutronix.de> <20160217133932.279611021@linutronix.de> <878u2j9gjr.fsf@tassilo.jf.intel.com> <20160217221640.GD5083@two.firstfloor.org> <20160218081320.GQ6357@twins.programming.kicks-ass.net> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stephane, On Thu, 18 Feb 2016, Stephane Eranian wrote: > On Thu, Feb 18, 2016 at 12:13 AM, Peter Zijlstra wrote: > > Now clearly, BIOS can completely wreck things and indeed report too > > small an apic_id range or whatever, and in this case we're up a creek > > without a paddle. > > > > But I think you can check for that at boot and report errors/warns > > whatever, because if you trigger this, your system is not really > > 'correct' anyway. > > > The example I was worried about is as follows, take an Ivytown system > (IVT) with 12 physical cores per package on a 2 socket system. > > Thomas's topology_max_packages() macro would return 2, for 2 packages > with CPU0..CPU47. > > But let's assume that the BIOS does some weird mappings and that the > id for socket0 is indeed 0 > but for socket1 it is 255. Then doing: > > pkg = topology_physical_package_id(); > pmu->boxes[pkg]; > > Would crash because the boxes[] has space for 2 elements and not 256. Right. It did not occur to me that this might be possible, but as I said in my reply to Peter, we can simply create logical package ids and use them. That makes us safe against BIOS tinkering. > If we know this cannot happen, then the code is fine. If we are not > sure, then I believe a check should be added > and if a mismatch is found, then the uncore PMU init code should > return an error. That's all I was trying to point > out. I think Thomas' code is indeed a good simplification. I'm glad you like it. Thanks, tglx