Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5254533rdb; Wed, 13 Dec 2023 03:44:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSySGll5Y8uxw9SKKAmBH2sUZkjAD98L0wcEve3fpsSJkK3sg7GOipFDgG4T/0I+LYxeOJ X-Received: by 2002:a05:6a20:42aa:b0:18f:97c:616e with SMTP id o42-20020a056a2042aa00b0018f097c616emr10004728pzj.107.1702467888793; Wed, 13 Dec 2023 03:44:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702467888; cv=none; d=google.com; s=arc-20160816; b=YwZvHpG0R+J5qe3yw9Tv3TD37/EvusweuhNZfEhuRjocV5+9eu2DZcJeQBvSIRXIef 3atMRYm9r9zw+RK+DvXc4lv+sr0Yy3xS9bQOsuh7VHkL0bpRUG+dOLkGJh/ZHWCjQ3dT eg9IXaTkF5M9R3oSDBUKfd+bmQoxota85KrS2TgsT3wTF6NwWxtXmpTM4V8+eNUgdCrx hkV63kAPaIqBSaXPU0COZLpL4C5f3Rb2qNBnai519URCwP6Pvkm0Rk3AJyaceDYBXIN6 4PVutigXz1jpwoNY1abXtHse98r3YeCS0fkHsgFSrEnp5E0cD6crez/Xmaac2vLQWlO8 QiHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=P0lIkZ5MKkdy8P8LuFbwaErCjEhsG8IhtH5mMG/Y/5Q=; fh=GT3Qs0ibQQgQy4eWwAxW+XRkMOOzkTRdhGQ3zYtEOCU=; b=07TDXsMF+XJbQdnBn1ZBSnO3PrD7fCqrlcm/qcbNrpB+ehILdXXLUmtFSsSnxxh7Uo fg3nVe0hZOpgdMFFf9HsUpwJ4nMqm/UW8XdnvMB2+XJfrIzyr2BDvHYnHOSGXvVZqk7X AUkT1ozpwe1hkCc31J+aU9Ojm++yy4q3MECQYGKa1FS3/xAWWWAD9zZ3D/vi3TyqPMkp IjLnTDCIInlgRH7dQT3FiozPWrBXC+J03/IOiLa1NtTcQIHSLJ1q66AGXjtkYYz636Ss gnt10wwKxQC15e9Wz0C8T7rC28vmuS3SvD9WDo+NkNCdPrCNZeIzKMJ6Zi4PHAOJS2I9 RRCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tQ1KpGhf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id o24-20020a17090ac09800b0028af5757d1asi124616pjs.95.2023.12.13.03.44.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 03:44:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tQ1KpGhf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4F37680A97A0; Wed, 13 Dec 2023 03:44:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235169AbjLMLob (ORCPT + 99 others); Wed, 13 Dec 2023 06:44:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233322AbjLMLoa (ORCPT ); Wed, 13 Dec 2023 06:44:30 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B8F6B0 for ; Wed, 13 Dec 2023 03:44:35 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CBDFC433C8; Wed, 13 Dec 2023 11:44:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702467875; bh=oMDLJR3QBu07Cmnnq8dPH187k2LYJ/Bh349mE/bY8oU=; h=From:To:Cc:Subject:Date:From; b=tQ1KpGhfjZNcUkxXi79TUZ0HBW1XEb69pN0LbOt68daPRWvfpzekQO7E2ChmRGle2 biouldnHtCuf7fbc3D7CGX8xnzjCNyVqXM5mxEFveKEuBo1xGfVQSLRhLM+q3N/pfe P+H9Z3RCadbQrOKYIOPXwR9sY+UZbxxXqX7OkXoBQROxFhtXgXsPxVCNWshjb7adO1 juZzy87gFjjUjxj7i1rLKg8da1JZZsn8sbBCHpUOVLItErdcomdop5XSD4YHl1av3D g1XduEVGHMzDJcOhR6klpIknCaAS/L6ebS4g8Rq5a9+h1aAvP9E+a0dfwFiI/8OnVA 3/WJK1RrTqE7A== From: Naveen N Rao To: , Cc: Steven Rostedt , Masami Hiramatsu , Shuah Khan , Michael Ellerman Subject: [PATCH v2] selftests/ftrace: Add test to exercize function tracer across cpu hotplug Date: Wed, 13 Dec 2023 17:08:02 +0530 Message-ID: <20231213113802.1278600-1-naveen@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Dec 2023 03:44:46 -0800 (PST) Add a test to exercize cpu hotplug with the function tracer active to ensure that sensitive functions in idle path are excluded from being traced. This helps catch issues such as the one fixed by commit 4b3338aaa74d ("powerpc/ftrace: Fix stack teardown in ftrace_no_trace"). Signed-off-by: Naveen N Rao --- v2: Add a check for next available online cpu, as suggested by Masami. .../ftrace/test.d/ftrace/func_hotplug.tc | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc new file mode 100644 index 000000000000..ccfbfde3d942 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc @@ -0,0 +1,42 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# description: ftrace - function trace across cpu hotplug +# requires: function:tracer + +if ! which nproc ; then + nproc() { + ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l + } +fi + +NP=`nproc` + +if [ $NP -eq 1 ] ;then + echo "We cannot test cpu hotplug in UP environment" + exit_unresolved +fi + +# Find online cpu +for i in /sys/devices/system/cpu/cpu[1-9]*; do + if [ -f $i/online ] && [ "$(cat $i/online)" = "1" ]; then + cpu=$i + break + fi +done + +if [ -z "$cpu" ]; then + echo "We cannot test cpu hotplug with a single cpu online" + exit_unresolved +fi + +echo 0 > tracing_on +echo > trace + +: "Set $(basename $cpu) offline/online with function tracer enabled" +echo function > current_tracer +echo 1 > tracing_on +(echo 0 > $cpu/online) +(echo "forked"; sleep 1) +(echo 1 > $cpu/online) +echo 0 > tracing_on +echo nop > current_tracer base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86 -- 2.43.0