Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp675243img; Fri, 22 Mar 2019 06:22:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7gtmf6+cGxfUhMM5Gh9/nMaQGVmbI71Sk82slkMuWbXJcGVZZBn6/CDb4LipiefcM/WtX X-Received: by 2002:a17:902:2702:: with SMTP id c2mr9445351plb.239.1553260934942; Fri, 22 Mar 2019 06:22:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553260934; cv=none; d=google.com; s=arc-20160816; b=GxfX+3QrxOxcwcCQ8erBzxSiqHvwXBCf8Nvhdz7V5UsF7c6yZMVctCG8xycRW6Gtw8 glSGjtg01tIHE4oMhkSklLgQgZafCQwhUmRKVLsm756nzMsDAs6XAL3j1/8yazybJ+pg p4k8bs2jzaCaGVgDoM0ZDIS0zJpA4HaVqW0b0/UtRNlqTS8XF4kb6qycj3YYTHWAEqOq 5G1jYse47c3a9Z9xyWfR+MsAZRtCvadWxyVan8de5ROX9uQZMFJ3fDWabYBYY94BnXMQ P2Qmk216U2kpiCoPMNxX+dBoEA8Ts8TFJPYZSsZ9cEdyiOjQ6wexEy4utdYi5dUWguUB 8JAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EyS+EmzJy0OOtRPBuW2s62jxOPLUCIxPiae+pKpkw+w=; b=FANHnWCojBkfJTCjWtJCaJQ6WdjgHfzpEf4GAhwc4DetnXgIptFEs6ZyuaeM+pfraO uP4ZOLTGZdpvO2LTbHONYI/DnPRVNoXcSrOmeewFLNKHxonWUB+8GCzrEXytF4IWAjL1 olge4YKNr2IRMlvrk+0qrtaghoEsjH4jPEUGc5GQ7xtyPatUmucIp2ux01g1K3rq0CA2 EJQ+ZOYnNLtOyaJHo3tLqREr0IXjH4GPzSBseCxIBn4z7rT/Nc5LNhB2DCN1o2DnDBG1 Y2jxpAtD+lGnYkg0ers5ZLlZxZH7rLu5v2lspyGTwhTgHMrKL1++ERvHvVjSy4FPIZmw 44iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=at4SCc54; 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 36si6699689pgx.547.2019.03.22.06.21.57; Fri, 22 Mar 2019 06:22:14 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=at4SCc54; 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 S1729063AbfCVNTy (ORCPT + 99 others); Fri, 22 Mar 2019 09:19:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:48988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728319AbfCVLWR (ORCPT ); Fri, 22 Mar 2019 07:22:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3B8692190A; Fri, 22 Mar 2019 11:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253736; bh=JdEacqSXaG4AIbCPUsyDaMQ988K67mrY+xCdQ4hmgec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=at4SCc54KYjPq0zJWPNi+ad4gwQ8a2BWqSWBWrx2kc6b3D83u3oHjAiyvFUygl9aP BcjEcsrS3smrpAaCdDF6peIs/U/fsxr0Ewk7myxvexvRJuWTOtWstzTtq7ItvQdgjn HvO8hrcX2xH/M9VXipEHW+x4n6RF5bssMyrfLmcU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephane Eranian , Jiri Olsa , Andi Kleen , Kan Liang , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 3.18 056/134] perf tools: Handle TOPOLOGY headers with no CPU Date: Fri, 22 Mar 2019 12:14:29 +0100 Message-Id: <20190322111214.037445813@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 c4e55b71010c..2ccfeb78fd5d 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -121,7 +121,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)) { @@ -168,8 +173,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