From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751488AbdBBNBU (ORCPT ); Thu, 2 Feb 2017 08:01:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60512 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbdBBNBT (ORCPT ); Thu, 2 Feb 2017 08:01:19 -0500 Date: Thu, 2 Feb 2017 14:01:00 +0100 From: Jiri Olsa To: Jan Stancek Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander shishkin , jolsa@kernel.org, mhiramat@kernel.org, rui teng , sukadev@linux.vnet.ibm.com Subject: Re: [PATCH] perf: fix topology test on systems with sparse CPUs Message-ID: <20170202130100.GG2305@krava> References: <290bf2031885722414cb1ae031869094a18b0580.1485794959.git.jstancek@redhat.com> <20170130184908.GB28444@krava> <20170202112913.GA2305@krava> <1953280547.2065342.1486037203674.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1953280547.2065342.1486037203674.JavaMail.zimbra@redhat.com> 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.31]); Thu, 02 Feb 2017 13:01:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 02, 2017 at 07:06:43AM -0500, Jan Stancek wrote: > > > > > When build_cpu_topo() encounters offline/absent CPUs, > > > it fails to find any sysfs entries and returns failure. > > > This leads to build_cpu_topology() and write_cpu_topology() > > > failing as well. > > > > > > Because HEADER_CPU_TOPOLOGY has not been written, read leaves > > > cpu_topology_map NULL and we get NULL ptr deref at: > > > > > > ... > > > cmd_test > > > __cmd_test > > > test_and_print > > > run_test > > > test_session_topology > > > check_cpu_topology > > > > So IIUIC that's the key issue here.. write_cpu_topology that fails > > to write the TOPO data and following readers crashing on processing > > uncomplete data? if thats the case write_cpu_topology needs to > > be fixed, instead of doing workarounds > > It's already late when you are in write_cpu_topology(), because > build_cpu_topology() returned you NULL - there's nothing to write. > That's why patch aims to fix this in build_cpu_topology(). ok, then we need to make sure we can't fail in write_cpu_topology might be another patch scope though.. we can go with your fix so far SNIP > > > 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? > > It's 28, which is the number of core_id/socket_id entries, > for CPUs 0 up to 27. ok, good jirka