Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp431067pxu; Tue, 1 Dec 2020 15:12:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrR4+Kd5+jqrTlnvDC3sceLLh7U9N0gK+GE9492G+8phTrk8KWcrekf+KD7qKJ5mf+6VuV X-Received: by 2002:a17:906:7813:: with SMTP id u19mr5348935ejm.153.1606864351463; Tue, 01 Dec 2020 15:12:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606864351; cv=none; d=google.com; s=arc-20160816; b=qrCx2NnQjI7DwVlDT+IpRaLC1JRI0jZydP+ONO0AnIzprmGXDflI63vL9SkhMrtzCO mn9gxdHkgxe/GLVlM7jDfI3OfmzaTUXFlGmwjbhDuwtmu2F9PgZ5x0dMVbxbpMKAlmX1 3dZNqEGjgKil0wlFVN9L7CoKg7LuNTdJJcfneTPt0m4pAzWh3R4TLGw+QKz4HJ/YVAdv MZ59eE9+PFWda+/EJ97+g/f/Q0gtKxZOIIoZiGCaOtiwvaCPWy0I7lu2mi9500L52Jdx SMthESJJjOm7lxtT9TJOi7bhq1V57gfur7vhtoqLJcxdoFiw8njWMHGzOBQJxsoj+ut4 ojhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from :dkim-signature:date; bh=4PzduU4xrk7bLId7Un6G5H9UsKXK91i0bQbuE9uv81E=; b=pkEtOpGrJyuk03v9xUOF386mRTplfdBnRnpPt5bnNWZdW0pD1XgSJBsegfqvIF6pSL TLaUw5N5NN86cycdmoU4bkHKaVj9ss0w14gtoWyLcdK2K9+PlSF1m9J9Ub8G0x2muPqd 8BHM6pc2tVws3it0ODGR6EGmPjEqHM1rEUW7ZUaZGZoLlGkO0tUkm7efvQUVBz3DUaXa 4hTm9GzjT8OlwtQ0dFORzwJaTjbJUjIuL0twpjzsPJDTpzQR/RC9wKCERKMxR3Dc2uP4 oo1bpigkrPK8j6KzGcG4dXSyEsHzgFJtUKfpKyXBU3tuu7nMEvPn+IzK8oHglzHtS8ny gdzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zsaqQBCX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ml22si866215ejb.172.2020.12.01.15.12.08; Tue, 01 Dec 2020 15:12:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zsaqQBCX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726631AbgLAXKW (ORCPT + 99 others); Tue, 1 Dec 2020 18:10:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:46316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgLAXKW (ORCPT ); Tue, 1 Dec 2020 18:10:22 -0500 Date: Tue, 1 Dec 2020 23:09:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606864181; bh=R1LZxKhC63MgOhIWSKRcfmgG/w02ZOoz7xHqWe+Pr7k=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=zsaqQBCXac4ssa46wKGJrHjx78Yx+BKPCLV22+wvuO2lvTanFDGUxj+NCPAd7BT2E TQo1DGLBSM79hGhonz/V0LYXVbogx5ZAv/HDAPU3QyZI4crCjRZPDk3x8CH2QsIBsJ 5osHzXr+wQYAdBUuuOnHChySkw+W5DZWwAQdrdJ8= From: Will Deacon To: Leo Yan Cc: James Clark , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mark Rutland , Al Grant , John Garry , Suzuki K Poulose Subject: Re: [PATCH] drivers/perf: Enable PID_IN_CONTEXTIDR with SPE Message-ID: <20201201230935.GD28496@willie-the-truck> References: <20201130162454.28255-1-james.clark@arm.com> <20201130164650.GA25187@willie-the-truck> <20201201041040.GC28939@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201201041040.GC28939@leoy-ThinkPad-X240s> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01, 2020 at 12:10:40PM +0800, Leo Yan wrote: > On Mon, Nov 30, 2020 at 04:46:51PM +0000, Will Deacon wrote: > > On Mon, Nov 30, 2020 at 06:24:54PM +0200, James Clark wrote: > > > Enable PID_IN_CONTEXTIDR by default when Arm SPE is enabled. > > > This flag is required to get PID data in the SPE trace. Without > > > it the perf tool will report 0 for PID which isn't very useful, > > > especially when doing system wide profiling or profiling > > > applications that fork. > > > > Can perf not figure out the pid some other way? (e.g. by tracing context > > switches and correlating that with the SPE data?). > > For perf 'per-thread' mode, we can use context switch trace event as > assisted info to select thread context. But for "system wide" mode and > "snapshot" mode in perf tool, since the trace data is continuous, I > think we cannot use context switch trace event to correlate the SPE > trace data. Is there no way to correlate them with something like CNTVCT? > > Also, how does this work with pid namespaces? > > Here we are studying the implemetation of Intel-PT and Arm CoreSight. > > The context ID is stored into the hardware trace data when record; > afterwards when perf tool decodes the trace data and detects the > packet for context ID, it will select the machine's thread context in > perf [1]. Since the perf tool gathers all the threads infomation in > perf data file, based on the context ID, it can find the corresponding > thread pointer with function machine__find_thread() [2]. > > Since your question is for "pid namespace", to be honest, I don't know > how perf tool to handle any confliction for differrent processes share > the same PID, and I am not sure if you are asking CGroup related stuff > or not. If this cannot answer your question, please let me know. My point was that the pid value written to CONTEXTIDR is a global pid and does not take namespacing into account. If perf is run inside a pid namespace, it will therefore not work. Will