Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp620338pxu; Sun, 22 Nov 2020 22:28:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQJ30pC31xsY0gMoIQ7sCDb5nzd5alz9sR70XiV0FS6VRpZJRzU6hATQyzoGnNDd6lWJ4B X-Received: by 2002:a17:906:76d3:: with SMTP id q19mr41535699ejn.162.1606112935888; Sun, 22 Nov 2020 22:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606112935; cv=none; d=google.com; s=arc-20160816; b=gEgraSZHSTX19fZjEKN2AAgnuho2414X06wUMgWPmpMfeQYVcOC2z8aHL//QgbCUFl yl9PB8etaKp5irTMPttSOQev42kO6JIeO7LMc77MmHTdTV/6J7a2kEDpXe6ocxGLA2P/ hw93a7X3OPx1wNowuiEwl6LTFk0R1Hxd5mnOpKqyMX9buSHL4hqOsfVohhn0ne/5b1cX X3XeX73iUsv//Qn+6Egtp2/WX3o9nj4k0X3J9cywgR8TkZVmum+eP9jGHhMPBSPcQFAW M33BkixcuRn1waQ7G8XudsdbsRQdgzxlX5rlaSMK0EkVSC0W1TIpRjj3Ko3I9LaQ6DvH we6g== 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=QB9Vs+4kipLsXgyHQaKtm+OK5sbwja+Pm5vAL/3kljg=; b=NIASuIrEczThJjIMlT6Y4+4ydTJJLllKkbpI1EivrWIe0UOwSmjt3BfyGKMzvnCG4v RhFn5UO6iRQea6kexS82wDpEkHCnuWubqYt2ztqYmkjD4Pebo/nQBbvWFq1VPE+2EVKe nt1cL2qghN2L/iT0claunGzVAFKT18thMnheRZ79zHyo5kAeC5Unw+9CJQ8KkmNu7xI4 PjlnmG5AYXWT0WVQyZl92Acl6Y12cTwlcc+n0dFiWCQbLBnAiRD9jTWt0/OQvRN6S1Ee k3TYPx6wXwlxY5tKBfRQlLkUFEtwAn6cEsd4hVNCqFZXVm/MkgdsET5DieyLuYxyLDES OsMw== 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 u20si6050286edr.287.2020.11.22.22.28.33; Sun, 22 Nov 2020 22:28:55 -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; 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 S1727952AbgKWGJB (ORCPT + 99 others); Mon, 23 Nov 2020 01:09:01 -0500 Received: from foss.arm.com ([217.140.110.172]:59394 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgKWGJA (ORCPT ); Mon, 23 Nov 2020 01:09:00 -0500 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 F413530E; Sun, 22 Nov 2020 22:08:59 -0800 (PST) Received: from [10.163.82.200] (unknown [10.163.82.200]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0E793F71F; Sun, 22 Nov 2020 22:08:57 -0800 (PST) Subject: Re: [RFC 09/11] coresight: etm-perf: Disable the path before capturing the trace data To: Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, mike.leach@linaro.org References: <1605012309-24812-1-git-send-email-anshuman.khandual@arm.com> <1605012309-24812-10-git-send-email-anshuman.khandual@arm.com> <1ad992f4-5981-6ff1-470b-875e30d3c229@arm.com> From: Anshuman Khandual Message-ID: Date: Mon, 23 Nov 2020 11:38:53 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1ad992f4-5981-6ff1-470b-875e30d3c229@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/12/20 2:57 PM, Suzuki K Poulose wrote: > On 11/10/20 12:45 PM, Anshuman Khandual wrote: >> perf handle structure needs to be shared with the TRBE IRQ handler for >> capturing trace data and restarting the handle. There is a probability >> of an undefined reference based crash when etm event is being stopped >> while a TRBE IRQ also getting processed. This happens due the release >> of perf handle via perf_aux_output_end(). This stops the sinks via the >> link before releasing the handle, which will ensure that a simultaneous >> TRBE IRQ could not happen. >> >> Signed-off-by: Anshuman Khandual >> --- >> This might cause problem with traditional sink devices which can be >> operated in both sysfs and perf mode. This needs to be addressed >> correctly. One option would be to move the update_buffer callback >> into the respective sink devices. e.g, disable(). >> >>   drivers/hwtracing/coresight/coresight-etm-perf.c | 2 ++ >>   1 file changed, 2 insertions(+) >> >> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c >> index 534e205..1a37991 100644 >> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c >> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c >> @@ -429,7 +429,9 @@ static void etm_event_stop(struct perf_event *event, int mode) >>             size = sink_ops(sink)->update_buffer(sink, handle, >>                             event_data->snk_config); >> +        coresight_disable_path(path); >>           perf_aux_output_end(handle, size); >> +        return; >>       } > > As you mentioned, this is not ideal where another session could be triggered on > the sink from a different ETM (not for per-CPU sink) in a different mode before > you collect the buffer. I believe the best option is to leave the > update_buffer() to disable_hw. This would need to pass on the "handle" to the > disable_path. Passing 'handle' into coresight_ops_sink->disable() would enable pushing updated trace data into perf aux buffer. But do you propose to drop the update_buffer() call back completely or just move it into disable() call back (along with PERF_EF_UPDATE mode check) for all individual sinks for now. May be, later it can be dropped off completely. > > That way the races can be handled inside the sinks. Also, this aligns the > perf mode of the sinks with that of the sysfs mode. Did not get that, could you please elaborate ?