Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2834664imm; Thu, 24 May 2018 17:11:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqmBAzAdlGANIAPXj7PzUkYuv7ILC/zKqtoH+m+Jn/aHhWUFBK5mrwZnsT18nZPpwYhzZQ1 X-Received: by 2002:a17:902:4203:: with SMTP id g3-v6mr142317pld.315.1527207081658; Thu, 24 May 2018 17:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527207081; cv=none; d=google.com; s=arc-20160816; b=K2a1s+tr7eN4Gq98paditX/jtUNg8+GGGkz/5dK79Jf8BO6H8hjYsa3rgqz/rIFTkI gMkjTr/DPF7YV+d5cIbpIWwQtgCv8rEoWdb9ahudu+RW8fylBEdgv9No24dbUNG5Xhin tuvZGZAUX97IbGGV5ToigUlcLyT15w+d1cjrT7IOe1bpIVKgYDFyxTM1MLh4QXBv2QZl 4tisaq8hWoTI+VQg48jO6A/4TemNzfu7093ClX/7v16OTadBN26ZHKbMBJo40eiouVmK DRhFr9T11A1sSz+r0nupor9KZG1KDG48831WG+9jFiTvKQt4nGGxE/v36f2imgCoEPOC 2C8Q== 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=7zG4arfZaPzUlZjztEnLRwVA8eVkBqXWvkUfLlVxAIc=; b=ckHmde9bDqmeMzS/ZUtAZ1AsqKaAEF2buO9z1HHpt1nrSx1vX8vIGvzLf+8pEW7Rxu +eVr2ugzXQB1v7eD43QUU/PQAoTqYsNZZNTwCQGnAUbp2u/ALGYvDM/CIqeJxEgKnIlQ YtLNdatnF7CH6d82dHK4CcHQXSqu2AdOW6TcbaIoXU+wV5cmjIQqjVTGTVE1JOMSyzcL Mj7QzCTmqSMfiaAoL4I5vThvWuNTUzO/rY5dz5Lz3XL0YYsntWkzljHvLD8sdabOEJHF gX0G6XVyuIWmzW9j5iLsObl64s+rj0vXfA1GxzE6fMxuhn0ygDSS92M5b0ADYy4fleeD kSOg== 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 u10-v6si21320328pfh.145.2018.05.24.17.11.07; Thu, 24 May 2018 17:11:21 -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 S966918AbeEXN4Y (ORCPT + 99 others); Thu, 24 May 2018 09:56:24 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52310 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966530AbeEXN4W (ORCPT ); Thu, 24 May 2018 09:56:22 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4ODsjnS074511 for ; Thu, 24 May 2018 09:56:21 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j5vs1pdey-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 24 May 2018 09:56:21 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 May 2018 14:56:14 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 24 May 2018 14:56:11 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4ODuBlA8454416; Thu, 24 May 2018 13:56:11 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 326BBAE05D; Thu, 24 May 2018 14:45:23 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EBE06AE05A; Thu, 24 May 2018 14:45:22 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 24 May 2018 14:45:22 +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] perf test 39 (Session topology) dumps core on s390 Date: Thu, 24 May 2018 15:56:00 +0200 X-Mailer: git-send-email 2.16.3 X-TM-AS-GCONF: 00 x-cbid: 18052413-0008-0000-0000-000004FAB6BD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052413-0009-0000-0000-00001E8EBFCB Message-Id: <20180524135600.77128-1-tmricht@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-24_03:,, 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=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805240163 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 Reviewed-by: Hendrik Brueckner --- tools/perf/tests/topology.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c index 17cb1bb3448c..5f366d650d2b 100644 --- a/tools/perf/tests/topology.c +++ b/tools/perf/tests/topology.c @@ -70,6 +70,9 @@ 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); + 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 +98,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_ASSERT_VAL("can't get templ file", !get_temp(path)); @@ -110,12 +113,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