From patchwork Fri Apr 28 16:38:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akanksha J N X-Patchwork-Id: 13226634 X-Patchwork-Delegate: mhiramat@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96589C77B61 for ; Fri, 28 Apr 2023 16:39:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346283AbjD1Qj7 (ORCPT ); Fri, 28 Apr 2023 12:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjD1Qj6 (ORCPT ); Fri, 28 Apr 2023 12:39:58 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61DC459DC; Fri, 28 Apr 2023 09:39:50 -0700 (PDT) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SGbMfm029807; Fri, 28 Apr 2023 16:39:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=1VFq6zyI75ZkAy0GmVMbORMhJmkyPnnRdcx8uJyRGqc=; b=hBg76IQPZU3C0X57/Yzuon3bKGAoht2zXv3xMlz6wEm8GRQoQVNaL7IgUCvl3HrTMWE1 OVr+AXTZoL3c90Lz46QCDi+4/lNGrhoUcwEMNqio6DNnnoT09DiRlWtAPZkIeCpkHOuz 4RDFdm9j0vjKFDkqgGzmxcMruCvj7dRKGS1+ZRbVEpBCP3inPajmSlbwpUxwcODEeq9N EW6sdJMbMVxik0i7P+6YMGILEvWmUXhRAT7yBUGOQFD75HxZ6h/ml6WCH0jBjDFGneI1 IeG9fy2VXMUJz1KkubtWDPaudvgCcUpgmvHd6FXBAf5LDNEwMU4te5JN1WO8sKtPSrkp 7g== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q8gjw2ggp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Apr 2023 16:39:46 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 33SGbMhA027503; Fri, 28 Apr 2023 16:38:58 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3q47773nsr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Apr 2023 16:38:58 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33SGct7c36831502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 16:38:55 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2DE32004D; Fri, 28 Apr 2023 16:38:54 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71DA020043; Fri, 28 Apr 2023 16:38:52 +0000 (GMT) Received: from li-ed75614c-32e0-11b2-a85c-ba2953069b43.ibm.com.com (unknown [9.43.42.160]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 28 Apr 2023 16:38:52 +0000 (GMT) From: Akanksha J N To: linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org, naveen.n.rao@linux.ibm.com, akanksha@linux.ibm.com, "Naveen N . Rao" Subject: [PATCH v3 1/2] selftests/ftrace: Add new test case which adds multiple consecutive probes in a function Date: Fri, 28 Apr 2023 22:08:41 +0530 Message-Id: <20230428163842.95118-2-akanksha@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230428163842.95118-1-akanksha@linux.ibm.com> References: <20230428163842.95118-1-akanksha@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: dLm0FE2YlPeEtHARPFhB-2Drxon920ql X-Proofpoint-ORIG-GUID: dLm0FE2YlPeEtHARPFhB-2Drxon920ql X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280133 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Commit 97f88a3d723162 ("powerpc/kprobes: Fix null pointer reference in arch_prepare_kprobe()") fixed a recent kernel oops that was caused as ftrace-based kprobe does not generate kprobe::ainsn::insn and it gets set to NULL. Add new test case kprobe_insn_boundary.tc which adds a kprobe at every byte within $FUNCTION_FORK up to an offset of 256 bytes, to be able to test potential issues with kprobes on successive instructions. The '|| continue' is added with the echo statement to ignore errors that are caused by trying to add kprobes to non probeable lines and continue with the test. Signed-off-by: Akanksha J N Acked-by: Naveen N. Rao Acked-by: Masami Hiramatsu (Google) --- .../test.d/kprobe/kprobe_insn_boundary.tc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_insn_boundary.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_insn_boundary.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_insn_boundary.tc new file mode 100644 index 000000000000..4f7cc318f331 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_insn_boundary.tc @@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2023 Akanksha J N, IBM corporation +# description: Register multiple kprobe events in a function +# requires: kprobe_events + +for i in `seq 0 255`; do + echo p $FUNCTION_FORK+${i} >> kprobe_events || continue +done + +cat kprobe_events >> $testlog + +echo 1 > events/kprobes/enable +( echo "forked" ) +echo 0 > events/kprobes/enable +echo > kprobe_events +echo "Waiting for unoptimizing & freeing" +sleep 5 +echo "Done" From patchwork Fri Apr 28 16:38:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akanksha J N X-Patchwork-Id: 13226632 X-Patchwork-Delegate: mhiramat@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DC49C77B61 for ; Fri, 28 Apr 2023 16:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346264AbjD1QjZ (ORCPT ); Fri, 28 Apr 2023 12:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346268AbjD1QjY (ORCPT ); Fri, 28 Apr 2023 12:39:24 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 735ED5276; Fri, 28 Apr 2023 09:39:21 -0700 (PDT) Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33SGcT9G026413; Fri, 28 Apr 2023 16:39:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=GkWUZ+AiZYDZ8lPFP0cYY8qVuunWl/Oa38WVcl3CSo4=; b=mBgpnPH8u3sozvBr+/nBbT7+42i6v5SxnpbIo0QWa4TZicZ+vwt7o9VfIVRXEBxBqluE jzGFp7c6hoze4CiZezfZRQKreNNcY0OL6x6NOlmKuURXIXxLzJkYdSBrwuIqJicAM4vO y5AJzmsmha3h1/VcbdxAvlubfOEuxFUL13cdnOWzVZHAopbY2orjOB5hNX8VbIJ1fxRm QJ5NbdfVGwJi0clIGAoRIiTubiFfeDiBXI2Z+sHCN9FpYIb3tFVxrxIroQ7FZFu6esxL GEtnW3wBxKs0Zin0d2CVybmWSecuonsYmpy9uv5wsqVdLN8k2bL420E+zSoVBj0zZna+ gA== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3q8hmv0a2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Apr 2023 16:39:10 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 33S8a88K030297; Fri, 28 Apr 2023 16:39:03 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3q4777310h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Apr 2023 16:39:03 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 33SGcxDw21758306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Apr 2023 16:38:59 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 62E2E20040; Fri, 28 Apr 2023 16:38:59 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A19D20043; Fri, 28 Apr 2023 16:38:57 +0000 (GMT) Received: from li-ed75614c-32e0-11b2-a85c-ba2953069b43.ibm.com.com (unknown [9.43.42.160]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 28 Apr 2023 16:38:56 +0000 (GMT) From: Akanksha J N To: linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org, naveen.n.rao@linux.ibm.com, akanksha@linux.ibm.com Subject: [PATCH v3 2/2] selftests/ftrace: Add new test case which checks for optimized probes Date: Fri, 28 Apr 2023 22:08:42 +0530 Message-Id: <20230428163842.95118-3-akanksha@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230428163842.95118-1-akanksha@linux.ibm.com> References: <20230428163842.95118-1-akanksha@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: WZJgrL13sgQp55Lh4Ubt2UphYzW1cY3H X-Proofpoint-ORIG-GUID: WZJgrL13sgQp55Lh4Ubt2UphYzW1cY3H X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-28_04,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 mlxlogscore=875 mlxscore=0 bulkscore=0 impostorscore=0 spamscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304280133 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Add new test case kprobe_opt_types.tc which enables and checks if each probe has been optimized in order to test potential issues with optimized probes. The '|| continue' is added with the echo statement to ignore errors that are caused by trying to add kprobes to non probeable lines and continue with the test. Signed-off-by: Akanksha J N Acked-by: Masami Hiramatsu (Google) Acked-by: Shuah Khan Acked-by: Steven Rostedt (Google) --- .../ftrace/test.d/kprobe/kprobe_opt_types.tc | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc new file mode 100644 index 000000000000..9f5d99328086 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc @@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2023 Akanksha J N, IBM corporation +# description: Register/unregister optimized probe +# requires: kprobe_events + +case `uname -m` in +x86_64) +;; +arm*) +;; +ppc*) +;; +*) + echo "Please implement other architecture here" + exit_unsupported +esac + +DEFAULT=$(cat /proc/sys/debug/kprobes-optimization) +echo 1 > /proc/sys/debug/kprobes-optimization +for i in `seq 0 255`; do + echo "p:testprobe $FUNCTION_FORK+${i}" > kprobe_events || continue + echo 1 > events/kprobes/enable || continue + (echo "forked") + PROBE=$(grep $FUNCTION_FORK /sys/kernel/debug/kprobes/list) + echo 0 > events/kprobes/enable + echo > kprobe_events + if echo $PROBE | grep -q OPTIMIZED; then + echo "$DEFAULT" > /proc/sys/debug/kprobes-optimization + exit_pass + fi +done +echo "$DEFAULT" > /proc/sys/debug/kprobes-optimization +exit_unresolved