From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54524C433EF for ; Mon, 13 Sep 2021 17:58:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17E9F60F3A for ; Mon, 13 Sep 2021 17:58:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 17E9F60F3A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K3HNLTEm+BgKvCmk2qxx9i105SjTLxb/v8Usx/Qn5P8=; b=Dmzw0jd/rVls7U NE4hODodKsBA3AAme2gp4WTnNhqbvUoIhlCUfU3GEpPIQGOX5QCcpGSEs/J+dgFVj7/KZNTqFqgxM dcLSz0j6bDHgcSqjxzRcO1Ij6mDLXV9lBqPw2Znu9oa7A0UwcTlrU9O5s0xFFuwj6A+BfXyBvzeFz nASGEAlfI6omrhZvpzg4awDdqTVJgrJh2FP7G9Z77Uq8GoQyt5/7nWL19tajz4HUC2nnNXsDWQLP7 VI3svMOZaY9IfDtPPh49h3Z1kLHjYS8Zh/PabfMjGvHM7VJ0q+u/duAeu9HfA+D0zYuexs3pxYqAh YL4GO9s2h0JFHDI6pqRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPqCC-002rWI-5s; Mon, 13 Sep 2021 17:56:44 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPqC7-002rVC-FN for linux-arm-kernel@lists.infradead.org; Mon, 13 Sep 2021 17:56:41 +0000 Received: by mail-pl1-x634.google.com with SMTP id v1so6348835plo.10 for ; Mon, 13 Sep 2021 10:56:39 -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=vm48QzVnlg64N4CDLfhKjY3I262QdEzPwX/kCmzJ/mI=; b=P8wDHk/53e8BOgh+Xkq0oe0cys/JU7emQx4SzvFhTxEJNVsMwJq4ccOR7g7bwPzSR6 HMh6I6fcLR3jH7Cn0zRMIQE/Qnj0efPjAfdNtwzXawhW110ipbzwLbfX9X28p8L/Oemw RPBx7ScWPafJK3mnuWCKiEP2MkZNHxbw3x9dLpeejSiV/CNjUHkqMkjunOabESq1S6lO nzR4XC03TXqL6KtHqkuBhZr0MPKYyvWujQIkCRnQ1gM/GEj4WV/n768Vxh99mCpU0FSW 99/Kbekp5BDikm7YWt53IwRBNgZ6oxn1pUZ5pK7Ub6j6UU9CcmlsON8MQKc276vvLELe gZVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vm48QzVnlg64N4CDLfhKjY3I262QdEzPwX/kCmzJ/mI=; b=T3+NWi+6T4MjRwv8xT+sCc1tOb0gRDEyOfuJnsSsWmrjkLKZV4eSiUo+f0o8UGHZwN keGk2wevIpwcOeICz0Vt2eBS/f2HXA7w3107naTrjPYN3QTJ6RbaC9GQmmXAPQSMu5u4 dxj3kFCMRyEDKiIVz/OLFSBF5ddJBYfCgdU8w5XNl9riTA4XIW/01NriS4g5ZkL51qJ2 fajvB1/qevkAkNs8yUZq/rFhk54VvRGdOP1EmhZEUw6RUW5YiRbuP/GFRpSrZSFWKOA1 aho5i2fg6rYP7iE6VZ19FQ6KL05xuJq0LkQET/J4TuKIO/xTIXzuomft3x0tE5Sv2kvm BHAQ== X-Gm-Message-State: AOAM533Ei8QO7lGoJpkrFqpZaCkg+LIgAwg18chKI0oIMtr/s80oKJlh JnSJU9T2MipwVx9K62a4Va7yXg== X-Google-Smtp-Source: ABdhPJyGwHaVpOVAHmi9y7dL1NNyewR0YKSE+++ZPJE8YHzmgNN46i1J9uCG16ikssPKf4MoEmnofw== X-Received: by 2002:a17:90a:3f8d:: with SMTP id m13mr717742pjc.199.1631555798581; Mon, 13 Sep 2021 10:56:38 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id b20sm7646156pfo.3.2021.09.13.10.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 10:56:37 -0700 (PDT) Date: Mon, 13 Sep 2021 11:56:35 -0600 From: Mathieu Poirier To: Leo Yan Cc: Suzuki K Poulose , Mike Leach , Robin Murphy , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] coresight: tmc-etr: Speed up for bounce buffer in flat mode Message-ID: <20210913175635.GA1676953@p14s> References: <20210905032144.966766-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210905032144.966766-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210913_105639_564989_E4D9DFF9 X-CRM114-Status: GOOD ( 33.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Sep 05, 2021 at 11:21:44AM +0800, Leo Yan wrote: > The AUX bounce buffer is allocated with API dma_alloc_coherent(), in the > low level's architecture code, e.g. for Arm64, it maps the memory with > the attribution "Normal non-cacheable"; this can be concluded from the > definition for pgprot_dmacoherent() in arch/arm64/include/asm/pgtable.h. > > Later when access the AUX bounce buffer, since the memory mapping is > non-cacheable, it's low efficiency due to every load instruction must > reach out DRAM. > > This patch changes to allocate pages with dma_alloc_noncoherent(), the > driver can access the memory via cacheable mapping; therefore, load > instructions can fetch data from cache lines rather than always read > data from DRAM, the driver can boost memory performance. After using > the cacheable mapping, the driver uses dma_sync_single_for_cpu() to > invalidate cacheline prior to read bounce buffer so can avoid read stale > trace data. > > By measurement the duration for function tmc_update_etr_buffer() with > ftrace function_graph tracer, it shows the performance significant > improvement for copying 4MiB data from bounce buffer: > > # echo tmc_etr_get_data_flat_buf > set_graph_notrace // avoid noise > # echo tmc_update_etr_buffer > set_graph_function > # echo function_graph > current_tracer > > before: > > # CPU DURATION FUNCTION CALLS > # | | | | | | | > 2) | tmc_update_etr_buffer() { > ... > 2) # 8148.320 us | } > > after: > > # CPU DURATION FUNCTION CALLS > # | | | | | | | > 2) | tmc_update_etr_buffer() { > ... > 2) # 2525.420 us | } > > Signed-off-by: Leo Yan > Reviewed-by: Suzuki K Poulose > --- > > Changes from v3: > Refined change to use dma_alloc_noncoherent()/dma_free_noncoherent() > (Robin Murphy); > Retested functionality and performance on Juno-r2 board. > > Changes from v2: > Sync the entire buffer in one go when the tracing is wrap around > (Suzuki); > Add Suzuki's review tage. > > .../hwtracing/coresight/coresight-tmc-etr.c | 26 ++++++++++++++++--- > 1 file changed, 22 insertions(+), 4 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c > index acdb59e0e661..a049b525a274 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c > @@ -609,8 +609,9 @@ static int tmc_etr_alloc_flat_buf(struct tmc_drvdata *drvdata, > if (!flat_buf) > return -ENOMEM; > > - flat_buf->vaddr = dma_alloc_coherent(real_dev, etr_buf->size, > - &flat_buf->daddr, GFP_KERNEL); > + flat_buf->vaddr = dma_alloc_noncoherent(real_dev, etr_buf->size, > + &flat_buf->daddr, > + DMA_FROM_DEVICE, GFP_KERNEL); Suzuki and Robin - are you guys good with this new revision? Thanks, Mathieu PS: Suzuki - I know you've already provided your RB on this but with the change in API I want to make sure before merging. > if (!flat_buf->vaddr) { > kfree(flat_buf); > return -ENOMEM; > @@ -631,14 +632,18 @@ static void tmc_etr_free_flat_buf(struct etr_buf *etr_buf) > if (flat_buf && flat_buf->daddr) { > struct device *real_dev = flat_buf->dev->parent; > > - dma_free_coherent(real_dev, flat_buf->size, > - flat_buf->vaddr, flat_buf->daddr); > + dma_free_noncoherent(real_dev, etr_buf->size, > + flat_buf->vaddr, flat_buf->daddr, > + DMA_FROM_DEVICE); > } > kfree(flat_buf); > } > > static void tmc_etr_sync_flat_buf(struct etr_buf *etr_buf, u64 rrp, u64 rwp) > { > + struct etr_flat_buf *flat_buf = etr_buf->private; > + struct device *real_dev = flat_buf->dev->parent; > + > /* > * Adjust the buffer to point to the beginning of the trace data > * and update the available trace data. > @@ -648,6 +653,19 @@ static void tmc_etr_sync_flat_buf(struct etr_buf *etr_buf, u64 rrp, u64 rwp) > etr_buf->len = etr_buf->size; > else > etr_buf->len = rwp - rrp; > + > + /* > + * The driver always starts tracing at the beginning of the buffer, > + * the only reason why we would get a wrap around is when the buffer > + * is full. Sync the entire buffer in one go for this case. > + */ > + if (etr_buf->offset + etr_buf->len > etr_buf->size) > + dma_sync_single_for_cpu(real_dev, flat_buf->daddr, > + etr_buf->size, DMA_FROM_DEVICE); > + else > + dma_sync_single_for_cpu(real_dev, > + flat_buf->daddr + etr_buf->offset, > + etr_buf->len, DMA_FROM_DEVICE); > } > > static ssize_t tmc_etr_get_data_flat_buf(struct etr_buf *etr_buf, > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel