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 388C0C433F5 for ; Thu, 11 Nov 2021 13:11:54 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id ED56A611AD for ; Thu, 11 Nov 2021 13:11:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ED56A611AD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=iCh8x7ayH3bCInSgJikKd0WW9xs7EwqKf4W51UWajUY=; b=NexSf91KQH4VBs1Eadp+k+Ykmy 03vJsZZ0jPy/KyjrY4FR58GpvQDug/sWmQ9BapW2TCIrYnSa+pRfYPqBJu8YDIYS2+fzqqit5n1li uoe443ERYLKYtPEckCFkxtBLEc9qWEEUAYp+KiE6xu1lsBY/2p4rRTmsrHUJwhEFJLVVp1AJJ4T6y K9YVng2R3MKlBamrrasp3RE2Dehl/E9/yu05yQO/m906Bvvu1tK7IVuKHY1k5pN0mall7xh2MKb1D tMWWrKud6P2ddwj5a/wJAa1aC3aYVK8sEk4pPmK26zXa8Om5g39RNb8NIgOf7c9LSE6mCUNM+ZKE+ rd9/7/bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ml9qb-007vtb-5k; Thu, 11 Nov 2021 13:10:33 +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 1ml9qW-007vsz-Fl for linux-arm-kernel@lists.infradead.org; Thu, 11 Nov 2021 13:10:31 +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 5E33CED1; Thu, 11 Nov 2021 05:10:26 -0800 (PST) Received: from [10.57.58.62] (unknown [10.57.58.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AAD353F70D; Thu, 11 Nov 2021 05:10:23 -0800 (PST) Subject: Re: [PATCH v2 4/4] perf arm-spe: Support hardware-based PID tracing To: Leo Yan Cc: Namhyung Kim , linux-kernel , linux-perf-users , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , John Garry , Will Deacon , Mathieu Poirier , linux-arm-kernel@lists.infradead.org References: <20211109115020.31623-1-german.gomez@arm.com> <20211109115020.31623-5-german.gomez@arm.com> <20211111074148.GC102075@leoy-ThinkPad-X240s> <20211111083002.GA106401@leoy-ThinkPad-X240s> <5c0e255b-e140-d157-7dfd-b27a43e128c9@arm.com> <20211111124257.GB106654@leoy-ThinkPad-X240s> From: German Gomez Message-ID: <19f1e8c8-5c46-0954-112e-eca57c564e97@arm.com> Date: Thu, 11 Nov 2021 13:10:21 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211111124257.GB106654@leoy-ThinkPad-X240s> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211111_051028_657445_CED37B0E X-CRM114-Status: GOOD ( 23.12 ) 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, thanks for looking into it On 11/11/2021 12:42, Leo Yan wrote: > On Thu, Nov 11, 2021 at 12:23:08PM +0000, German Gomez wrote: >> On 11/11/2021 08:30, Leo Yan wrote: >>> On Wed, Nov 10, 2021 at 11:59:05PM -0800, Namhyung Kim wrote: > [...] > >>>>>>> +static int arm_spe_set_tid(struct arm_spe_queue *speq, pid_t tid) >>>>>>> +{ >>>>>>> + struct arm_spe *spe = speq->spe; >>>>>>> + int err = machine__set_current_tid(spe->machine, speq->cpu, tid, tid); >>>>>> I think we should pass -1 as pid as we don't know the real pid. >>>>>> >>>>> AFAICT, I observe one case for machine__set_current_tid() returning error >>>>> is 'speq->cpu' is -1 (this is the case for per-thread tracing). In >>>>> this case, if pass '-1' for pid/tid, it still will return failure. >>>>> >>>>> So here should return the error as it is. Am I missing anything? >>>> I'm not saying about the error. It's about thread status. >>>> In the machine__set_current_tid(), it calls >>>> machine__findnew_thread() with given pid and tid. >>>> >>>> I suspect it can set pid to a wrong value if the thread has >>>> no pid value at the moment. >>> Here we should avoid to write pid '-1' with >>> machine__set_current_tid(). >> If the kernel is writing the tids to the contextidr, isn't it wrong to >> assume tid == pid when decoding the context packets here? I haven't >> observed any impact in the built-in commands though, so there must be >> something I'm not seeing. > Okay, let me correct myself :) > > I checked Intel-pt's implementation, I understand now that we need to > distinguish the cases for pid/tid from context switch event and only tid > from SPE context packet. > > Since the context switch event contains the correct pid and tid > values, we should set both of them, see Intel-PT's implementation [1]. > > As Namhyung pointed, we need to set pid as '-1' when we only know the > tid value from SPE context packet; see [2]. I will correct this and resend the patch for SPE. Thanks, German > > So we should use the same with Intel-pt. > > Sorry for I didn't really understand well Namhyung's suggestion and > thanks you both pointed out the issue. > > Leo > > P.s. an offline topic is we should send a patch to fix cs-etm issue > as well [3]. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/util/intel-pt.c#n2920 > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/util/intel-pt.c#n2215 > [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/util/cs-etm.c#n1121 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel