Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2067471imm; Mon, 28 May 2018 00:37:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr/KTomTcmI6cqUqDe6t+cR6oAdIVpkIUFuM4GS+x4/p0u7Y1w0KVp8tUtKfZgwY5HQKt8+ X-Received: by 2002:a65:6119:: with SMTP id z25-v6mr9738104pgu.139.1527493061040; Mon, 28 May 2018 00:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527493061; cv=none; d=google.com; s=arc-20160816; b=MygekRaZLeOKuDbmcX1Kf60k2hy2e6KG8aUd7O2QCMN0Cdkf6ATJuFVXxRdmOLmf6p u+3AohfPlwDWSIssVetzbc10abjh1EdjOT/VhW9EQrVH3EiwV+HiC3gJl4FKAInlpcFt YcagvK1/1pHqrjgq16CrS8x8fkiBv615wiXHgNIB0ekfMNBlTcjBeoTpf2kFOUsJOG0K OU9olQaRKWdemuSW//RJ+HkWtLjlUFCkfwCvPrF8sI5JNK6rVBr0UJQhREdOodS8VD/K xssMWvSDLBaKB+3v0JI2bMIatHbYiK4foZof4vT8X2OMltWXnYnmsEwTh+gHuHPrNhJg AwLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8wUu7ff7/sAIlr7kmQKxZzv5MVeS5MzrN0s8GpQ+UPU=; b=OpkhlQcUcKg1l2QBgXQaI+vagu+op5i9I69aSW/N5mJEiY3BRyXlCoKVhNFSv8yKVV yIJgEaj84qoWG/lkcN9Y5yvKB+xUH1CQ+/+YGs2VNK3gq/fu0R/xMDswSjgT5dIcjVBw 9NHjquBftHMNodicA6RdhvpM3v5Ccg3eWZGEBx0uNaSzohTrYuldi9C6936mEG/z8zMf hHoSXMiHocxS1EeQP2ulUNxCfX7rGrsxxrk3PUJgLLZcoKDwnoD/A2dOV2Oj6cfQkVdj kUZ8EzUTO1qgaODeMhXPE9lcjv8tYi7Dz+1/+AUIHItJcYQH8Kw9Fzd47CmjuyccjKQx xQUQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si29537002pla.565.2018.05.28.00.37.26; Mon, 28 May 2018 00:37:41 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753826AbeE1HhK (ORCPT + 99 others); Mon, 28 May 2018 03:37:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53238 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753612AbeE1HhI (ORCPT ); Mon, 28 May 2018 03:37:08 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4S7Y60x059999 for ; Mon, 28 May 2018 03:37:07 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j8cd8tdy9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 28 May 2018 03:37:07 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 May 2018 08:37:05 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 May 2018 08:37:03 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4S7b3Ww18022636; Mon, 28 May 2018 07:37:03 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B4ABE42045; Mon, 28 May 2018 08:27:37 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FA2D42042; Mon, 28 May 2018 08:27:37 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 28 May 2018 08:27:37 +0100 (BST) From: Thomas Richter To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, Thomas Richter Subject: [PATCH v2] perf test 39 (Session topology) dumps core on s390 Date: Mon, 28 May 2018 09:36:57 +0200 X-Mailer: git-send-email 2.16.3 X-TM-AS-GCONF: 00 x-cbid: 18052807-0040-0000-0000-0000043E773F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052807-0041-0000-0000-00002643C056 Message-Id: <20180528073657.11743-1-tmricht@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-28_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805280093 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org perf test 39 fails with core dump on s390. The root cause is a NULL pointer reference in function check_cpu_topology() line 76 (or line 82 without -v). The session->header.env.cpu variable is NULL because on s390 function process_cpu_topology() returns with error: socket_id number is too big. You may need to upgrade the perf tool. and releases the env.cpu variable via zfree() and sets it to NULL. Here is the gdb output: (gdb) n 76 pr_debug("CPU %d, core %d, socket %d\n", i, (gdb) n Program received signal SIGSEGV, Segmentation fault. 0x00000000010f4d9e in check_cpu_topology (path=0x3ffffffd6c8 "/tmp/perf-test-J6CHMa", map=0x14a1740) at tests/topology.c:76 76 pr_debug("CPU %d, core %d, socket %d\n", i, (gdb) Make sure the env.cpu variable is not used when its NULL. Test for NULL pointer and return TEST_SKIP if so. Output before: [root@p23lp27 perf]# ./perf test -F 39 39: Session topology :Segmentation fault (core dumped) [root@p23lp27 perf]# Output after: [root@p23lp27 perf]# ./perf test -vF 39 39: Session topology : --- start --- templ file: /tmp/perf-test-Ajx59D socket_id number is too big.You may need to upgrade the perf tool. ---- end ---- Session topology: Skip [root@p23lp27 perf]# Signed-off-by: Thomas Richter --- --- tools/perf/tests/topology.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c index 17cb1bb3448c..40e30a26b23c 100644 --- a/tools/perf/tests/topology.c +++ b/tools/perf/tests/topology.c @@ -70,6 +70,27 @@ static int check_cpu_topology(char *path, struct cpu_map *map) session = perf_session__new(&data, false, NULL); TEST_ASSERT_VAL("can't get session", session); + /* On platforms with large numbers of CPUs process_cpu_topology() + * might issue an error while reading the perf.data file section + * HEADER_CPU_TOPOLOGY and the cpu_topology_map pointed to by member + * cpu is a NULL pointer. + * Example: On s390 + * CPU 0 is on core_id 0 and physical_package_id 6 + * CPU 1 is on core_id 1 and physical_package_id 3 + * + * Core_id and physical_package_id are platform and architecture + * dependend and might have higher numbers than the CPU id. + * This actually depends on the configuration. + * + * In this case process_cpu_topology() prints error message: + * "socket_id number is too big. You may need to upgrade the + * perf tool." + * + * This is the reason why this test might be skipped. + */ + if (!session->header.env.cpu) + return TEST_SKIP; + for (i = 0; i < session->header.env.nr_cpus_avail; i++) { if (!cpu_map__has(map, i)) continue; @@ -95,7 +116,7 @@ int test__session_topology(struct test *test __maybe_unused, int subtest __maybe { char path[PATH_MAX]; struct cpu_map *map; - int ret = -1; + int ret = TEST_FAIL; TEST_ASSERT_VAL("can't get templ file", !get_temp(path)); @@ -110,12 +131,9 @@ int test__session_topology(struct test *test __maybe_unused, int subtest __maybe goto free_path; } - if (check_cpu_topology(path, map)) - goto free_map; - ret = 0; - -free_map: + ret = check_cpu_topology(path, map); cpu_map__put(map); + free_path: unlink(path); return ret; -- 2.14.3