From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C97DC433EF for ; Thu, 10 Feb 2022 17:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=dHrYiWqNNKu7Bnakv8Kw3ayTvIyrw5ztgpWq0L7mgXU=; b=OWMraI3vdRfIw26YizhBiolguG +YVoPopH+MYKdVHyu7UIXQW23EoP+/JmemGG5xgwKBsUT/6NRimwVRFlEMx17NM1RSuAJDUJlSRwD qvKOxS5WZthUrsicwJeLZmaINOKFfmEnktrp/KRspOfikC1C3er4aYWLcQCNLepxjnEseejLmPM6F 6y+awZy8IoWsFeCpNzeKTGVk7I6yqE2jrUhadAH19+qC9gelOhT5Lq2cftighOHecDhBpG+IswguR 8lwl161V6hj93Lyb3K+yJQM17U4QL+SdgLMc7i+nfGtg9asUH7IBF5l1FOTZ+kCra71Gxh3pFXUr1 Khd+JZSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIDBV-004UAU-33; Thu, 10 Feb 2022 17:24:45 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIDBR-004U94-Ac for linux-arm-kernel@lists.infradead.org; Thu, 10 Feb 2022 17:24:42 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F1F0D6E; Thu, 10 Feb 2022 09:24:37 -0800 (PST) Received: from [10.1.30.148] (e127744.cambridge.arm.com [10.1.30.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 283923F718; Thu, 10 Feb 2022 09:24:35 -0800 (PST) Subject: Re: [RFC PATCH 1/2] perf: arm_spe: Fix consistency of PMSCR register bit CX To: Leo Yan Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, mark.rutland@arm.com, james.clark@arm.com References: <20220117124432.3119132-1-german.gomez@arm.com> <20220117124432.3119132-2-german.gomez@arm.com> <20220205153940.GB391033@leoy-ThinkPad-X240s> <4d5951ee-d7d2-1e76-eb24-5f3c46d1662c@arm.com> <20220208130047.GA273989@leoy-ThinkPad-X240s> From: German Gomez Message-ID: Date: Thu, 10 Feb 2022 17:23:50 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20220208130047.GA273989@leoy-ThinkPad-X240s> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_092441_441366_426771B1 X-CRM114-Status: GOOD ( 19.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Leo, On 08/02/2022 13:00, Leo Yan wrote: > Hi German, > > On Mon, Feb 07, 2022 at 12:06:14PM +0000, German Gomez wrote: > > [...] > Indeed! I can reproduce the issue now. And I can capture backtrace > for arm_spe_pmu_start() with below commands: > > # cd /home/leoy/linux/tools/perf > # ./perf probe --add "arm_spe_pmu_start" -s /home/leoy/linux/ -k /home/leoy/linux/vmlinux > # echo 1 > /sys/kernel/debug/tracing/events/probe/arm_spe_pmu_start/enable > # echo stacktrace > /sys/kernel/debug/tracing/events/probe/arm_spe_pmu_start/trigger > > ... run your commands with non-root user ... > > # cat /sys/kernel/debug/tracing/trace > > dd-7697 [000] d.h2. 506.068700: arm_spe_pmu_start: (arm_spe_pmu_start+0x8/0xe0) > dd-7697 [000] d.h3. 506.068701: > => kprobe_dispatcher > => kprobe_breakpoint_handler > => call_break_hook > [...] > => do_el0_svc > => el0_svc > => el0t_64_sync_handler > => el0t_64_sync > > The backtrace clearly shows the function arm_spe_pmu_start() is > invoked in the 'dd' process (dd-7697); the flow is: > - perf program sends IPI to CPU0; > - 'dd' process is running on CPU0 and it's interrupted to handle IPI; > - 'dd' process has root capabilities, so it will enable context > tracing for non-root perf session. Thanks for testing, and sharing the commands in your replies! > >>>> One way to fix this is by caching the value of the CX bit during the >>>> initialization of the PMU event, so that it remains consistent for the >>>> duration of the session. >>>> >>>> [...] > So the patch makes sense to me. Just a minor comment: > > Here we can define a u64 for recording pmscr value rather than a > bool value. > > struct arm_spe_pmu { > ... > u64 pmscr; > }; I agree with the comment from Will that it makes more sense to store the value of the register in the perf_event somehow (due to misunderstanding from my side, I thought arm_spe_pmu struct was local to the session). What about perf_event's void *pmu_private? Thanks, German _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel