Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp915984pxu; Fri, 23 Oct 2020 17:15:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeot15w8TIgO1oFEux1MOdnHH4a9Ng8L7yfXGRJnmcrnA3FvIAcjj2rutD/yScTC99YIVc X-Received: by 2002:a17:906:7113:: with SMTP id x19mr4493496ejj.59.1603498547398; Fri, 23 Oct 2020 17:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603498547; cv=none; d=google.com; s=arc-20160816; b=MFkVRmsXEZr+qImQN4erJkomblcv/zbEPc8U33ojWnLlbv0Jk8kzzxiffPI/t1pJ3T 37nmfV2+MP9W/l01UDjL78IfAMQvYBg1x3O8x6hbYxPN/A4z/xpyYQN7+GwCeoU3XjJh BYz11qvqYOXz/rY2mjr1pen1e0t3x02pYGeJiHAIE14i+Rx67Rzk2hgODMjADAq19NXi C8BZYnFIM37vpk+zMp/Zg43e5eTUFfU4waVFTK+AzgNG8XVYoefR0kQgCmo3hKP/hW37 6liRn62wd8laOtNu5mhRgiBpnflFSx+MVtr2fQ5bNsqKx9c6GKF39gkj5+B/9SaNPIen dXYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CGGzYJFzvaAClgoRLNesvAoSeLjys7jFkN1Zjf9m1Mg=; b=BE6FkkPCHWJrtYfSIOz8fn4dRdt4hak69qTEebSzuhvUH0lNd2CvkGDf05WV/25VTp mzYUD8JwQmVfdN9wLVhEW56FZyexqmWYixeUrcYu5YkYLPJjZ3zTGIor7b7t0W97LMQ9 uQdg29J+/F1I7KLwMfIvcPi0aRiFSKBpWtWPF3/qkst3UccJZYvxU14PFxtyo9pqrHlY wJt3w2NixRYYXTdHWU9NpWycLFuuiYPJE9m7jqBzvlxxDcd+BLDO1MFXV0Yqvp2V6JnU U9+Loa7rT35aEKm6sCe+ziv6eg2th8HEqK16m7zeIVi43bGWT+sX0Qg05KR5aKKJ325d dAig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YQ+zi25/"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si2123533edp.443.2020.10.23.17.15.25; Fri, 23 Oct 2020 17:15:47 -0700 (PDT) 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=@linaro.org header.s=google header.b="YQ+zi25/"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756219AbgJWUhe (ORCPT + 99 others); Fri, 23 Oct 2020 16:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756129AbgJWUhd (ORCPT ); Fri, 23 Oct 2020 16:37:33 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B419FC0613CE for ; Fri, 23 Oct 2020 13:37:33 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id o9so1586328plx.10 for ; Fri, 23 Oct 2020 13:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CGGzYJFzvaAClgoRLNesvAoSeLjys7jFkN1Zjf9m1Mg=; b=YQ+zi25/jTA5S0YJD+eHWDE4qmiYDzQKrABHi4pdtuJsUIeyaRHwjp5l1TrhwJQyGt CJ8iMpPENPDlPNsAjIFBhS2wa0pK9Dt30CifMlddAjdoNOAV8OZQfFG4ZMY47Tb+3XyJ pR9Zz6mLi39wlcO/FSWM6qT9eXxzZ6DuF/gMqua1qjRi9reky7ZHkW+KM3VXy5oZwcX5 gdKkthNHczliC1MZKI/uUSkP6QHBsxMVHjQIFHEZNGsr8bXI3tgxMh8LzgGvX6j1PgDq PDsr5cSlaJDlSDwwodCMYo5RTHEgYjzOt91miZwg02NAQKkkEQc1Xb92LjFOpiUF2O2a OPDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CGGzYJFzvaAClgoRLNesvAoSeLjys7jFkN1Zjf9m1Mg=; b=aNCHyLYtB1GIhzXYUWwzM0OTJxHS+h+vJL7CqZAl6SAULWZCHK3chgmnIrlkoiPbMX 0ShTJ8HekceZ/AH0OauRtFfB2Sgvt40q1VMcPnObNSYSha0NtMz4eKP+tXVtYcmIn3LR pQKOV34AF8HssmIm9amKl7hAmM6u5HWT+bOOQlgGqRaBLOtgCq/OuUjatnh34wuniDjB phR/7XdQWNj9puz5jYt4CUT5XqTw2zdAyXt6wSN1AQDWky1ZQ+Q9kxJ4G1DNW8h3YKDu M5DI2bHCZKky528ducWwXWkRE4EffC8Sj7Acd+2TtWPI8e66Ip9J740ZeA0/MG4pXAPV CQLQ== X-Gm-Message-State: AOAM530cTX4xeOObScCFfe9e8OvizbdbaNfVk9q6lA+vYz9tGJnoHrfU uxYAy+O/xvDBJyNWg7om5kqaGw== X-Received: by 2002:a17:902:ba96:b029:d5:f36b:44af with SMTP id k22-20020a170902ba96b02900d5f36b44afmr654523pls.51.1603485453114; Fri, 23 Oct 2020 13:37:33 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id q4sm2874788pgj.44.2020.10.23.13.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 13:37:31 -0700 (PDT) Date: Fri, 23 Oct 2020 14:37:29 -0600 From: Mathieu Poirier To: Peter Zijlstra Cc: Suzuki Poulose , Sai Prakash Ranjan , Mike Leach , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCHv2 2/4] coresight: tmc-etf: Fix NULL ptr dereference in tmc_enable_etf_sink_perf() Message-ID: <20201023203729.GA819775@xps15> References: <20201022212033.GA646497@xps15> <20201023073905.GM2611@hirez.programming.kicks-ass.net> <174e6461-4d46-cb65-c094-c06ee3b21568@arm.com> <20201023094115.GR2611@hirez.programming.kicks-ass.net> <20201023105431.GM2594@hirez.programming.kicks-ass.net> <2457de8f-8bc3-b350-fdc7-61276da31ce6@arm.com> <20201023131628.GY2628@hirez.programming.kicks-ass.net> <728fd89c-78f2-0c5c-0443-c91c62b02f0e@arm.com> <20201023134416.GA2628@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201023134416.GA2628@hirez.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 23, 2020 at 03:44:16PM +0200, Peter Zijlstra wrote: > On Fri, Oct 23, 2020 at 02:29:54PM +0100, Suzuki Poulose wrote: > > On 10/23/20 2:16 PM, Peter Zijlstra wrote: > > > On Fri, Oct 23, 2020 at 01:56:47PM +0100, Suzuki Poulose wrote: > > > > > That way another session could use the same sink if it is free. i.e > > > > > > > > perf record -e cs_etm/@sink0/u --per-thread app1 > > > > > > > > and > > > > > > > > perf record -e cs_etm/@sink0/u --per-thread app2 > > > > > > > > both can work as long as the sink is not used by the other session. > > > > > > Like said above, if sink is shared between CPUs, that's going to be a > > > trainwreck :/ Why do you want that? > > > > That ship has sailed. That is how the current generation of systems are, > > unfortunately. But as I said, this is changing and there are guidelines > > in place to avoid these kind of topologies. With the future > > technologies, this will be completely gone. > > I understand that the hardware is like that, but why do you want to > support this insanity in software? > > If you only allow a single sink user (group) at the same time, your > problem goes away. Simply disallow the above scenario, do not allow > concurrent sink users if sinks are shared like this. > > Have the perf-record of app2 above fail because the sink is in-user > already. I agree with you that --per-thread scenarios are easy to deal with, but to support cpu-wide scenarios events must share a sink (because there is one event per CPU). CPU-wide support can't be removed because it has been around for close to a couple of years and heavily used. I also think using the pid of the process that created the events, i.e perf, is a good idea. We just need to agree on how to gain access to it. In Sai's patch you objected to the following: > + struct task_struct *task = READ_ONCE(event->owner); > + > + if (!task || is_kernel_event(event)) Would it be better to use task_nr_pid(current) instead of event->owner? The end result will be exactly the same. There is also no need to check the validity of @current since it is a user process. Thanks, Mathieu [1]. https://elixir.bootlin.com/linux/latest/source/kernel/events/core.c#L6170 > > Only if the hardware has per-CPU sinks can you allow this.