From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suzuki.Poulose@arm.com (Suzuki K Poulose) Date: Tue, 26 Apr 2016 10:23:20 +0100 Subject: [PATCH V3 13/18] coresight: tmc: make sysFS and Perf mode mutually exclusive In-Reply-To: References: <1461345255-11758-1-git-send-email-mathieu.poirier@linaro.org> <1461345255-11758-14-git-send-email-mathieu.poirier@linaro.org> <571E2A7F.2070802@arm.com> <571E2F16.3010706@arm.com> <571E339E.9080306@arm.com> Message-ID: <571F3388.8090700@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 25/04/16 16:18, Mathieu Poirier wrote: > On 25 April 2016 at 09:11, Suzuki K Poulose wrote: >> On 25/04/16 16:05, Mathieu Poirier wrote: >>> >>> On 25 April 2016 at 08:52, Suzuki K Poulose >>> wrote: >>>> >>>> On 25/04/16 15:48, Mathieu Poirier wrote: >>>>> >>>>> >>>>> On 25 April 2016 at 08:32, Suzuki K Poulose >>>>> wrote: >>>>>> >>>>>> >>>>>> On 22/04/16 18:14, Mathieu Poirier wrote: >>>> >>>> >>>> >>>>>>> + spin_lock_irqsave(&drvdata->spinlock, flags); >>>>>>> + if (drvdata->reading) { >>>>>>> + ret = -EINVAL; >>>>>>> + goto out; >>>>>>> + } >>>>>>> + >>>>>>> + val = local_xchg(&drvdata->mode, mode); >>>>>>> + /* >>>>>>> + * In Perf mode there can be only one writer per sink. There >>>>>>> + * is also no need to continue if the ETR is already operated >>>>>>> + * from sysFS. >>>>>>> + */ >>>>>>> + if (val != CS_MODE_DISABLED) { >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> Could val be CS_MODE_PERF ? In other words, should we be checking : >>>>>> if (val == CS_MODE_SYSFS) instead ? >>>>> >>>>> >>>>> >>>>> If we check for CS_MODE_SYSFS we also have to check for CS_MODE_PERF, >>>>> which is two checks rather than a single one with the current >>>>> solution. >>>> >>>> >>>> >>>> I am confused now. The comment says, we want to check for sysfs mode and >>>> don't continue in that case. So, we shouldn't be worried about PERF mode. >>> >>> >>> You are correct about the sysFS part, but the first sentence of the >>> comment also mention that in perf mode there can only be one writer >>> per sink. Otherwise ring buffers for one session would end up with >>> traces from other ongoing sessions, and that is not taking into >>> account the buffer management nightmares it would cause. >> >> >> OK, in either case, val == CS_MODE_SYSFS is much better check there, to >> what we want to do > > If we check for SYSFS we also need to check for PERF. Otherwise > nothing prevents another session from using the sink buffer, which is > not supported. Ah, I got wrong. Sorry for the noise. The current check makes sense. Suzuki From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752624AbcDZJX1 (ORCPT ); Tue, 26 Apr 2016 05:23:27 -0400 Received: from foss.arm.com ([217.140.101.70]:52750 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbcDZJXX (ORCPT ); Tue, 26 Apr 2016 05:23:23 -0400 Subject: Re: [PATCH V3 13/18] coresight: tmc: make sysFS and Perf mode mutually exclusive To: Mathieu Poirier References: <1461345255-11758-1-git-send-email-mathieu.poirier@linaro.org> <1461345255-11758-14-git-send-email-mathieu.poirier@linaro.org> <571E2A7F.2070802@arm.com> <571E2F16.3010706@arm.com> <571E339E.9080306@arm.com> Cc: "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" From: Suzuki K Poulose Message-ID: <571F3388.8090700@arm.com> Date: Tue, 26 Apr 2016 10:23:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/04/16 16:18, Mathieu Poirier wrote: > On 25 April 2016 at 09:11, Suzuki K Poulose wrote: >> On 25/04/16 16:05, Mathieu Poirier wrote: >>> >>> On 25 April 2016 at 08:52, Suzuki K Poulose >>> wrote: >>>> >>>> On 25/04/16 15:48, Mathieu Poirier wrote: >>>>> >>>>> >>>>> On 25 April 2016 at 08:32, Suzuki K Poulose >>>>> wrote: >>>>>> >>>>>> >>>>>> On 22/04/16 18:14, Mathieu Poirier wrote: >>>> >>>> >>>> >>>>>>> + spin_lock_irqsave(&drvdata->spinlock, flags); >>>>>>> + if (drvdata->reading) { >>>>>>> + ret = -EINVAL; >>>>>>> + goto out; >>>>>>> + } >>>>>>> + >>>>>>> + val = local_xchg(&drvdata->mode, mode); >>>>>>> + /* >>>>>>> + * In Perf mode there can be only one writer per sink. There >>>>>>> + * is also no need to continue if the ETR is already operated >>>>>>> + * from sysFS. >>>>>>> + */ >>>>>>> + if (val != CS_MODE_DISABLED) { >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> Could val be CS_MODE_PERF ? In other words, should we be checking : >>>>>> if (val == CS_MODE_SYSFS) instead ? >>>>> >>>>> >>>>> >>>>> If we check for CS_MODE_SYSFS we also have to check for CS_MODE_PERF, >>>>> which is two checks rather than a single one with the current >>>>> solution. >>>> >>>> >>>> >>>> I am confused now. The comment says, we want to check for sysfs mode and >>>> don't continue in that case. So, we shouldn't be worried about PERF mode. >>> >>> >>> You are correct about the sysFS part, but the first sentence of the >>> comment also mention that in perf mode there can only be one writer >>> per sink. Otherwise ring buffers for one session would end up with >>> traces from other ongoing sessions, and that is not taking into >>> account the buffer management nightmares it would cause. >> >> >> OK, in either case, val == CS_MODE_SYSFS is much better check there, to >> what we want to do > > If we check for SYSFS we also need to check for PERF. Otherwise > nothing prevents another session from using the sink buffer, which is > not supported. Ah, I got wrong. Sorry for the noise. The current check makes sense. Suzuki