From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751441AbdBBLaB (ORCPT ); Thu, 2 Feb 2017 06:30:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50226 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbdBBL37 (ORCPT ); Thu, 2 Feb 2017 06:29:59 -0500 Date: Thu, 2 Feb 2017 12:29:56 +0100 From: Jiri Olsa To: Jan Stancek Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, mhiramat@kernel.org, rui.teng@linux.vnet.ibm.com, sukadev@linux.vnet.ibm.com Subject: Re: [PATCH] perf: fix topology test on systems with sparse CPUs Message-ID: <20170202112956.GB2305@krava> References: <290bf2031885722414cb1ae031869094a18b0580.1485794959.git.jstancek@redhat.com> <20170130184908.GB28444@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 02 Feb 2017 11:30:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 31, 2017 at 05:03:51PM +0100, Jan Stancek wrote: SNIP > > There are 2 problems wrt. cpu_topology_map on systems with sparse CPUs: > > 1. offline/absent CPUs will have their socket_id and core_id set to -1 > which triggers: > "socket_id number is too big.You may need to upgrade the perf tool." > > 2. size of cpu_topology_map (perf_env.cpu[]) is allocated based on > _SC_NPROCESSORS_CONF, but can be indexed with CPU ids going above. > Users of perf_env.cpu[] are using CPU id as index. This can lead > to read beyond what was allocated: > ==19991== Invalid read of size 4 > ==19991== at 0x490CEB: check_cpu_topology (topology.c:69) > ==19991== by 0x490CEB: test_session_topology (topology.c:106) > ... > > For example: > _SC_NPROCESSORS_CONF == 16 > available: 2 nodes (0-1) > node 0 cpus: 0 6 8 10 16 22 24 26 > node 0 size: 12004 MB > node 0 free: 9470 MB > node 1 cpus: 1 7 9 11 23 25 27 > node 1 size: 12093 MB > node 1 free: 9406 MB > node distances: > node 0 1 > 0: 10 20 > 1: 20 10 so what's max_present_cpu in this example? jirka