From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 712AEC43381 for ; Sat, 23 Feb 2019 21:15:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A57420651 for ; Sat, 23 Feb 2019 21:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550956522; bh=hxR7G8WaZ8i6CJj+JXFdd4C78bJP69B/9cmCXO9HGbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IgzH1yu8H9F3kHvm1lERzkrkMg9AlkPRC8hPTrpTJsLlhO7kwN7PqZbsefJAFXg+P MM7Xz3nwNeDtzAUyYzLB6Jbspje6XNiz1EKxu5HfZqf1DYzBEjp8pUfNExjMvFo/22 YIcBmp2ZkrV5sp9GIVH7jtaqQL0Qpyq9YYN+Ss1o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729872AbfBWVPV (ORCPT ); Sat, 23 Feb 2019 16:15:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:47140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729859AbfBWVKx (ORCPT ); Sat, 23 Feb 2019 16:10:53 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1A6B20855; Sat, 23 Feb 2019 21:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550956252; bh=hxR7G8WaZ8i6CJj+JXFdd4C78bJP69B/9cmCXO9HGbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ORijPIFX8LmDB7vpiX85BzzeGeIk7bu9uvEJMruoyerfhTejcCpWNAMPyWjcpA9Le GhM7nliegS5yFrmIAPesOOe5QZD15qT423qDbfCV9njkKXyjBlLw2eGDKjm+r06U/Z LNyth9X1eNMY2Adef2KUD6Y+A7JoXM2F98J8fTTM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stephane Eranian , Andi Kleen , Kan Liang , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 4.4 03/26] perf tools: Handle TOPOLOGY headers with no CPU Date: Sat, 23 Feb 2019 16:10:24 -0500 Message-Id: <20190223211047.202725-3-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190223211047.202725-1-sashal@kernel.org> References: <20190223211047.202725-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephane Eranian [ Upstream commit 1497e804d1a6e2bd9107ddf64b0310449f4673eb ] 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 Signed-off-by: Sasha Levin --- 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 10af1e7524fbd..f1aae86f7f6c8 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -124,7 +124,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)) { @@ -171,8 +176,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: -- 2.19.1