Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7290957imu; Tue, 22 Jan 2019 03:39:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4pcxMBNiICYIORNht74uTTyTKrjr+sgZ52GehBgRgSK3HelCBYzqSibAOrKojfNNW+Pe3n X-Received: by 2002:a63:c904:: with SMTP id o4mr31392061pgg.331.1548157189741; Tue, 22 Jan 2019 03:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548157189; cv=none; d=google.com; s=arc-20160816; b=W/Nl2x62Exw583eMQUBxECKAHulDpG9D4GlxLUZSlMe9j6J+fXpxpTpQdzYrUp5GPe x3TRe+QN9ioEmVosj52PH/DDQsJWDHuyG58l9CZQDNQrkUkDY8umI3YGvuUJ3CAtxa/Y tAMqTyeG1J8v43AB2Xj3YiRAubIp9pQ4q6zhZgvcrA1+QBM1Y57UPF3u3wZjMFIgVyj/ FYznqofn2YOFBcoIEK0lJGDqTKXv/yszgSgfy9gqOs19uEUwg5F1rd9rpJvz8UrGQAmA BMeRdhmOfvlYPXtAzgx5uw2gdVI6T7Iwwr4UTdkdhYHubi6XhqnqUVaWuWFCDnVYhal6 l9Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=XwfJCermsOKLroHnWwNUQQhuoRV0PUgwjZuBguZAYkY=; b=Nl0WRQtb7xAf/0hz17RVzq1B3lE37UW/64pvx1hCUOf7+fYiDJhmT03jo7dN4vABUB GiPziJhFtVenGENlY1Sa4kCqcgD7GyASDy3R9x3pkIlAC+vbD24UpeC88HX+7eDMcooM EPIOIOv6+fcJaTVu1tGN3cgOSuv5QyHMnhbE5903Cx3xyCdvt566Aq6NmsRb/KfyWZwl goksh0WqsOUTx9mhnFU+Uq1cbEylP/8t6na//OAEvVMFC84Bb3MC54MqNXrSwMHqyAwG M94A7z690bvclrZbgIn9UEjBG1pgQYw/pWGuDx/zYGPmGZ3abJLk7iEqUDfkckZvK0eG tLtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l186si9531727pge.205.2019.01.22.03.39.34; Tue, 22 Jan 2019 03:39:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728298AbfAVLho (ORCPT + 99 others); Tue, 22 Jan 2019 06:37:44 -0500 Received: from terminus.zytor.com ([198.137.202.136]:38103 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727922AbfAVLho (ORCPT ); Tue, 22 Jan 2019 06:37:44 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x0MBaVOE2929919 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 22 Jan 2019 03:36:31 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x0MBaU7L2929916; Tue, 22 Jan 2019 03:36:30 -0800 Date: Tue, 22 Jan 2019 03:36:30 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Stephane Eranian Message-ID: Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org, kan.liang@linux.intel.com, ak@linux.intel.com, hpa@zytor.com, acme@redhat.com, eranian@google.com, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org Reply-To: mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, eranian@google.com, acme@redhat.com, kan.liang@linux.intel.com, ak@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, jolsa@kernel.org In-Reply-To: <1547885559-1657-1-git-send-email-eranian@google.com> References: <1547885559-1657-1-git-send-email-eranian@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf tools: Handle TOPOLOGY headers with no CPU Git-Commit-ID: 1497e804d1a6e2bd9107ddf64b0310449f4673eb X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1497e804d1a6e2bd9107ddf64b0310449f4673eb Gitweb: https://git.kernel.org/tip/1497e804d1a6e2bd9107ddf64b0310449f4673eb Author: Stephane Eranian AuthorDate: Sat, 19 Jan 2019 00:12:39 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 21 Jan 2019 11:28:56 -0300 perf tools: Handle TOPOLOGY headers with no CPU This patch fixes an issue in cpumap.c when used with the TOPOLOGY header. In some configurations, some NUMA nodes may have no CPU (empty cpulist). Yet a cpumap map must be created otherwise perf abort with an error. This patch handles this case by creating a dummy map. Before: $ perf record -o - -e cycles noploop 2 | perf script -i - 0x6e8 [0x6c]: failed to process type: 80 After: $ perf record -o - -e cycles noploop 2 | perf script -i - noploop for 2 seconds Signed-off-by: Stephane Eranian Acked-by: Jiri Olsa Cc: Andi Kleen Cc: Kan Liang Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1547885559-1657-1-git-send-email-eranian@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cpumap.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 1ccbd3342069..383674f448fc 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -134,7 +134,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list) if (!cpu_list) return cpu_map__read_all_cpu_map(); - if (!isdigit(*cpu_list)) + /* + * must handle the case of empty cpumap to cover + * TOPOLOGY header for NUMA nodes with no CPU + * ( e.g., because of CPU hotplug) + */ + if (!isdigit(*cpu_list) && *cpu_list != '\0') goto out; while (isdigit(*cpu_list)) { @@ -181,8 +186,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list) if (nr_cpus > 0) cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); - else + else if (*cpu_list != '\0') cpus = cpu_map__default_new(); + else + cpus = cpu_map__dummy_new(); invalid: free(tmp_cpus); out: