Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1718422ybg; Sat, 19 Oct 2019 01:01:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIbxoBeMQFN+NfYHWjz7mZ44bofGyuiZVtKWb+z0+qoGIoHC63lEyyDZFichT9ICD1wub8 X-Received: by 2002:a05:6402:70c:: with SMTP id w12mr13813489edx.177.1571472093084; Sat, 19 Oct 2019 01:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571472093; cv=none; d=google.com; s=arc-20160816; b=fnXG2WojU8z/DEaFkubO8KB8iSJJrY16nRQwh3DCUVUS4AAnJMfzQ1i6dmh1cFI3VX vhVdid4lPDBJuYDtUFkPv7F/PrsAOPasjHANqQfQ+6RvPHquyMq7FtrtDWpPEnjAqjSr YlPHTwvvxNI+GB5u355fexbJs7N8c2eG+U46qJgF3zb6vUzKz4nXVa/hhVeM5DgGnb0j TBkBjxAiExzBNNsg2edMeRKnLK+xa/8U/BK/CMfAcGo6SsFcBJPr/VqxCuek0wNQr2Rd l+NIe8e3s3fie9XjobkFsls2Rk5tJ7QeR1OUJ3vCoeOUZdIqJW3UujlDOK0WOzL0Riw9 y9yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :organization:from:cc:to:references:subject; bh=MeJOMTO3iYSaK44mwQSsQzIJRvwr7J0djfiOCf4we4Y=; b=j05Pu8uebyytjed3RefVSWunYeuts12vuGP0/GVgU/dohLOrFaRSyWw+Qim1guO6KK /A89n75wxvElA14QnC7GWuIz2Gd6V9pvN9rjdA0rlturt7j68vf6EGiLNPB7D9vYhGa6 qxzWQ2VseCXgzE9VgL4HxIUorE0jk7SUdVlFlivTolY0XtoiULwVQ5hpXykYt9xkYoJO Re/BGHQCv7TMKuTxTxWNX3xcT3OB1z9ZFmoBBGdhxPZ2cJ0Qi1t45a+UhnD4JoTjVog7 g6zsu/u4CubzaTbKJdFQrcX7qG9gBU2K6DF3Hp8Y8t4wt3InundNdUE7iT2RyDaSMTB2 I+Pw== 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 x25si5156944edr.128.2019.10.19.01.01.10; Sat, 19 Oct 2019 01:01:33 -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 S2632914AbfJRIko (ORCPT + 99 others); Fri, 18 Oct 2019 04:40:44 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51354 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727903AbfJRIkn (ORCPT ); Fri, 18 Oct 2019 04:40:43 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9I8bWWQ053607 for ; Fri, 18 Oct 2019 04:40:42 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vqa0yr49v-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 Oct 2019 04:40:41 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 18 Oct 2019 09:40:39 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 18 Oct 2019 09:40:37 +0100 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9I8eb5g57475080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Oct 2019 08:40:37 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2846A4054; Fri, 18 Oct 2019 08:40:36 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D828A405C; Fri, 18 Oct 2019 08:40:36 +0000 (GMT) Received: from oc3784624756.ibm.com (unknown [9.152.212.90]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 18 Oct 2019 08:40:36 +0000 (GMT) Subject: Perf record is broken on kernel 5.4.0.rc3 References: To: "linux-perf-use." , Linux Kernel Mailing List , Song Liu , Hechao Li , Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra Cc: Heiko Carstens , Vasily Gorbik From: Thomas Richter Organization: IBM X-Forwarded-Message-Id: Date: Fri, 18 Oct 2019 10:40:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19101808-0008-0000-0000-00000323320C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19101808-0009-0000-0000-00004A4252EF Message-Id: <318faccf-a5fb-50f3-2635-6037b4670eb6@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-18_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910180085 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I ran into a eBPF program load error, system call bpf() returned -EPERM. It turned out that bpf_prog_load() bpf_prog_charge_memlock() __bpf_prog_charge() operated on a strange value of user->locked_vm: user->locked_vm:0xfffffffffffffe04 when accounting for 1 page. I bisected this strange value to commit d44248a41337 ("perf/core: Rework memory accounting in perf_mmap()") I added printk at end of function perf_mmap() to show allocation and at end of function perf_mmap_close() to display memory release. Then I run command 'perf record -e rbd000' to record samples and saving them in the auxiliary trace buffer. Here is the output, copied from the dmesg buffer: During allocation the values increase [52.250027] perf_mmap user->locked_vm:0x87 pinned_vm:0x0 ret:0 [52.250115] perf_mmap user->locked_vm:0x107 pinned_vm:0x0 ret:0 [52.250251] perf_mmap user->locked_vm:0x188 pinned_vm:0x0 ret:0 [52.250326] perf_mmap user->locked_vm:0x208 pinned_vm:0x0 ret:0 [52.250441] perf_mmap user->locked_vm:0x289 pinned_vm:0x0 ret:0 [52.250498] perf_mmap user->locked_vm:0x309 pinned_vm:0x0 ret:0 [52.250613] perf_mmap user->locked_vm:0x38a pinned_vm:0x0 ret:0 [52.250715] perf_mmap user->locked_vm:0x408 pinned_vm:0x2 ret:0 [52.250834] perf_mmap user->locked_vm:0x408 pinned_vm:0x83 ret:0 [52.250915] perf_mmap user->locked_vm:0x408 pinned_vm:0x103 ret:0 [52.251061] perf_mmap user->locked_vm:0x408 pinned_vm:0x184 ret:0 [52.251146] perf_mmap user->locked_vm:0x408 pinned_vm:0x204 ret:0 [52.251299] perf_mmap user->locked_vm:0x408 pinned_vm:0x285 ret:0 [52.251383] perf_mmap user->locked_vm:0x408 pinned_vm:0x305 ret:0 [52.251544] perf_mmap user->locked_vm:0x408 pinned_vm:0x386 ret:0 [52.251634] perf_mmap user->locked_vm:0x408 pinned_vm:0x406 ret:0 [52.253018] perf_mmap user->locked_vm:0x408 pinned_vm:0x487 ret:0 [52.253197] perf_mmap user->locked_vm:0x408 pinned_vm:0x508 ret:0 [52.253374] perf_mmap user->locked_vm:0x408 pinned_vm:0x589 ret:0 [52.253550] perf_mmap user->locked_vm:0x408 pinned_vm:0x60a ret:0 [52.253726] perf_mmap user->locked_vm:0x408 pinned_vm:0x68b ret:0 [52.253903] perf_mmap user->locked_vm:0x408 pinned_vm:0x70c ret:0 [52.254084] perf_mmap user->locked_vm:0x408 pinned_vm:0x78d ret:0 [52.254263] perf_mmap user->locked_vm:0x408 pinned_vm:0x80e ret:0 The value of user->locked_vm increases to a limit then the memory is tracked by pinned_vm. During deallocation the size is subtracted from pinned_vm until it hits a limit. Then a larger value is subtracted from locked_vm leading to a large number (because of type unsigned): [64.267797] perf_mmap_close mmap_user->locked_vm:0x408 pinned_vm:0x78d [64.267826] perf_mmap_close mmap_user->locked_vm:0x408 pinned_vm:0x70c [64.267848] perf_mmap_close mmap_user->locked_vm:0x408 pinned_vm:0x68b [64.267869] perf_mmap_close mmap_user->locked_vm:0x408 pinned_vm:0x60a [64.267891] perf_mmap_close mmap_user->locked_vm:0x408 pinned_vm:0x589 [64.267911] perf_mmap_close mmap_user->locked_vm:0x408 pinned_vm:0x508 [64.267933] perf_mmap_close mmap_user->locked_vm:0x408 pinned_vm:0x487 [64.267952] perf_mmap_close mmap_user->locked_vm:0x408 pinned_vm:0x406 [64.268883] perf_mmap_close mmap_user->locked_vm:0x307 pinned_vm:0x406 [64.269117] perf_mmap_close mmap_user->locked_vm:0x206 pinned_vm:0x406 [64.269433] perf_mmap_close mmap_user->locked_vm:0x105 pinned_vm:0x406 [64.269536] perf_mmap_close mmap_user->locked_vm:0x4 pinned_vm:0x404 [64.269797] perf_mmap_close mmap_user->locked_vm:0xffffffffffffff84 pinned_vm:0x303 [64.270105] perf_mmap_close mmap_user->locked_vm:0xffffffffffffff04 pinned_vm:0x202 [64.270374] perf_mmap_close mmap_user->locked_vm:0xfffffffffffffe84 pinned_vm:0x101 [64.270628] perf_mmap_close mmap_user->locked_vm:0xfffffffffffffe04 pinned_vm:0x0 This value sticks for the user until system is rebooted, causing follow-on system calls using locked_vm resource limit to fail. This happens on a s390 (where I can proof it), but I am sure this affects other plattforms too as above commit changes common code. If you send me a fix, I can verify it. -- Thomas Richter, Dept 3252, IBM s390 Linux Development, Boeblingen, Germany -- Vorsitzender des Aufsichtsrats: Matthias Hartmann Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294