Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp651826pxu; Fri, 23 Oct 2020 09:52:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWO3oDwotUTktCLKPr24KkLBKcL4nlnkieGAVf2q6cdkudAUbBBlescnQrwvLA8JYibSrc X-Received: by 2002:a50:9502:: with SMTP id u2mr2995246eda.196.1603471945681; Fri, 23 Oct 2020 09:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603471945; cv=none; d=google.com; s=arc-20160816; b=shJPzzNEoho/sIDy7utJFx/9uCNSdZVwEz319KNxjBbW4cYyy/WQqZAlPdnm7PUdcy kZZCZlck5oMJxq6kIlHSZ1gtCOfaLViCpdcl1MlZlI2JoC9b++ZUCqJGc8nEC/+ZCBNk 8wUqU5F7LXfhIeB31x72vOMGuwqbxe/Rb8rONNA26Kn0po5bAEg1dFu42dqwqLY8Rpba FG1lkju9IM8bDV+fO8H3uk+Ygz9y0Mzob1hhus9oHQfaJykUNJEXtdsFjCGTZCqB0xZI B7vDgrpxE/A9/CgJINr8VPP6R2q8ttdQGdq9GEWb1Eak2kqQqYGkbDaaxQM+wIIDvAgo 03QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=PzUSYBCAISzPPpN8wjPaQy68Zny9Lj7bffYEpS91a6s=; b=PZ8udGBwK8af6lqmj9nMtmMAvv3du9vVSzd99/KYVv7In4pSFEtx/FRSVc5tDq9lyq vI6E1sLYNOpBc3+UsTZSQ+tj4jlC5j62Y1Pua3cG5axHLBsQKs55j0BhHM9wFf+0+YYe 7eYXvLxHx9bY87tbpLpU7HmQlZ1g79uqdc28OxPe0GG1TpTr4rxRUQeRkyFsjZN9fYdP zXnbkb96YJWqBLIjIPlvT0cE09Fm30xmAHxKhjIO3NU2wDZ+/LuS6FJIJ7LeBUV/Oetd XJOvoiugDz+hkZBvqsuiein//cK6azuCJ3VK+fw0dpXyY5kMFENJrBqlTUlrw2eg0jkd ZMAA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si1124482eds.558.2020.10.23.09.52.03; Fri, 23 Oct 2020 09:52:25 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S460770AbgJWIuB (ORCPT + 99 others); Fri, 23 Oct 2020 04:50:01 -0400 Received: from foss.arm.com ([217.140.110.172]:46708 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S460766AbgJWIuA (ORCPT ); Fri, 23 Oct 2020 04:50:00 -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 5541D31B; Fri, 23 Oct 2020 01:50:00 -0700 (PDT) Received: from [10.57.13.45] (unknown [10.57.13.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 99E4E3F66E; Fri, 23 Oct 2020 01:49:55 -0700 (PDT) Subject: Re: [PATCHv2 2/4] coresight: tmc-etf: Fix NULL ptr dereference in tmc_enable_etf_sink_perf() To: Peter Zijlstra , Mathieu Poirier Cc: 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 References: <20201022113214.GD2611@hirez.programming.kicks-ass.net> <20201022150609.GI2611@hirez.programming.kicks-ass.net> <788706f2-0670-b7b6-a153-3ec6f16e0f2e@arm.com> <20201022212033.GA646497@xps15> <20201023073905.GM2611@hirez.programming.kicks-ass.net> From: Suzuki Poulose Message-ID: <174e6461-4d46-cb65-c094-c06ee3b21568@arm.com> Date: Fri, 23 Oct 2020 09:49:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <20201023073905.GM2611@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter On 10/23/20 8:39 AM, Peter Zijlstra wrote: > On Thu, Oct 22, 2020 at 03:20:33PM -0600, Mathieu Poirier wrote: >> Suzuki's depiction of the usecase is accurate. Using the pid of the process >> that created the events comes out of a discussion you and I had in the common >> area by the Intel booth at ELC in Edinburgh in the fall of 2018. At the time I >> exposed the problem of having multiple events sharing the same HW resources and >> you advised to proceed this way. > > Bah, I was afraid of that. I desperately tried to find correspondence on > it, but alas, verbal crap doesn't end up in the Sent folder :-/ > >> That being said it is plausible that I did not expressed myself clearly enough >> for you to understand the full extend of the problem. If that is the case we >> are more than willing to revisit that solution. Do you see a better option than >> what has currently been implemented? > > Moo... that really could've done with a comment I suppose. > > So then I don't understand the !->owner issue, that only happens when > the task dies, which cannot be concurrent with event creation. Are you Part of the patch from Sai, fixes this by avoiding the dereferencing after event creation (by caching it). But the kernel events needs fixing. One follow up question on the !->owner issue. Given the ->owner is dying, does it prevent events from being scheduled ? Or is there a delay between that and eventually stopping the events. In this case, we hit the issue when : A A or B ? event_start() ... event->owner = NULL READ_ONCE(event->owner); Is this expected ? > somehow accessing ->owner later? > > As for the kernel events.. why do you care about the actual task_struct > * in there? I see you're using it to grab the task-pid, but how is that > useful? Correct, kernel events are something that the driver didn't account for. May be we could handle this case with a "special pid" and simply disallow sharing (which is fine I believe, given there are not grouping for the kernel created events). Suzuki