Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3971956pxb; Tue, 25 Jan 2022 00:19:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3Q3vDiW7z/jgMHA2X/rY7nMVNVKujRyhZrnGv31GZ6xOUJszwPmdQs8yioguSGHzH4a+w X-Received: by 2002:a63:bf48:: with SMTP id i8mr14257025pgo.368.1643098767393; Tue, 25 Jan 2022 00:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098767; cv=none; d=google.com; s=arc-20160816; b=Q770z2o/J1Jn95qMSlnXx1uzSTLmXbnQerlYakz68o2hXOUdAcW9oXH56wAqABrLcV ypvgBcXLuvgKo6LWx4AqMCBgTTqV9HyDTTi3TIdlETASckt8rQFztawCLTLPa/Q5wkwt iqm+uiLYoNh63vj5kjECTiVJEB09c2hyEwEd/A/ouU2lZMykQXALSR6wPWRdCFb4ah4v SHBtrzhNUDPr8M6GM4k6txDtIlCx66PWdTShcekt7cEkWBpqoVnywFxxNr+u2a4IKfYZ q8EAN9AGe1QQm+Of6+Vn7fcpZGO9M6Qo297r9hZ5S8ho6jQRvjLgW/8TqH3cUF4sECF8 CVLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mgApY7lvxO0tIiBgOt9j4Lo3aiQnHLeRaAMpeP7P3Ts=; b=JdVT8xn+KECX9cNzN9/6CQnPEyTILhdWIUWh0WUeXcCYrbnRbEbjem+a4+yCV6fuRt Z3k2eQX6MGxuOF/dEiJEs6KVLRQNkBAmMYWNuGc2yAT++JBORQ3YJGWCjm4qaqeeeeEN J7sUA+5bM95jFsApNcZPzzCJZ1UVy0dXxWLv9p/rnq4YOIwnROj5Dj5GQ3IrkF2FGGH4 cVdBSkRlCqUkebI2nfyyWZjy1Ddi/nzOf4pGuZ4pds8TQy7NBU09SjxpZDqys5tJQf0F 5dgjbj2o7k3SrTRIhZHghFwuqX5dc/4NU9C4SUTWt3xt/q/+YvikVjmkNKBhczenqOXE nA8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MsDVrIew; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g24si15901354pgj.640.2022.01.25.00.19.15; Tue, 25 Jan 2022 00:19:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MsDVrIew; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3413304AbiAYAir (ORCPT + 99 others); Mon, 24 Jan 2022 19:38:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2364468AbiAXXsP (ORCPT ); Mon, 24 Jan 2022 18:48:15 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDF07C07E30F; Mon, 24 Jan 2022 13:43:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6394FB81136; Mon, 24 Jan 2022 21:43:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 860B4C340E4; Mon, 24 Jan 2022 21:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060595; bh=4ABbKYiiDxKwGitVr08/1AJL/S5WC4/EA9Zq2J99dIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MsDVrIewpK0Cq9Rml56lTAyyef1v+s31oIybBkrMdJ7Z6/OsK3VhUjMroaHF0wZbX TQ1MxDnc2poaJsX0l4TTzDpy8wQxHf0FT/McJPOyo/o7BNQgI58FFzjGKhB0PsJTtF QeeZ8Z2byoi2x91jr1SB97Qip2vH4/4PjuLNxzX4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Rogers , Thomas Richter , Heiko Carstens , Sumanth Korikkar , Sven Schnelle , Vasily Gorbik , Arnaldo Carvalho de Melo Subject: [PATCH 5.16 1000/1039] perf cputopo: Fix CPU topology reading on s/390 Date: Mon, 24 Jan 2022 19:46:29 +0100 Message-Id: <20220124184158.895209300@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Richter commit a6e62743621ea29bea461774c0bcc68e5de59068 upstream. Commit fdf1e29b6118c18f ("perf expr: Add metric literals for topology.") fails on s390: # ./perf test -Fv 7 ... # FAILED tests/expr.c:173 #num_dies >= #num_packages ---- end ---- Simple expression parser: FAILED! # Investigating this issue leads to these functions: build_cpu_topology() +--> has_die_topology(void) { struct utsname uts; if (uname(&uts) < 0) return false; if (strncmp(uts.machine, "x86_64", 6)) return false; .... } which always returns false on s390. The caller build_cpu_topology() checks has_die_topology() return value. On false the the struct cpu_topology::die_cpu_list is not contructed and has zero entries. This leads to the failing comparison: #num_dies >= #num_packages. s390 of course has a positive number of packages. Fix this by adding s390 architecture to support CPU die list. Output after: # ./perf test -Fv 7 7: Simple expression parser : --- start --- division by zero syntax error ---- end ---- Simple expression parser: Ok # Fixes: fdf1e29b6118c18f ("perf expr: Add metric literals for topology.") Reviewed-by: Ian Rogers Signed-off-by: Thomas Richter Cc: Heiko Carstens Cc: Ian Rogers Cc: Sumanth Korikkar Cc: Sven Schnelle Cc: Vasily Gorbik Link: https://lore.kernel.org/r/20211124090343.9436-1-tmricht@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/cputopo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/tools/perf/util/cputopo.c +++ b/tools/perf/util/cputopo.c @@ -165,7 +165,8 @@ static bool has_die_topology(void) if (uname(&uts) < 0) return false; - if (strncmp(uts.machine, "x86_64", 6)) + if (strncmp(uts.machine, "x86_64", 6) && + strncmp(uts.machine, "s390x", 5)) return false; scnprintf(filename, MAXPATHLEN, DIE_CPUS_FMT,