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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D5C0C433EF for ; Tue, 12 Oct 2021 11:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27C7B60F3A for ; Tue, 12 Oct 2021 11:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236106AbhJLLJw (ORCPT ); Tue, 12 Oct 2021 07:09:52 -0400 Received: from foss.arm.com ([217.140.110.172]:35860 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233324AbhJLLJv (ORCPT ); Tue, 12 Oct 2021 07:09:51 -0400 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 73BA41FB; Tue, 12 Oct 2021 04:07:49 -0700 (PDT) Received: from [10.1.34.171] (e127744.cambridge.arm.com [10.1.34.171]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 315823F694; Tue, 12 Oct 2021 04:07:46 -0700 (PDT) Subject: Re: [RFC] perf arm-spe: Track task context switch for cpu-mode events To: Leo Yan , Namhyung Kim Cc: James Clark , Arnaldo Carvalho de Melo , Jiri Olsa , Ingo Molnar , Peter Zijlstra , LKML , Andi Kleen , Ian Rogers , Stephane Eranian , Adrian Hunter References: <20210923142305.GA603008@leoy-ThinkPad-X240s> <363c4107-fc6f-51d0-94d8-a3f579c8f5a2@arm.com> <20211004062638.GB174271@leoy-ThinkPad-X240s> <20211006093620.GA14400@leoy-ThinkPad-X240s> <87dad53f-a9a5-cd36-7348-ee10f4edd8fb@arm.com> <20211011142940.GB37383@leoy-ThinkPad-X240s> From: German Gomez Message-ID: <8a1eafe3-d19e-40d6-f659-de0e9daa5877@arm.com> Date: Tue, 12 Oct 2021 12:07:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20211011142940.GB37383@leoy-ThinkPad-X240s> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Leo and Namhyung, I want to make sure I'm on the same page as you regarding this topic. On 11/10/2021 15:29, Leo Yan wrote: > Hi German, > > On Mon, Oct 11, 2021 at 02:58:40PM +0100, German Gomez wrote: >> Hi Namhyung, >> >> On 09/10/2021 01:12, Namhyung Kim wrote: >> >>> Hi German, >>> >>> On Fri, Oct 8, 2021 at 4:08 AM German Gomez wrote: >>> >>> [...] >>> >>> I think we should use context-switch even for kernel samples, but >>> only if the context packets are not available. Do you think we should use them also when tracing outside of the root namespace? I'm no sure if we are considering the driver patch to disable context packets in non-root ns from earlier. >> [...] >> Actually I took time to try to find some way to enable switch events >> conditionally. As Namhyung suggested, we can enable the switch events >> in the perf tool (should do this in arm_spe_recording_options()), I am >> just wandering if perf tool can enable switch event only when it runs >> in the non-root namespace. I looked the code util/namespaces.c but >> still fail to find any approach to confirm the perf is running in >> the root namespace... anyway, this is not critical for this work. >> >> Welcome if anyone has idea for this. Thanks, Leo. We'll let you know if we come up with something too. > >> @Leo, what are your thoughts on this? Perhaps adding a warning message >> to tell the user to please enable context packets, otherwise the results >> will have workload-dependant inaccuracies, could be a good enough >> compromise? > Yeah, this is exactly what I think. It's good to give a warning so > users have knowledge for the potential inaccuracies. > > Thanks, > Leo If we are not considering patching the driver at this stage, so we allow hardware tracing on non-root namespaces. I think we could proceed like this:   - For userspace, always use context-switch events as they are     accurate and consistent with namespaces.   - For kernel tracing, if context packets are enabled, use them, but     warn the user that the PIDs correspond to the root namespace.   - Otherwise, use context-switch events and warn the user of the time     inaccuracies. Later, if the driver is patched to disable context packets outside the root namespace, kernel tracing could fall back to using context-switch events and warn the user with a single message about the time inaccuracies. If we are aligned, we could collect your feedback and share an updated patch that considers the warnings. Many thanks Best regards