From nobody Fri Dec 19 14:23:47 2025 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAFA933CEB2; Wed, 5 Nov 2025 19:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762370203; cv=none; b=Vyn2kd7vITd7zmVmGKMW6w6sFsHGqbj/7dru0O8mGii9RvPpBY0BMBxAnV6LQa5Oz+FP32pi3t/LjXywltcCfsBTU5lOhfE7t7UK28XEuy/vhKsBUS3DD7TLjaWbYNdF5HzP81yCvjoXKO/4f+KXqaBvAoHjYNu7PjuouXq/ALY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762370203; c=relaxed/simple; bh=xEPuY0Aq6t22FgSHExwjo58jWnNFk4btfpoFcms/TMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P1P4eoWFulcG8AKKiRnL5ishUkQNCMIvgD9eJV8qY9M0kkkYzHNI8kFrnrQ1XIHX7GbKAwiNbMMB26xuvrJJ6UPpOOMDfiLwH3EciSkj95fFKp8qN/5jly6ye0tpKET9Qnc3To9aideoOw0ffzJP+bqIp0uGoXRFQ3MNkXfQ3RA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=G7KwDwpJ; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="G7KwDwpJ" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5A5HJ0Kx021179; Wed, 5 Nov 2025 19:16:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=p/08haptJ9TbAqui1 15p4wPH+9xfsOic9U8vGBYByis=; b=G7KwDwpJEhakrJWV1njmUFw+UxbtezMja pfv8G4mbPjBRVgukpN9TA+rk+S40MrqSAgGDYPtxOpkG83JllN+9QvORrxfr/DMf 9EehrgyBt/yRpdzZbisR8A6ybYxTirVBp871PuWMtIGuVBCBl/P305FKaQqYHNfd QI+6oX5nfqrQUSFwumU3jHanTMKfBjaSa2YUyIji9D9dnBfSVv+Xc4yXMprV1JKr mb9ewbkUR1MkMBnqZ2rfkFpstzPhbSXQGSDSujZNLw+7HnlSLtNoaibYkmb10n9g 5Rx7CIkoUgcCr3ROiTXx8BQ1C329KNwc0sHxHEf8gaDGnG2ZtiNhQ== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4a59q93a82-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Nov 2025 19:16:38 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5A5HZR31027407; Wed, 5 Nov 2025 19:16:37 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4a5vwyhxdv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Nov 2025 19:16:37 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5A5JGXGo30343426 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Nov 2025 19:16:33 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6DB520043; Wed, 5 Nov 2025 19:16:33 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C28E20040; Wed, 5 Nov 2025 19:16:33 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.87.135.254]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Nov 2025 19:16:33 +0000 (GMT) From: Ilya Leoshkevich To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Ilya Leoshkevich Subject: [PATCH 1/5] perf jitdump: Fix PID namespace detection Date: Wed, 5 Nov 2025 20:10:24 +0100 Message-ID: <20251105191626.34998-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251105191626.34998-1-iii@linux.ibm.com> References: <20251105191626.34998-1-iii@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=StmdKfO0 c=1 sm=1 tr=0 ts=690ba297 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=BtBgnFqPBM3CgXGvGYgA:9 X-Proofpoint-ORIG-GUID: EbYCSNVZ4S7mpTiQilpc6TvFUYX8pGVH X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTAxMDAxOCBTYWx0ZWRfX9bhAVL1fphdM tgJMuwx8d0BTerIUXVE7PwzcdG6vnVsleXC8w+t/Kzanjq1/pQYEwJFxov5KW6kN8HBXsLBnvSr M6qEzX+jEHQz7wnQeo4cAYXs6gcn6Dox2HdMbtizF20Zi9rbI/47Zv6d9DiIMzbdbKj1k8cFJaO p+NZiSBIZHBE/7T6fbNy5LctzPoTNEBHg69eKvzgx1lXh1I8991w66z31zI1jYjoCTwJ7Ng31S9 AQuybggSi3gnecgLaJc1ViLdBqn17IOWC8nx8qzmVUHpy/WUu6L8uZ+Mc2RbXP435ZMEOS0RHt4 QcHjVezONJIPxHXdR/VR3XOPZYaVbK9j3CH+SjjNmiYg4ht9GqwY1XxNMRqUmpMv51iZsM/Lw0l dQWp/tlY3FY4yps71fBgY5lu8iXHkQ== X-Proofpoint-GUID: EbYCSNVZ4S7mpTiQilpc6TvFUYX8pGVH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-05_07,2025-11-03_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 adultscore=0 bulkscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511010018 Content-Type: text/plain; charset="utf-8" perf inject fails to detect jitdump file produced by a process running in a different PID namespace if this process has not exited yet. The PID namespace heuristic in jit_detect() compares two PIDs: * pid: outermost NStgid of mmap(jitdump) caller from perf's PoV. * nsinfo__nstgid(nsi): innermost NStgid of mmap(jitdump) caller from perf's PoV. The semantics of the in_pidns variable can be seen in, e.g., nsinfo__get_nspid(): it's true if and only if perf and the profiled process are in different PID namespaces. The current logic is clearly inverted: if pid and nsinfo__nstgid(nsi) are different, then the profiled process must be in a different PID namespace. This, of course, ignores that fact that they may end up being equal by accident, but that's not the point here. Fix by flipping the comparison. Changing just that, however, breaks the case when the process has exited. Add explicit support for that by adding "synthesized" field to nsinfo, which tracks whether NStgid was obtained from a running process (ignoring considerations of PID reuse or running inject on a different machine). When the namespace information is synthesized, assume the process ran in a different PID namespace. Signed-off-by: Ilya Leoshkevich --- tools/perf/util/jitdump.c | 27 +++++++++++++++++++++------ tools/perf/util/namespaces.c | 9 +++++++++ tools/perf/util/namespaces.h | 2 ++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index b062b1f234b62..19e4bc139935b 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -788,15 +788,30 @@ jit_detect(const char *mmap_name, pid_t pid, struct n= sinfo *nsi, bool *in_pidns) if (!end) return -1; =20 - *in_pidns =3D pid =3D=3D nsinfo__nstgid(nsi); /* - * pid does not match mmap pid - * pid=3D=3D0 in system-wide mode (synthesized) + * Determine whether the process ran inside a container, and whether it + * mapped jit.dump for profiling purposes or by accident. Record this + * for further use in jit_inject(). The kernel does not provide PID + * namespace information, so we have to resort to guesswork. * - * If the pid in the file name is equal to the nstgid, then - * the agent ran inside a container and perf outside the - * container, so record it for further use in jit_inject(). + * If the process exited and perf had to synthesize the namespace + * information, then it's not possible to have any certainty; be + * aggressive and assume that the process ran inside a container. This + * allows the user to proceed with injection at the cost of a small + * probability of injecting irrelevant data. + * + * If the process' NStgid as observed by perf is different from its + * innermost NStgid, then it must have run inside a container. There is + * a very small probability that NStgids randomly happenned to be the + * same; ignore it. + * + * pid =3D=3D 0 means system-wide mode, just proceed. + * + * Finally, the most straightforward case: if the PID in the file name + * is equal to the process' NStgid as observed by perf, then it must be + * a match. */ + *in_pidns =3D nsinfo__synthesized(nsi) || pid !=3D nsinfo__nstgid(nsi); if (pid && !(pid2 =3D=3D pid || *in_pidns)) return -1; /* diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c index 01502570b32d0..7de5d62e271c4 100644 --- a/tools/perf/util/namespaces.c +++ b/tools/perf/util/namespaces.c @@ -132,6 +132,8 @@ int nsinfo__init(struct nsinfo *nsi) =20 rv =3D nsinfo__get_nspid(&RC_CHK_ACCESS(nsi)->tgid, &RC_CHK_ACCESS(nsi)->= nstgid, &RC_CHK_ACCESS(nsi)->in_pidns, spath); + if (rv =3D=3D 0) + RC_CHK_ACCESS(nsi)->synthesized =3D false; =20 out: free(newns); @@ -166,6 +168,7 @@ struct nsinfo *nsinfo__new(pid_t pid) RC_CHK_ACCESS(nsi)->nstgid =3D pid; nsinfo__clear_need_setns(nsi); RC_CHK_ACCESS(nsi)->in_pidns =3D false; + RC_CHK_ACCESS(nsi)->synthesized =3D true; /* Init may fail if the process exits while we're trying to look at its * proc information. In that case, save the pid but don't try to enter * the namespace. @@ -197,6 +200,7 @@ struct nsinfo *nsinfo__copy(const struct nsinfo *nsi) RC_CHK_ACCESS(nnsi)->nstgid =3D nsinfo__nstgid(nsi); RC_CHK_ACCESS(nnsi)->need_setns =3D nsinfo__need_setns(nsi); RC_CHK_ACCESS(nnsi)->in_pidns =3D nsinfo__in_pidns(nsi); + RC_CHK_ACCESS(nnsi)->synthesized =3D nsinfo__synthesized(nsi); if (nsinfo__mntns_path(nsi)) { RC_CHK_ACCESS(nnsi)->mntns_path =3D strdup(nsinfo__mntns_path(nsi)); if (!RC_CHK_ACCESS(nnsi)->mntns_path) { @@ -275,6 +279,11 @@ void nsinfo__set_in_pidns(struct nsinfo *nsi) RC_CHK_ACCESS(nsi)->in_pidns =3D true; } =20 +bool nsinfo__synthesized(const struct nsinfo *nsi) +{ + return RC_CHK_ACCESS(nsi)->synthesized; +} + void nsinfo__mountns_enter(struct nsinfo *nsi, struct nscookie *nc) { diff --git a/tools/perf/util/namespaces.h b/tools/perf/util/namespaces.h index e95c79b80e27c..41ba2ea8137e5 100644 --- a/tools/perf/util/namespaces.h +++ b/tools/perf/util/namespaces.h @@ -38,6 +38,7 @@ DECLARE_RC_STRUCT(nsinfo) { bool in_pidns; char *mntns_path; refcount_t refcnt; + bool synthesized; }; =20 struct nscookie { @@ -60,6 +61,7 @@ pid_t nsinfo__nstgid(const struct nsinfo *nsi); pid_t nsinfo__pid(const struct nsinfo *nsi); bool nsinfo__in_pidns(const struct nsinfo *nsi); void nsinfo__set_in_pidns(struct nsinfo *nsi); +bool nsinfo__synthesized(const struct nsinfo *nsi); =20 void nsinfo__mountns_enter(struct nsinfo *nsi, struct nscookie *nc); void nsinfo__mountns_exit(struct nscookie *nc); --=20 2.51.1 From nobody Fri Dec 19 14:23:47 2025 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48E3B31328A; Wed, 5 Nov 2025 19:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762370202; cv=none; b=k2nOVmtAdTPUU2hnDM/RmRw8p5WJseETGChd9awx6OCUYWAoaAN6B4uFSijnJSi0Qz6yZRfdAbs+By/jvdwP//1qZUA12kZ750dLEtyniAoITRnQSNEHHdZXLF4LDW11LV/HdbU2DujRgrm9KJinOqCPdKAp2LupYimxmTkjJZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762370202; c=relaxed/simple; bh=qa5CE62I4QdqMVTINDn/2L6tShJyDKFrJ7cig69/BKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hwmvq+/gKA7nXOzFkoxg+vf6E/4glqQoFAXv35yv994Fl0ilSL73R2jX6hlxKvID6wKVrC67L17JK3Y5JOGttuvmuREr6kQBKRaWPRN8F+TnEKwPjgtnT8LCFvgGWmBGlAGnDtZlgazdFmBdx1OyiECmRdLWT3mtkc3wcDFjsvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=AJOMHF5s; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="AJOMHF5s" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5A5FUD2O009906; Wed, 5 Nov 2025 19:16:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=+fzVlHDQpgFkvnVrg z/csJQAUTecVeOjHoOubrzEtZQ=; b=AJOMHF5sGxUbCPTha8Z/JVt+t8aEX4AM5 THM3aeRgX/W/FGNKMjBVLArjuKQ7p2BUC+VBUJRUZuGFP8+cxDeTG4uW7HEOqJ1X Jr5XiMvcUtJudSJn5Nlyi1iNwFm8SxxdNP/IPM0C0gAsEQujWrtUj+S9QkzYT0+s G2xTFhuU+7evKH8s6DRLcyRvw9XO9IyV+OJwvBh8YqQkSmjM5iag+QVwZ/AvAEpM x3lgJ7BZOqj8gstkVIaSywC5iC9zNsxUiBHFMKaStXrBFg4mL04CuO+wfqqDmARK MJ4S45ib/MHGkbK8qhMtDFFKiFxOd2U23hsnY22kdKpYn4iZbHmsw== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4a59xc3808-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Nov 2025 19:16:39 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5A5G7Vbv021491; Wed, 5 Nov 2025 19:16:38 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4a5xrjskjd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Nov 2025 19:16:38 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5A5JGY2653674414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Nov 2025 19:16:34 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44FA52004B; Wed, 5 Nov 2025 19:16:34 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFD2320040; Wed, 5 Nov 2025 19:16:33 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.87.135.254]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Nov 2025 19:16:33 +0000 (GMT) From: Ilya Leoshkevich To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Ilya Leoshkevich Subject: [PATCH 2/5] perf test java symbol: Get rid of shellcheck warnings Date: Wed, 5 Nov 2025 20:10:25 +0100 Message-ID: <20251105191626.34998-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251105191626.34998-1-iii@linux.ibm.com> References: <20251105191626.34998-1-iii@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTAxMDAyMSBTYWx0ZWRfX8Sd9rvdeS7pZ H8tK94FqHR6iIqfjZB1LHitKsktJASP6CEcxROTSld+zDrCgw6ABJqsuxqi6aJf1+slR6B7eP2q dcAhzS0YnV25LGjyx3tKec/DQ2ZngtSxegC7Z7sfmGwmqWly4YfdW2yml9y1jIc0yDNom38xYK1 fiD+QmeOTWBNcCTYhgGg6jMRky0psKdpKVPh4YRhKRG+ZT84WVHIIlca6IbnVAeYD+FZLH7mM8j /2K6MwGKKteL6L6RN0qEGX1lshje15QGnmNtyk9jrVHtkYJcZ3vuzkUOrhchf437lX//Snuau/A HVhds4KmkTGVPfyRpIMiZlshtzokyRZv+P776huyO58IZrjoaq7GYC8NG1c9eeh5saPk38nK/XC mHuYYXBbVuwUUzOB2ETu0P3KKYFqwg== X-Proofpoint-GUID: T5DP3SlHhtcxiDSkOJXVJw3QvJoMGPRW X-Authority-Analysis: v=2.4 cv=OdCVzxTY c=1 sm=1 tr=0 ts=690ba297 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=KKAkSRfTAAAA:8 a=ZbB1VCf3sOdwrY-7MgYA:9 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: T5DP3SlHhtcxiDSkOJXVJw3QvJoMGPRW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-05_07,2025-11-03_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511010021 Content-Type: text/plain; charset="utf-8" Add missing quotes and suppress the $? warnings. Signed-off-by: Ilya Leoshkevich --- tools/perf/tests/shell/test_java_symbol.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/perf/tests/shell/test_java_symbol.sh b/tools/perf/tests/= shell/test_java_symbol.sh index 499539d1c4794..b1d7cd43af01a 100755 --- a/tools/perf/tests/shell/test_java_symbol.sh +++ b/tools/perf/tests/shell/test_java_symbol.sh @@ -4,6 +4,9 @@ # SPDX-License-Identifier: GPL-2.0 # Leo Yan , 2022 =20 +# Allow [ $? -ne 0 ], because long commands look ugly in if statements. +# shellcheck disable=3DSC2181 + # skip if there's no jshell if ! [ -x "$(command -v jshell)" ]; then echo "skip: no jshell, install JDK" @@ -13,11 +16,12 @@ fi PERF_DATA=3D$(mktemp /tmp/__perf_test.perf.data.XXXXX) PERF_INJ_DATA=3D$(mktemp /tmp/__perf_test.perf.data.inj.XXXXX) =20 -cleanup_files() -{ +# Shellcheck does not understand that this function is used by a trap. +# shellcheck disable=3DSC2317 +cleanup_files() { echo "Cleaning up files..." - rm -f ${PERF_DATA} - rm -f ${PERF_INJ_DATA} + rm -f "$PERF_DATA" + rm -f "$PERF_INJ_DATA" } =20 trap cleanup_files exit term int @@ -38,7 +42,7 @@ else exit 2 fi =20 -cat < 1 ? fib(x - 2) + fib(x - 1) : 1; } @@ -56,7 +60,7 @@ if [ $? -ne 0 ]; then exit 1 fi =20 -if ! DEBUGINFOD_URLS=3D'' perf inject -i $PERF_DATA -o $PERF_INJ_DATA -j; = then +if ! DEBUGINFOD_URLS=3D'' perf inject -i "$PERF_DATA" -o "$PERF_INJ_DATA" = -j; then echo "Fail to inject samples" exit 1 fi @@ -64,8 +68,8 @@ fi # Below is an example of the instruction samples reporting: # 8.18% jshell jitted-50116-29.so [.] Interpreter # 0.75% Thread-1 jitted-83602-1670.so [.] jdk.internal.jimage.= BasicImageReader.getString(int) -perf report --stdio -i ${PERF_INJ_DATA} 2>&1 | \ - grep -E " +[0-9]+\.[0-9]+% .* (Interpreter|jdk\.internal).*" > /dev/null = 2>&1 +perf report --stdio -i "$PERF_INJ_DATA" 2>&1 | + grep -E " +[0-9]+\.[0-9]+% .* (Interpreter|jdk\.internal).*" >/dev/null 2= >&1 =20 if [ $? -ne 0 ]; then echo "Fail to find java symbols" --=20 2.51.1 From nobody Fri Dec 19 14:23:47 2025 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1861426560D; Wed, 5 Nov 2025 19:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762370203; cv=none; b=lQd+wsUza6qxesFOH8+dSHOo6dlXmxNWvJUj61LPwIQbIjlP0G8B7lYgcS5AHde6Cp8Uj7sIC5RMwu3D8UJAP3y2csgoRtq+8Pf77NfzDcniq3Gnw73Z09cs4Qrc+BMUCxTI9TcZhC/QPu+iCYiuKWixeJdjFjOm3TZ+sePC7vc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762370203; c=relaxed/simple; bh=y0I3ywJfgU14mhdocsZghcDODSmE0AQjRwQb8FWlXZ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j3gepWDonnllfKxSnaTtVw8VV4BsVY94OfJySRXk5LSxPS3hriadshUNfvGwskCswfk2THkLlN1keNNhgcJ+BtIY3OBzjhnORH3LmxPCUgDPzE49huQDCRI5w2byr6TuJLcyFlov04r7pFlxSozg5DrYsTcW7NmQGKXL7VKBgPQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=mwvbwwrq; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="mwvbwwrq" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5A5Fab8E023094; Wed, 5 Nov 2025 19:16:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=OReeLvTuehb8VFolv BTYDo9jRGmTREs3SO7FB4+siaM=; b=mwvbwwrqb+2pAPwapOYLEF3FlhBqmoHgY 6hs+itxePeSHPr0Zhoqr9Gn7QaL+CMClEwde2lyK8kMwTYQEuwb4ya9VHC/XRRWB 15PCcs5JEA30bf0LjgoL3QKGNJt3RAX/I7dQjpPeYbTvHli/sR5XoAuhNDOmcpC4 kw0971BMVU3YmCvdnmrovUmTGzJvSza4x7HOCayzIUjEKVn+9gaLxT+vbRssOUEt k31CODAK36G6JBXQL+btrlS/JaNQzwNbpkRiuo7pOOPD13Lp9Outgql0H+IL35JP WuZiLAMvkNH/VwtWjU2FqUDyhrdVLMr+/pGt2VTqoq6gAJBIa89Pg== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4a59xc3809-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Nov 2025 19:16:39 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5A5GCfwV012875; Wed, 5 Nov 2025 19:16:38 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4a5y821h1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Nov 2025 19:16:38 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5A5JGYbm54395314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Nov 2025 19:16:35 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA6102004B; Wed, 5 Nov 2025 19:16:34 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EED120040; Wed, 5 Nov 2025 19:16:34 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.87.135.254]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Nov 2025 19:16:34 +0000 (GMT) From: Ilya Leoshkevich To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Ilya Leoshkevich Subject: [PATCH 3/5] perf test java symbol: Extract LIBJVMTI detection Date: Wed, 5 Nov 2025 20:10:26 +0100 Message-ID: <20251105191626.34998-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251105191626.34998-1-iii@linux.ibm.com> References: <20251105191626.34998-1-iii@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTAxMDAyMSBTYWx0ZWRfX6A/tTYnGNH7O h1inTvKNb8H3Dkj5evMtELePyMZGC99RbaEu0TT12Qw70MAtCZAvjJXDViaSXhNwZymvT6/baOG wzHaHIIzWevIotR7iwsCC7Jm0gsQkiPfxYk+ZwlTCGqWHA8DMLqBh2emHfb8izIWOkLYDTYMeNQ Dajnq/Fh7QQwPyeNNqOA2a3eioXov/Udu+ZsnbLVrJJHSBEH0Q0gWvCRIgKAKBRfw0PLwPRIp+G ih9DYGalG+krqPFU/J1pjPJRMTKNh7lO79cfMc4NJcgPm6a5XKWTYJ4CMzl6WfQGN2WKNoy2+qb wWUxnq3ihVbe0Q2CeRfqOUuDDu3+jXcB1mlThF4KBXZEEjh8zVuX/lwI2kv5/LLZQDa/GfTa4S4 /SuojPtX7BWESiPeTsazxoaY7GBThw== X-Proofpoint-GUID: vhD4owe5hidJS4vjW-Q7VmpWM2a_OptJ X-Authority-Analysis: v=2.4 cv=OdCVzxTY c=1 sm=1 tr=0 ts=690ba297 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=eP20pe4kTd3lE2_0kUEA:9 X-Proofpoint-ORIG-GUID: vhD4owe5hidJS4vjW-Q7VmpWM2a_OptJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-05_07,2025-11-03_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511010021 Content-Type: text/plain; charset="utf-8" Extract LIBJVMTI into lib/setup_libjvmti.sh for reuse by future tests. Signed-off-by: Ilya Leoshkevich --- tools/perf/tests/shell/lib/setup_libjvmti.sh | 18 ++++++++++++++++++ tools/perf/tests/shell/test_java_symbol.sh | 17 ++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 tools/perf/tests/shell/lib/setup_libjvmti.sh diff --git a/tools/perf/tests/shell/lib/setup_libjvmti.sh b/tools/perf/test= s/shell/lib/setup_libjvmti.sh new file mode 100644 index 0000000000000..fab4a44f8ecb2 --- /dev/null +++ b/tools/perf/tests/shell/lib/setup_libjvmti.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +if [ -e "$PWD/tools/perf/libperf-jvmti.so" ]; then + LIBJVMTI=3D$PWD/tools/perf/libperf-jvmti.so +elif [ -e "$PWD/libperf-jvmti.so" ]; then + LIBJVMTI=3D$PWD/libperf-jvmti.so +elif [ -e "$PREFIX/lib64/libperf-jvmti.so" ]; then + LIBJVMTI=3D$PREFIX/lib64/libperf-jvmti.so +elif [ -e "$PREFIX/lib/libperf-jvmti.so" ]; then + LIBJVMTI=3D$PREFIX/lib/libperf-jvmti.so +elif [ -e "/usr/lib/linux-tools-$(uname -a | awk '{ print $3 }' | sed -r '= s/-generic//')/libperf-jvmti.so" ]; then + LIBJVMTI=3D/usr/lib/linux-tools-$(uname -a | awk '{ print $3 }' | sed -r = 's/-generic//')/libperf-jvmti.so +else + echo "Fail to find libperf-jvmti.so" + # JVMTI is a build option, skip the test if fail to find lib + exit 2 +fi diff --git a/tools/perf/tests/shell/test_java_symbol.sh b/tools/perf/tests/= shell/test_java_symbol.sh index b1d7cd43af01a..f36c9321568c5 100755 --- a/tools/perf/tests/shell/test_java_symbol.sh +++ b/tools/perf/tests/shell/test_java_symbol.sh @@ -26,21 +26,8 @@ cleanup_files() { =20 trap cleanup_files exit term int =20 -if [ -e "$PWD/tools/perf/libperf-jvmti.so" ]; then - LIBJVMTI=3D$PWD/tools/perf/libperf-jvmti.so -elif [ -e "$PWD/libperf-jvmti.so" ]; then - LIBJVMTI=3D$PWD/libperf-jvmti.so -elif [ -e "$PREFIX/lib64/libperf-jvmti.so" ]; then - LIBJVMTI=3D$PREFIX/lib64/libperf-jvmti.so -elif [ -e "$PREFIX/lib/libperf-jvmti.so" ]; then - LIBJVMTI=3D$PREFIX/lib/libperf-jvmti.so -elif [ -e "/usr/lib/linux-tools-$(uname -a | awk '{ print $3 }' | sed -r '= s/-generic//')/libperf-jvmti.so" ]; then - LIBJVMTI=3D/usr/lib/linux-tools-$(uname -a | awk '{ print $3 }' | sed -r = 's/-generic//')/libperf-jvmti.so -else - echo "Fail to find libperf-jvmti.so" - # JVMTI is a build option, skip the test if fail to find lib - exit 2 -fi +# shellcheck source=3Dlib/setup_libjvmti.sh +. "$(dirname "$0")/lib/setup_libjvmti.sh" =20 cat < To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Ilya Leoshkevich Subject: [PATCH 4/5] perf test java symbol: Fix a false negative in symbol regex Date: Wed, 5 Nov 2025 20:10:27 +0100 Message-ID: <20251105191626.34998-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251105191626.34998-1-iii@linux.ibm.com> References: <20251105191626.34998-1-iii@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Xo7ivwsg7DKxB7QieEb-qDgVk3tx50ij X-Authority-Analysis: v=2.4 cv=MKhtWcZl c=1 sm=1 tr=0 ts=690ba298 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=Tfjndf6In5KXQWtPGGIA:9 X-Proofpoint-ORIG-GUID: Xo7ivwsg7DKxB7QieEb-qDgVk3tx50ij X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTAxMDAwMSBTYWx0ZWRfXzXfeARG1L11I aqvfq8j9e1HoF0SjYcEKF2LOPq6O03hYEXibMC7WEU7PochIhyX8s+dSi23OlSJ65/v/oI9ssUI 0neqMrPDdmsZBLcVYFYfW0pPuyH3/rrXD4hT2Yct3YV9/kERgZ2H3g8b2H0PJZ8Y4XyTRxuCTRK 0NyA3KEFM/6peWE2CuQT0nzJZyakPxAsIcOcLViD3C8sgEV/bypYtpUYPgyCQpfKcJFRuYki2gk Ww87pTIK5QFlhi+EtnGkzxi5pmH4nKRzcKbENRC7pgNAUcCIQw+W7IEKJwU5Hzlzs20G+Ou6Mzx rZdbPNSS0wCGc5hk2pDIGlLVx54u1b3fOLmb0+J7wQdpefe3mBCTgn6oXIwdVKvzuWrYZPvEsLj R1+3cyTE1/V5A6QirSe0C5u/cBKo1g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-05_07,2025-11-03_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 bulkscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 adultscore=0 phishscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511010001 Content-Type: text/plain; charset="utf-8" There are a lot of symbols like InterpreterRuntime::resolve_get_put() in the perf report output, so the existing regex unfortunately always matches something. Replace it with a more precise one. Signed-off-by: Ilya Leoshkevich --- tools/perf/tests/shell/test_java_symbol.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/test_java_symbol.sh b/tools/perf/tests/= shell/test_java_symbol.sh index f36c9321568c5..4c6bc57b87181 100755 --- a/tools/perf/tests/shell/test_java_symbol.sh +++ b/tools/perf/tests/shell/test_java_symbol.sh @@ -55,8 +55,10 @@ fi # Below is an example of the instruction samples reporting: # 8.18% jshell jitted-50116-29.so [.] Interpreter # 0.75% Thread-1 jitted-83602-1670.so [.] jdk.internal.jimage.= BasicImageReader.getString(int) +# Look for them, while avoiding false positives from lines like this: +# 0.03% jshell libjvm.so [.] InterpreterRuntime::= resolve_get_put(JavaThread*, Bytecodes::Code) perf report --stdio -i "$PERF_INJ_DATA" 2>&1 | - grep -E " +[0-9]+\.[0-9]+% .* (Interpreter|jdk\.internal).*" >/dev/null 2= >&1 + grep ' jshell .* jitted-.*\.so .* \(Interpreter$\|jdk\.internal\)' &>/dev= /null =20 if [ $? -ne 0 ]; then echo "Fail to find java symbols" --=20 2.51.1 From nobody Fri Dec 19 14:23:47 2025 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E6B333FE18; Wed, 5 Nov 2025 19:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762370205; cv=none; b=nqTauhry7bRehzpuDyMgjK53qE2fA/0ojVAnpAjPU5zzT/J9JpPKWRxtovsQb1TO8k/gRRaSuGJg0hX8Q6WRxurFkTKDzaB5UwBMLqwtZ9q5ByQ1RqzigkU6XOsf6FhcGiuaxK/i76yUl4OI/FF2sq3n8qqBkPNtWK0s5Harfd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762370205; c=relaxed/simple; bh=22Z3mj1k3enKgJtEbBtMi+H4eLL7PQ660K2yzaiWT/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y1EbqdPXGDbNVcKDbhZojZHSH+OfstLuVJDBGCagvuuUyEX4SoYDOELUD5SUArTEGrfbzjvX33tqlWNyvTUjh3y6io/plTomioMZZTsUwrkzCMPky385OzPM/vY8Wt6UaVfe5br6QgGZAiVnKa/beOmkMi3fT1ft+yXLkzXIx18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=jx5wTg8d; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="jx5wTg8d" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5A5D8jxl009411; Wed, 5 Nov 2025 19:16:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=oWL+2CjkMNbiQD1Rr qj0Z+xs4KQ7ALjD1Ir1gDVUNgw=; b=jx5wTg8dcFf4a5G9eSxwL2Y7cCZmvGQ8T 6YNZpjB1gkyqcGMxpKOyoVCBGnpM0RD6Hu8avdl2FDt1XqMc4ASyzV5Xz+fm0n+P QODicHt7cfTwg25+l5be6B6BXRGALYwBu1wzdDOX2qqsgJ39qJP7XKGMWq30oEZx 50a0vaOhPVB5zvgCV4WqpG22/9jSllJQYPGk9vdxx24rg5GT3NmUFwLD4vYo/KL+ 7dzbc4Op/r9zUa+rAnjEV0Rygu8jagYx/Pn1JcdbDBkNv9ofrJMlF4c+U09/4J9X TAPmC/uGZMwtZKbZ0P1dzRvZsh2EiXPzMwJdR6TxsJQ48dJC8LMzw== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4a59vuk8xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Nov 2025 19:16:40 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5A5GTgbu012974; Wed, 5 Nov 2025 19:16:39 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4a5y821h20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Nov 2025 19:16:39 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5A5JGaIB41812392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Nov 2025 19:16:36 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 17CCA20043; Wed, 5 Nov 2025 19:16:36 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9293420040; Wed, 5 Nov 2025 19:16:35 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.87.135.254]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Nov 2025 19:16:35 +0000 (GMT) From: Ilya Leoshkevich To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Ilya Leoshkevich Subject: [PATCH 5/5] perf test java symbol: Add PID namespace variant Date: Wed, 5 Nov 2025 20:10:28 +0100 Message-ID: <20251105191626.34998-6-iii@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251105191626.34998-1-iii@linux.ibm.com> References: <20251105191626.34998-1-iii@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 67HUu6tjUeQb4lMg6u_lCwGNJw0jhE5F X-Proofpoint-GUID: 67HUu6tjUeQb4lMg6u_lCwGNJw0jhE5F X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTAxMDAyMSBTYWx0ZWRfXzDy4Duiq5+y4 BvDOD0wgbvmFfzPl4+Ia9AexdU7Qsj3bXXt3EY7xMxt+2xAo0JBeuoYgcs1jU/rCc93q3LQwUN5 SolwJy6WKUpT1IVzE/KGnA4xIvGQ7AZUfUq7NXQDlp8KQ6DVQRRaEthapseQ/8wOS9M8PXNDXln TqNrIse67F1EGQlVJMXsjolK7DPEYKME4wcYuoCneMKNaLWkQBNJBLiPV6trqmYvf5MeodMuWu7 /y3uZWr/RutnLs6lV9ID98l3G5n25wqaRp9P05f4pafgAvkVOV0a3ZJIpR34+OPuWEFN7SI6KtV rlwRD4fgEGQRMAoTQa5aJrLewnkIUZFptjEQT7KalhsNhFSDaMkYPAMrmBG4dPwM9k0uajzX953 gU3ERwXbw1XNllYksx4GcUhTJnIbfA== X-Authority-Analysis: v=2.4 cv=U6qfzOru c=1 sm=1 tr=0 ts=690ba298 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=2i8RwoOR_BBpVC3p_GAA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-05_07,2025-11-03_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 impostorscore=0 spamscore=0 phishscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511010021 Content-Type: text/plain; charset="utf-8" Add a PID namespace variant of test_java_symbol.sh. Compared to the existing test, we must jump through two extra hoops here. First, we need to check whether unshare is there an is usable, which may not be the case either due to kernel config or permissions. Second, we need to keep jshell running after perf record exits in order to reproduce a real issue with this setup. This means we have to attach perf after starting jshell, use ctl-fifo and ack-fifo, and work around perf's inability to attach to existing children. Signed-off-by: Ilya Leoshkevich --- .../tests/shell/test_java_symbol_pidns.sh | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100755 tools/perf/tests/shell/test_java_symbol_pidns.sh diff --git a/tools/perf/tests/shell/test_java_symbol_pidns.sh b/tools/perf/= tests/shell/test_java_symbol_pidns.sh new file mode 100755 index 0000000000000..afee6d055ad90 --- /dev/null +++ b/tools/perf/tests/shell/test_java_symbol_pidns.sh @@ -0,0 +1,135 @@ +#!/bin/bash +# Test symbol resolution for java running inside a PID namespace +# SPDX-License-Identifier: GPL-2.0 + +set -u -o pipefail + +# shellcheck source=3Dlib/setup_libjvmti.sh +. "$(dirname "$0")/lib/setup_libjvmti.sh" + +JSHELL=3D(jshell -s -J"-agentpath:$LIBJVMTI") +if ! command -v jshell &>/dev/null; then + echo "skip: no jshell, install JDK" + exit 2 +fi + +UNSHARE=3D( + unshare + --user --map-user=3D"$(id -u)" --map-group=3D"$(id -g)" + --fork --pid --mount-proc +) +if ! "${UNSHARE[@]}" true; then + echo "skip: unshare not functional" + exit 2 +fi + +if [ "$#" -eq 0 ]; then + # Verify isolation by running the test inside a separate PID namespace. + exec "${UNSHARE[@]}" "$0" "$@" stage2 +fi +if [ "$1" !=3D stage2 ]; then + echo "$0 must be started without arguments" + exit 1 +fi +shift + +WORKDIR=3D$(mktemp -d /tmp/__perf_test_java_symbol_pidns.XXXXX) +trap 'rm -r "$WORKDIR"' EXIT + +test() { + TEST_ID=3Djshell-exit-$JSHELL_EXIT + + # Verify that perf inject can deal with JIT dump produced by jshell + # running in PID namespace that is different from its own one. + # Make sure jshell is still around when perf inject runs, so attach and + # detach perf manually. + # jshell is a shell script that runs java as a child process, and perf + # cannot attach to existing children. Therefore create a stopped + # process, which will exec jshell after it's resumed. + JSHELL_STDIN=3D$WORKDIR/jshell-stdin-$TEST_ID + JSHELL_STDOUT=3D$WORKDIR/jshell-stdout-$TEST_ID + mkfifo "$JSHELL_STDIN" + mkfifo "$JSHELL_STDOUT" + exec {JSHELL_STDIN_FD}<>"$JSHELL_STDIN" + exec {JSHELL_STDOUT_FD}<>"$JSHELL_STDOUT" + JITDUMPDIR=3D"$WORKDIR" bash -c 'kill -STOP "$$" && exec "$0" "$@"' \ + "${UNSHARE[@]}" "${JSHELL[@]}" \ + <&"$JSHELL_STDIN_FD" >&"$JSHELL_STDOUT_FD" & + JSHELL_PID=3D$! + + # Start perf record and wait until it attaches to jshell. + PERF_CTL=3D$WORKDIR/perf-ctl-$TEST_ID + PERF_ACK=3D$WORKDIR/perf-ack-$TEST_ID + mkfifo "$PERF_CTL" + mkfifo "$PERF_ACK" + exec {PERF_CTL_FD}<>"$PERF_CTL" + exec {PERF_ACK_FD}<>"$PERF_ACK" + PERF_DATA=3D$WORKDIR/perf-$TEST_ID.data + perf record --clockid=3D1 --delay=3D-1 \ + --control=3D"fd:$PERF_CTL_FD,$PERF_ACK_FD" \ + --output=3D"$PERF_DATA" --pid=3D"$JSHELL_PID" & + PERF_PID=3D$! + echo "enable" >&"$PERF_CTL_FD" + while IFS=3D read -r LINE <&"$PERF_ACK_FD"; do + [ "$LINE" !=3D "ack" ] || break + done + + # Spawn jshell and ask it to run some CPU-intensive code. + kill -CONT "$JSHELL_PID" + cat >&"$JSHELL_STDIN_FD" < 1 ? fib(x - 2) + fib(x - 1) : 1; } +System.out.println(fib(44)); +EOF + while IFS=3D read -r LINE <&"$JSHELL_STDOUT_FD"; do + [ "$LINE" !=3D 1134903170 ] || break + done + + # Terminate perf record. + echo "stop" >"$PERF_CTL" + if ! wait "$PERF_PID"; then + echo "Fail to record for java program" + exit 1 + fi + + # Terminate jshell before perf inject. + if [ "$JSHELL_EXIT" =3D "early" ]; then + echo "/exit" >&"$JSHELL_STDIN_FD" + if ! wait "$JSHELL_PID"; then + echo "Fail to run java program" + exit 1 + fi + fi + + # Inject the JIT data. + PERF_INJ_DATA=3D$WORKDIR/perf-$TEST_ID.data.inj + if ! DEBUGINFOD_URLS=3D"" perf inject --input=3D"$PERF_DATA" \ + --output=3D"$PERF_INJ_DATA" --jit; then + echo "Fail to inject samples" + exit 1 + fi + + # Below is an example of the instruction samples reporting: + # 8.18% jshell jitted-50116-29.so [.] Interpreter + # 0.75% Thread-1 jitted-83602-1670.so [.] jdk.internal.jimage= .BasicImageReader.getString(int) + # Look for them, while avoiding false positives from lines like this: + # 0.03% jshell libjvm.so [.] InterpreterRuntime:= :resolve_get_put(JavaThread*, Bytecodes::Code) + if ! perf report --input=3D"$PERF_INJ_DATA" --stdio | + grep ' jshell .* jitted-.*\.so .* \(Interpreter$\|jdk\.internal\)' \ + &>/dev/null; then + echo "Fail to find java symbols" + exit 1 + fi + + # Terminate jshell after perf inject. + if [ "$JSHELL_EXIT" =3D "late" ]; then + echo "/exit" >&"$JSHELL_STDIN_FD" + if ! wait "$JSHELL_PID"; then + echo "Fail to run java program" + exit 1 + fi + fi +} + +for JSHELL_EXIT in early late; do + test +done --=20 2.51.1