Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp66414ybl; Thu, 15 Aug 2019 12:47:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfAZJHW9le2bvKUtJOJp0DfWFT0/nwVdeHlWIGXuMtSv2kdKIfr5Yz4SEUEep7+JpkqYop X-Received: by 2002:a17:90a:3646:: with SMTP id s64mr3751624pjb.44.1565898435207; Thu, 15 Aug 2019 12:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565898435; cv=none; d=google.com; s=arc-20160816; b=oB1P7GKEXSZqUtBJBZrVsJZ3rzdLCX2kcWq2LjV7etyB1pT2+U6JNg1NJy97VsjwvR 12gPWJhAFRXlx/tkgbnHMX71ot3xbHp1MEP+A8rMV9r3uCZcq4xOUUVeI9KGJ0pp/mdG 5O5eHGFIx/n27ri7QhjxRDUhvTt9AUQn4fbf55ZtkaAl5vhWZwRWKZzZyt4Z05IkDsrR GbNrwoa+wyIFHefCNNDoKqh9SSfkrcbEtihfeuX28WOPZ6g2bd8VYlkr2urBBqMRMZzn hoTcmO1Bc14blJFvHDI+FZPRn1lqG5/OxPgfNGTLwBSJcHgPJAo4XPrfTs6pb34YRL7p R79A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=W/qaXV9S7EqSXjJ9HVVNAqMBd3/53HT0f+nyTBIWkjQ=; b=N5VpWcorXW1ECrlADZ7+9W+ga7ivOQitRIIEgL6Q45hMzxKZajXjaFCuUhk6QGT9Aj bp8E3upYtZug7TzboJ4gcRtNNPshVlLzjJTX/JSGUU7dCQKIEZ9Sg4uGzGV95lVPZ0FV jrAOGtc+CFfGeh8F5IlIAq6Xu5femQ0j7L3qFsapBSaP/+gFHzwhI4F5WytzeR1YF551 jOLT5fUtCHA3LcLYNibjTpLAYuHtAYa8IAThRZJ9e5sa1GIooWG63HnmMXIB3TA/ABsU 0+qXX3l/xoGdEII58GmBFNbH9oBHWfuNz1YV/PcIXjM3qQoMxNm3rzs1QDHlk8IPr7hB 4Etg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wUeoX1uP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id n1si1523631pjt.23.2019.08.15.12.46.59; Thu, 15 Aug 2019 12:47:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wUeoX1uP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1732466AbfHORh6 (ORCPT + 99 others); Thu, 15 Aug 2019 13:37:58 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:39220 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728685AbfHORh5 (ORCPT ); Thu, 15 Aug 2019 13:37:57 -0400 Received: by mail-io1-f67.google.com with SMTP id l7so757113ioj.6 for ; Thu, 15 Aug 2019 10:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=W/qaXV9S7EqSXjJ9HVVNAqMBd3/53HT0f+nyTBIWkjQ=; b=wUeoX1uPuGsbMGnSpUBVS62MFU9GgL7ic0/36SPnwOTAguBfWA5Gak5iU8UcYL+6Dq eGzLlIckv3K1bz2qreTGE3JfD/5nCYhPO/tTJhCS/6LuqmPYxQj6ZwKSdD2VrjUKqbA9 cF2gjQykZblgqUg090nE4cyIWH4OSJX1WMpYqrhjWe1o4KMHHqH1EHezZg37KrkJo5BF cL27sbU6YsXo3SELPEd7nMTo41502vReAZTx1EIqEBrmtKQi0wmLGx2pZ35M1iUIds9p 9/NT5Q+9z7VMWJiJdQBCojS5ovGK4mfJLU7cI8ikaLIhf8fn56Ap8BsjZj11gMu94O9S 2pAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=W/qaXV9S7EqSXjJ9HVVNAqMBd3/53HT0f+nyTBIWkjQ=; b=FnJ3sWGnCByeXncBZGFHw24FpEIGLRtA8gZGqK3z+cmuAZrGp1Y77DwOOcaffzA9wx rqZayORxwlYXQzQfgSCSbFDumTZ5nwgDgKpaxUpdnqJzX0tfWJ4spfGi+XpoNTIviWYn nQ7CCeADPT/uAKABvuog7uuZc7Jx7N9cqnnlps5UEPkQgiSAzQJzoW4LHpYjI4D4Qj7e PhEmfZ+jvVBJzf9bEs9rVJrFfm8yuZYWKc5EgwEGZW+dnLMExsmfNXbf0BTb0qv/uo97 A985enpR0yw642cnrUq+afmWqdl6mLHAMb7rD8S4VwJvRmMsAsy3p7a9/ggeQgMY0FHR 4hAQ== X-Gm-Message-State: APjAAAWDy13CeOrDli7N2e8twAF1fqQQ0klmu2XeI1gFHTPI6iR0OgSX 3t2z6VIZk/WxwQMTDvbwCIEeEhtJOYIM1EE7JfloJQ== X-Received: by 2002:a6b:7d49:: with SMTP id d9mr6742403ioq.50.1565890677021; Thu, 15 Aug 2019 10:37:57 -0700 (PDT) MIME-Version: 1.0 References: <20190812190320.209988-1-yabinc@google.com> In-Reply-To: <20190812190320.209988-1-yabinc@google.com> From: Mathieu Poirier Date: Thu, 15 Aug 2019 11:37:46 -0600 Message-ID: Subject: Re: [PATCH v2] coresight: tmc-etr: Fix perf_data check. To: Yabin Cui Cc: Suzuki K Poulose , Alexander Shishkin , linux-arm-kernel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 12 Aug 2019 at 13:03, Yabin Cui wrote: > > When tracing etm data of multiple threads on multiple cpus through > perf interface, each cpu has a unique etr_perf_buffer while sharing > the same etr device. There is no guarantee that the last cpu starts > etm tracing also stops last. This makes perf_data check fail. > > Fix it by checking etr_buf instead of etr_perf_buffer. > > Fixes: 3147da92a8a8 ("coresight: tmc-etr: Allocate and free ETR memory buffers for CPU-wide scenarios") > Signed-off-by: Yabin Cui > --- > > v1 -> v2: rename perf_data to perf_buf. Add fixes tag. > > --- > drivers/hwtracing/coresight/coresight-tmc-etr.c | 6 +++--- > drivers/hwtracing/coresight/coresight-tmc.h | 6 +++--- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c > index 17006705287a..90d1548ad268 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c > @@ -1484,7 +1484,7 @@ tmc_update_etr_buffer(struct coresight_device *csdev, > goto out; > } > > - if (WARN_ON(drvdata->perf_data != etr_perf)) { > + if (WARN_ON(drvdata->perf_buf != etr_buf)) { > lost = true; > spin_unlock_irqrestore(&drvdata->spinlock, flags); > goto out; > @@ -1497,7 +1497,7 @@ tmc_update_etr_buffer(struct coresight_device *csdev, > > CS_LOCK(drvdata->base); > /* Reset perf specific data */ > - drvdata->perf_data = NULL; > + drvdata->perf_buf = NULL; > spin_unlock_irqrestore(&drvdata->spinlock, flags); > > size = etr_buf->len; > @@ -1556,7 +1556,7 @@ static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, void *data) > } > > etr_perf->head = PERF_IDX2OFF(handle->head, etr_perf); > - drvdata->perf_data = etr_perf; > + drvdata->perf_buf = etr_perf->etr_buf; Ok for the fix. Looking a things again I don't see a need to do the assignment for each event - this needs to be done only when the device is assocated with a monitored process. Please move it here [1]. Thanks, Mathieu [1]. https://elixir.bootlin.com/linux/v5.3-rc4/source/drivers/hwtracing/coresight/coresight-tmc-etr.c#L1572 > > /* > * No HW configuration is needed if the sink is already in > diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h > index 1ed50411cc3c..f9a0c95e9ba2 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc.h > +++ b/drivers/hwtracing/coresight/coresight-tmc.h > @@ -178,8 +178,8 @@ struct etr_buf { > * device configuration register (DEVID) > * @idr: Holds etr_bufs allocated for this ETR. > * @idr_mutex: Access serialisation for idr. > - * @perf_data: PERF buffer for ETR. > - * @sysfs_data: SYSFS buffer for ETR. > + * @sysfs_buf: SYSFS buffer for ETR. > + * @perf_buf: PERF buffer for ETR. > */ > struct tmc_drvdata { > void __iomem *base; > @@ -202,7 +202,7 @@ struct tmc_drvdata { > struct idr idr; > struct mutex idr_mutex; > struct etr_buf *sysfs_buf; > - void *perf_data; > + struct etr_buf *perf_buf; > }; > > struct etr_buf_operations { > -- > 2.23.0.rc1.153.gdeed80330f-goog >