From patchwork Tue May 14 19:40:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10943693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 678646C5 for ; Tue, 14 May 2019 19:40:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 574E8288E2 for ; Tue, 14 May 2019 19:40:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B7B5288E6; Tue, 14 May 2019 19:40:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DEDAA288E2 for ; Tue, 14 May 2019 19:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QWfpsZCJTRFQeDaPwuzRHs5u9kV/KHyREfWH4GdMaiw=; b=oGooCV4/P0mBVSiThCtii5WmfK R9tTPRWhMS+pSyxxDFPmKVZfj/YDOgPP3f+WAG8dn2l6+hVha0sVHNsikWBIPoGYmnPf71gaf17om 705ZHmE+2myMw8qK4Z41kG+H26QsG84bhqF5P7rERwf6SOWr3Eh7EykXbe7QkPJSqTAxarzyKEp+U 7Lue/658WDL91zr1fgRCLIHf9kB2lTJH3Nbc93i2i6gWgNYz3/7cjSLdtfxfef+sfz43SSRVDIX+Y Vw2lzm+CoXB03TtIQlD4KHGkp/2pWzCYi61kfhd78en++Ae+6SbfGorRnghOYp3vDHM4T2sQv67MZ pKM/slTQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdHt-0006OM-Jw; Tue, 14 May 2019 19:40:33 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdHj-0006FY-2Y for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2019 19:40:24 +0000 Received: by mail-pl1-x643.google.com with SMTP id f97so105667plb.5 for ; Tue, 14 May 2019 12:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Xpd5fXby+7ekbmSJL/l5IgMLyrh9k2LAW0LAUPjY/8=; b=pIIANLrZhKqr2Fkh7C78m66NcKxrJVDij+1KZsZeOGF17vSoHGgodtnEYmpBobXjPz cfMMa12eAB3UL39IcMaJpuecD4/zq384Tw2Yetz7jKKTsuI+7rD4lJXq09bSsnOKSU6g kW/npFVGXFftSCPBEjY0JkYT9zTHgwsT2tI0RT6BG8bV//YTisJfE+xu+j7B4KAAgRyx BlQU4t3uOWYSxDb1nqpf4clAfeWxd+QuPH/Np2GZs009YZ4IS2PrcRkm+9p2+XvoET1F ZVJc+lo5lA2kv2Gkpy/zPMWOL2yb7IYWiJf34p4TNhcsF1NBUkSN3nuu5UB1ItvvYgYp m/sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6Xpd5fXby+7ekbmSJL/l5IgMLyrh9k2LAW0LAUPjY/8=; b=ddWZtiORAAa/oVqaGbTbKc+NMBjGwkZor32o6H8w8RKEA/sS3Hm7AcXWKkiag8aG7i QOE61iioSXKz7OduUCAU4NLvhyqXxobnKvcJIO83Ry26AtlmmeZuz05yaeBY4KTZk/iE UYDaERI81Fk68nFJ0GTKa9v053zEnCZO/5NKpJSUgK0yKq7xW8PgwJEpH20TNZZ1Tcq+ /omoerfNQN9hJc089MJEAeSoQXr8YPQZi/H8PxlrE7a9/nZQjQ17rSjBjd4ZddPxptf0 Yp05KB9XMAXySnYGrWIA3kzqFIjD6GF3iGEDaOX5yRI4exfcN8HUxKq3EDLzRY7lX0+r 29GQ== X-Gm-Message-State: APjAAAX8XnKp4eYQ40kkHdO3Tpz4eZc17+Jx/Tb1ItF68pMPnUtV6EAG iDMd5FQGvYr9356oe1oCksq2M82Qva0= X-Google-Smtp-Source: APXvYqwMLGXfFNFWvtXZg67czC687qRDohmxuHMnmeo+hQ11WZtQSlnx57Y/9WBgt8drUlR2t1QX/Q== X-Received: by 2002:a17:902:22:: with SMTP id 31mr40062070pla.15.1557862821987; Tue, 14 May 2019 12:40:21 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id w66sm5791196pfb.47.2019.05.14.12.40.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:40:21 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 1/6] coresight: etb10: Properly set AUX buffer head in snapshot mode Date: Tue, 14 May 2019 13:40:13 -0600 Message-Id: <20190514194018.23420-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514194018.23420-1-mathieu.poirier@linaro.org> References: <20190514194018.23420-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190514_124023_112773_358C0A29 X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, leo.yan@linaro.org, mike.leach@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Unify amongst sink drivers how the AUX ring buffer head is communicated to user space. That way the same algorithm in cs_etm_find_snapshot() can be used to determine where the latest data is and how much of it to access. Signed-off-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etb10.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 4ee4c80a4354..60e753b1768d 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -548,13 +548,14 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev, writel_relaxed(0x0, drvdata->base + ETB_RAM_WRITE_POINTER); /* - * In snapshot mode we have to update the handle->head to point - * to the new location. + * In snapshot mode we simply increment the head by the number of byte + * that were written. User space function cs_etm_find_snapshot() will + * figure out how many bytes to get from the AUX buffer based on the + * position of the head. */ - if (buf->snapshot) { - handle->head = (cur * PAGE_SIZE) + offset; - to_read = buf->nr_pages << PAGE_SHIFT; - } + if (buf->snapshot) + handle->head += to_read; + __etb_enable_hw(drvdata); CS_LOCK(drvdata->base); out: From patchwork Tue May 14 19:40:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10943695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A0C492A for ; Tue, 14 May 2019 19:40:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07D69288E2 for ; Tue, 14 May 2019 19:40:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0431288E6; Tue, 14 May 2019 19:40:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9C388288E2 for ; Tue, 14 May 2019 19:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zJVJqR0qsk9Cyvm+CBwRx2K6mjDtojIfm+7oPEl7eOk=; b=BmU/9k6ZMh9Y2KJEsDWmNgaO4Y c3sZn9KwI6kxEzloIJWTwnFr4AIjkaa0EVCJfHyIJb+hgaUw//56S523OURcwvL9m44jT6BhjbhxK Wg48qq3gRso3hXqhxFPQ1IUZQHq/2mg3hjTa+iDC6mHtEJgG1m2ywB0xMvJWG3CQsCZjTeH7jLe/P WGbV4w5J4SSewbbi7xcepBUVw2RnvjCLp/Fkn5bUvqM1+EYMwkKD9rXmJDzmmGuemOJPrf0wEbJqB /ELqwcNdmUZ91vkctx7ZU7CrVoEYafUAlMtLgWZb1gyIM7sNKeSUpoTXaWH7vl3BHPM+Ti1SErXOc lVpJ69AQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdI6-0006ie-8w; Tue, 14 May 2019 19:40:46 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdHj-0006Fx-RL for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2019 19:40:25 +0000 Received: by mail-pg1-x544.google.com with SMTP id d31so70145pgl.7 for ; Tue, 14 May 2019 12:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+AhN3Bvjm6iExjpvfnaKjLZ6Hur3GYpc1/lk5q3y4p0=; b=ffGExovUSLhtcOKqbyTXzRlHzMpyVLs5ai0l4CZ8LqjMkSlA3Ln6kWmowCiuhEs8h9 WgcJLKyZhJ+z8JA2XpxMxxvNnoxZkw2mJ87u0CoLKHJ0kCSge9GVUomZqvUnlLYXd6zM OZnLv8FCLugHEnkH9wni60vjwz6D7sgS6ZII4ML5eiZ+soWJBBlBMJwa0UsIkEtCc4bo pcCuaW2MEAzib9wTFRNcQKO63HctbFqv0Iph0nOh+1otPV9LwFo3ITIjESLvjuz+o5hq KRH0Gax1S8Lx7K+t7cxQGfCMGU80Kr4ioxHFCq4zBIgs9sCHF6KmFtMAbjYjSRsQQ8TM Zijg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+AhN3Bvjm6iExjpvfnaKjLZ6Hur3GYpc1/lk5q3y4p0=; b=p6jW8HRhgtzQRfXNlO4uLc60Sl7sjTPi69D8v3EEGrZ9uevWH9jGiV7FgICJXlcnDc DJuwJlrn0Mm6iUZXk34IHbteSNHzKgso3s47eRihF/67xrFJGiUs4PXb31L9PmmavNMC 5RMMUOehS7brx5B5JCl3X72KICsGzvM53+fVe4o/2qVacOeYY6Aori39ypo0xLpQl9Pp CBf4hpSd9dGriIMfn+/eW8jPWEc8Xz7OnPTtBGarGBGxIqAWohvyhOMF9u+SUpa4qyc1 8A/KADmH4pI/Eqh+cyViSZ/WP9Ou5IAN2Nc/xVARsKYMfiqk0hanW0gu9ircYApg1bV9 tnOg== X-Gm-Message-State: APjAAAUBPPyztNZaunLhKkmsYncY/uzwv9i3Ke+6Jz8GaI38z36rKKTy 4Ef086ARcMeU5fXXLphCtCGhBmp2KFo= X-Google-Smtp-Source: APXvYqxQnuHPyiJxOcjfiMT2ToXf2Pynp+AgagCoPx9qjPtyO3u2zh0otNBTtQ68qiBpNENECDlU1g== X-Received: by 2002:a65:624f:: with SMTP id q15mr40053183pgv.436.1557862823074; Tue, 14 May 2019 12:40:23 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id w66sm5791196pfb.47.2019.05.14.12.40.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:40:22 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 2/6] coresight: tmc-etr: Properly set AUX buffer head in snapshot mode Date: Tue, 14 May 2019 13:40:14 -0600 Message-Id: <20190514194018.23420-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514194018.23420-1-mathieu.poirier@linaro.org> References: <20190514194018.23420-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190514_124023_880324_348ABE60 X-CRM114-Status: GOOD ( 13.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, leo.yan@linaro.org, mike.leach@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Unify amongst sink drivers how the AUX ring buffer head is communicated to user space. That way the same algorithm in cs_etm_find_snapshot() can be used to determine where the latest data is and how much of it to access. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index df6e4b0b84e9..cc8401c76c39 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1501,14 +1501,13 @@ tmc_update_etr_buffer(struct coresight_device *csdev, tmc_etr_sync_perf_buffer(etr_perf); /* - * Update handle->head in snapshot mode. Also update the size to the - * hardware buffer size if there was an overflow. + * In snapshot mode we simply increment the head by the number of byte + * that were written. User space function cs_etm_find_snapshot() will + * figure out how many bytes to get from the AUX buffer based on the + * position of the head. */ - if (etr_perf->snapshot) { + if (etr_perf->snapshot) handle->head += size; - if (etr_buf->full) - size = etr_buf->size; - } lost |= etr_buf->full; out: From patchwork Tue May 14 19:40:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10943697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95C2992A for ; Tue, 14 May 2019 19:41:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83D7A288E2 for ; Tue, 14 May 2019 19:41:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76809288E6; Tue, 14 May 2019 19:41:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1CDCD288E2 for ; Tue, 14 May 2019 19:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=J0Khitkirf5GxFLFfBxqNelz1q8r19yumkNU04NVMmQ=; b=Jm/s5Zwl3Sg/fMbpO8gfQWzMc2 Am2knOHMKU5NUAYQBgq2Reby4j4bY7PtllZ693i3rcavALU2a+LYCYCjPyR1tLhT5h9uqQDoOyq3q Khn1+0JSr9m+nhtDVvxXUb91AyzWzaKruw/F0kVNSjClynepNU7vhvDZ18q3LL9NmyiJzn/aLYpRO mdEB6f5wgHNAp7+wUUuIMTCL/89/cAwwzZ7gZ69tLWnD+ib9ByLn1LPwP8RzdZbbqPaG0CpGTLBHb 7FBPxFdzqPidQW1D/bF0QMWiGzuksSzO2q00YWXpThSTIzYTGGK1w26xWBQn4fSR/uMq+U1yCxgud M4luagDw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdIG-0006xV-2F; Tue, 14 May 2019 19:40:56 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdHl-0006GN-3N for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2019 19:40:26 +0000 Received: by mail-pl1-x641.google.com with SMTP id c5so91387pll.11 for ; Tue, 14 May 2019 12:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cMypeu62+O4d2QQyEv5D1H2MRXYlgCP4kYc0ttWa7FU=; b=JuInKa9BA8nX08TPGghqjluce0xuM9Ra/gvISgsbbNXkIN0szR8TAWCEezVYz1SlCw XmZgZwKLIyoDw6wpylHWySLVnVNd/oHnI3mHpYrSD+0eMoFvD/2oOltW1Tr4Z/MPCoB+ oDLhh7JWgRMl/YjAiAZjGOPnoMQ1AuYIAXo2MZIPWuISZ0fwoeQhGpFgLB6XoaWZyqB9 7M+ul91cdOYMUbLlbGXPG7M4lbgtjGr1k31Fq6e+WFII8ka4xlm87+/y6IpOQYD6x0Qc Nu45dwXLt0hQnPGJ74GsWlMotaNmZmHo6PPW0BPLgu8f9kqBYdtP+6nmEQePiZrTAmDm pCBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cMypeu62+O4d2QQyEv5D1H2MRXYlgCP4kYc0ttWa7FU=; b=RCLkzGtElMO7vpBCEPhj83TPwgIFCQT5AyZ6mLVFF43BVuKlpSArTTWog769Wqdu0G a8lS4uCLkWHYTDfKN94d3y6osuCkkxYO0AZaQ3VCfst6vAjaNxm7gmuM6wy9IO+b4Rnr dyZafmQyJlEG6VRcrGcLATu+ggrNJ4ENqoeOcRO9EJxqhCEtzVcGFOOIGnu0ki+pKeHt Xe9XcqPqBxUyZf2m0tYlWE/eFJ1MKydDdlpZDC7BGzcLytcVNywQBGN8E5vfS8puXj6j xVCVbTTSIxt0dhpPYsdsph5ztXtj8zRwKOvUeF5e9StR43voDaXdE8zxwgNzvlkJEvDv 8kBg== X-Gm-Message-State: APjAAAXs4Yd7umHlTX1MAVNqKZovcBro1vGNHUiwIiPy9Kb55q2Pevnr LgvIwbPYQwdVFqeB4YV34hS6XckCQsw= X-Google-Smtp-Source: APXvYqyW4JZffl68wHTIwJqUFBCZKdQ1h1s1FVDOvj2vyVA+bR+jiEOFxbpqvPl4LneRm1ltl2Q5fw== X-Received: by 2002:a17:902:42:: with SMTP id 60mr39788701pla.79.1557862824173; Tue, 14 May 2019 12:40:24 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id w66sm5791196pfb.47.2019.05.14.12.40.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:40:23 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 3/6] coresight: tmc-etf: Properly set AUX buffer head in snapshot mode Date: Tue, 14 May 2019 13:40:15 -0600 Message-Id: <20190514194018.23420-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514194018.23420-1-mathieu.poirier@linaro.org> References: <20190514194018.23420-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190514_124025_136499_2F33BFAD X-CRM114-Status: GOOD ( 14.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, leo.yan@linaro.org, mike.leach@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Unify amongst sink drivers how the AUX ring buffer head is communicated to user space. That way the same algorithm in cs_etm_find_snapshot() can be used to determine where the latest data is and how much of it to access. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 2527b5d3b65e..d026bd04a6af 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -542,11 +542,15 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, } } - /* In snapshot mode we have to update the head */ - if (buf->snapshot) { - handle->head = (cur * PAGE_SIZE) + offset; - to_read = buf->nr_pages << PAGE_SHIFT; - } + /* + * In snapshot mode we simply increment the head by the number of byte + * that were written. User space function cs_etm_find_snapshot() will + * figure out how many bytes to get from the AUX buffer based on the + * position of the head. + */ + if (buf->snapshot) + handle->head += to_read; + CS_LOCK(drvdata->base); out: spin_unlock_irqrestore(&drvdata->spinlock, flags); From patchwork Tue May 14 19:40:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10943703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65FE992A for ; Tue, 14 May 2019 19:41:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55753288E2 for ; Tue, 14 May 2019 19:41:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49DF4288EA; Tue, 14 May 2019 19:41:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EAFCF288E2 for ; Tue, 14 May 2019 19:41:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FTYFI7ktieYNw9yNB4FrREnpw+nrdsoejxZ2tuKmg+g=; b=m+HOOdi7MSnbkKqTUVLesrlrfq uwflO4q2j86n9IOHzG5I45CXr8Qe0b1ZiPIc09Q2H/LuM592IOnzm7Y2xtvRbH3hW6NVmmFrjSwow vxo3teoX8FAyPy/qjYiI/CzWE22/VNeyFQ1VzvTrel5s0qXHhqhrtg58wNhRl8wcSKJXAfQxdl3s3 /UPJxJnvEJoZxIn9RQpq7wrwvFudL7cDxZg8EE+lvsW0/LhSaKZUwhpx3KkBmhQJiVE74qKr4A9dn 98xKMH/Hn4k2fMYXQv1y6alkRz/RYdrAjeTmHclawyN9F08jTPGNOsCpVcL7V4SSAe2X7Ia0hLqWO TsS5yjNw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdIR-0007B7-K4; Tue, 14 May 2019 19:41:07 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdHm-0006H1-4j for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2019 19:40:28 +0000 Received: by mail-pl1-x644.google.com with SMTP id f97so105728plb.5 for ; Tue, 14 May 2019 12:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ahqTbyLxNKiH4aCMkEpTRiwITDmQrozYIS4vKSWki9g=; b=gAq8XVBmDwYtTZ7sHtRfMR64RRvAik45Y0DUQ1a3aXwTJYSFIXudMVBILW3BiwG5bS Lx+lW1OyeysKsnD0T4JYNcUVVVTp4ZVBK/Kb0jZzP4HSiCnBpHYDSfDdjOvjNe1V4Box bjiQKdfISfQSHaZn9YS65bMokwZSfx+NjdksfSguA2oJIgcVJZp2tjJliP+/4Y8+HE3V xPAmaLJUAWIMb0Ctj+N4V1JCBr9ZuuP9v4lwDCNsclh6CtN58ppOHvqPndreL9gtcc1S bD/ExmNCtH6rQ506VGCKBgANlu7RU2491pvsge1XeylAUSvDDy3xN2m2rh7en24/Mp9a P3qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ahqTbyLxNKiH4aCMkEpTRiwITDmQrozYIS4vKSWki9g=; b=PJ/+OfMSMaWKwLWjZ6zO6/ErENUlN3tSkyy9egOGVuisL21HoOmeYg/ncL9agtK1e5 1SPHucr6jGlfd016rt4j9FxMNBYL0nGiV5rGoIPtuVhW8Enoh2sGAuqp2dyQSvTgbBpS r5Ng4O5jINtADShf1bYGPWIAT/9n+WMO8QjItW6Osfpibzc+0LUMmD81Cy63R9pkbw50 bnGoGCqGnoC8dq05L/Ob1xFEZvZa7yP/JQh/W6CAdshpeNxlhFmQ0uPAOCPVlGb2xU3u D7avT8Tg3gvMXn2OpQ4RhHhfBuQrOQJjvOKs7syyEwMtfWNLUQwsqYI09ubC702vmRs4 lc/Q== X-Gm-Message-State: APjAAAXGQrkNpFQeZfml3LwP/t0ZOB5Y1X9XqrJWhoocQ69syAsm43F/ ZMIIe3SXzt+bhcOfuZ1VmQZqMTxFN/c= X-Google-Smtp-Source: APXvYqwV+d498s+0xPnmEZGl1ixcG6xHhVsUC0a+p0XsVpmUY7HfTlJrRbzjHDEY9c3CMnY/KpAekg== X-Received: by 2002:a17:902:b490:: with SMTP id y16mr10431038plr.161.1557862825253; Tue, 14 May 2019 12:40:25 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id w66sm5791196pfb.47.2019.05.14.12.40.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:40:24 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 4/6] coresight: tmc-etf: Fix snapshot mode update function Date: Tue, 14 May 2019 13:40:16 -0600 Message-Id: <20190514194018.23420-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514194018.23420-1-mathieu.poirier@linaro.org> References: <20190514194018.23420-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190514_124026_293071_E3FD4DC4 X-CRM114-Status: GOOD ( 13.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, leo.yan@linaro.org, mike.leach@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When working in snapshot mode function perf_aux_output_begin() does not set the handle->size because the size is expected to be deduced by the placement of the "head" and "old" pointers in user space. As such there is no point in trying to adjust the amount of data to copy to the ring buffer. Signed-off-by: Mathieu Poirier Reviewed-by: Leo Yan Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index d026bd04a6af..31d41e2ad955 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -477,9 +477,11 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, /* * The TMC RAM buffer may be bigger than the space available in the * perf ring buffer (handle->size). If so advance the RRP so that we - * get the latest trace data. + * get the latest trace data. In snapshot mode none of that matters + * since we are expected to clobber stale data in favour of the latest + * traces. */ - if (to_read > handle->size) { + if (!buf->snapshot && to_read > handle->size) { u32 mask = 0; /* From patchwork Tue May 14 19:40:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10943705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11C9092A for ; Tue, 14 May 2019 19:41:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0B9C288E2 for ; Tue, 14 May 2019 19:41:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E31CC288E6; Tue, 14 May 2019 19:41:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7CA6E288E2 for ; Tue, 14 May 2019 19:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=a60V8qTH+wA+KGm2OezvlAWhInxNHz/mbqei7GSV/tE=; b=G2Rsa+ojhTn4VduyrTzE3YXxHI oAE79xxb8ZYYQvlQoT12f28syuiTjieclei6D04H5Dh6WjFn8whSgaBf92TSj7yEjRjWj0+FgfdUl 3KioWRuuMQQVgS3cLV6yxUWG6qerz/fDskB6HqK6vlisu9iYEJeYAPBray8X3dCq5EK0Hx7VkJt+n 7iZd9PDltb1GwaJfcJHOxtbbw4x3bmtJ25iQxR8ZU3+AI1v1g7k3WQDkoctCKYT/wYkJUIYy4Y2Np 13Zm/GUa4n4q0oDyhsr7NPwwwZdTVjeENmxdhcnU0KazMULRMHNzPRAfYrtdS67Es6QOT/y+31mlz b6HiAeFg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdIb-0007Oy-1I; Tue, 14 May 2019 19:41:17 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdHn-0006If-KI for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2019 19:40:31 +0000 Received: by mail-pg1-x544.google.com with SMTP id i21so58247pgi.12 for ; Tue, 14 May 2019 12:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nzcbkHx25LwhIrDMW7jKp49bMtN7zqAQcn0716JxD9M=; b=JdYE77h0RFDTmuyEGuR3jo6VsWVTe+FxwDn4E5zYketf8cPNJ6vS248H8GDTzWk1Se vwbDphS99XnZ9WP6pQLoYSdDnUniQwG+rr7Jx6mYjt86sw8kPDf9LCgPzVLSkf4xJ1G5 vq03H3MuY1IM8LE8kW07YkTN1UtW6StD1umOPSOv4AQnj1Euk6PJrCbQibhLVRot3rXM iabHab7X8NHUDi5/rsWKPnVqygnTtPMPmzLFL+bel9msLDDWPw9pBoqW5eraJgDgEXQY VRGoEvvJWLgHKf79kGS/IifwlN5gaAHaR87QpfXur6dHzGQAiCp1kE9NIyy1xFrad6Nx fHbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nzcbkHx25LwhIrDMW7jKp49bMtN7zqAQcn0716JxD9M=; b=Uc5AhhliWaQherqpw3n/tv5IANTRRsqqKCYxuF6OKXCUpVCKXmjpExtxTdQ5E73mbG OFRufdU3V6+8Yl9rLp1c8tvdXg3tEwEfD69x4gn5TZrS0gEZfHL0WaqX7uubZJueKsk9 AS/Cp7EU7TkHLjF9ENdiFRoLzCO2TFLe5ksRUFSWQ8WZOOwwcIjMRIlZ0M7olYQ1wQTw Y6TdZ13TjITcIujxx3PGouSM11FH3cR+1IyfQ4zX8D8kpM5vmaEP1x8Wub2PZ/J96kgX 6ZxCj+vN8Mn8PoaLsSwtUaRYY7xIv0YbUk5OPFXKcFVngUHo2GsOOMiauuUR2Yc7G0LM eZBg== X-Gm-Message-State: APjAAAXr7qQkoDIFfsR6QAlOuUWaRY4xKg3DoVWPx02UL9g5LNfM8SZa qbNDEBnAdXV+kqU69uI7U6H5WRTML9w= X-Google-Smtp-Source: APXvYqyGleCvseNrN10LWXodWjUoaVsZ8LmdeZt/3/SX8odQ2hok+ELweJ5t+Yc1Fqe9NZAte8MUCQ== X-Received: by 2002:a62:86c4:: with SMTP id x187mr42066910pfd.34.1557862826843; Tue, 14 May 2019 12:40:26 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id w66sm5791196pfb.47.2019.05.14.12.40.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:40:26 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 5/6] coresight: perf: Don't set the truncated flag in snapshot mode Date: Tue, 14 May 2019 13:40:17 -0600 Message-Id: <20190514194018.23420-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514194018.23420-1-mathieu.poirier@linaro.org> References: <20190514194018.23420-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190514_124027_873556_E30AFFF9 X-CRM114-Status: GOOD ( 12.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, leo.yan@linaro.org, mike.leach@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch avoids setting the truncated flag when operating in snapshot mode since the trace buffer is expected to be truncated and discontinuous from one snapshot to another. Moreover when the truncated flag is set the perf core stops enabling the event, waiting for user space to consume the data. In snapshot mode this is clearly not what we want since it results in stale data. Signed-off-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etb10.c | 8 +++++++- drivers/hwtracing/coresight/coresight-tmc-etf.c | 8 +++++++- drivers/hwtracing/coresight/coresight-tmc-etr.c | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 60e753b1768d..516d67cd7759 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -512,7 +512,13 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev, lost = true; } - if (lost) + /* + * Don't set the TRUNCATED flag in snapshot mode because 1) the + * captured buffer is expected to be truncated and 2) a full buffer + * prevents the event from being re-enabled by the perf core, + * resulting in stale data being send to user space. + */ + if (!buf->snapshot && lost) perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED); /* finally tell HW where we want to start reading from */ diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 31d41e2ad955..bd5f3b57eebd 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -518,7 +518,13 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, lost = true; } - if (lost) + /* + * Don't set the TRUNCATED flag in snapshot mode because 1) the + * captured buffer is expected to be truncated and 2) a full buffer + * prevents the event from being re-enabled by the perf core, + * resulting in stale data being send to user space. + */ + if (!buf->snapshot && lost) perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED); cur = buf->cur; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index cc8401c76c39..1fc3db8045e1 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1511,7 +1511,13 @@ tmc_update_etr_buffer(struct coresight_device *csdev, lost |= etr_buf->full; out: - if (lost) + /* + * Don't set the TRUNCATED flag in snapshot mode because 1) the + * captured buffer is expected to be truncated and 2) a full buffer + * prevents the event from being re-enabled by the perf core, + * resulting in stale data being send to user space. + */ + if (!etr_perf->snapshot && lost) perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED); return size; } From patchwork Tue May 14 19:40:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 10943707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DEF346C5 for ; Tue, 14 May 2019 19:41:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD583288E2 for ; Tue, 14 May 2019 19:41:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C155A288E6; Tue, 14 May 2019 19:41:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 488F1288E2 for ; Tue, 14 May 2019 19:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FrDGJxrPTolm2LmYX4qIhYLKSsSe91euIg3U/Kq3bhg=; b=noDeQ58AFwvCAb+p8mE0GLDZ8B Ym4tDMvkEZ/9/wcTunFrQxYHR+2mirHD4sxX7tVbdv4brv+Rbnff6yX5twRZD+v09gUCeCE6OMZe0 ooeD6suBZBQ9vLcCDDn9nn/lkMFG0dHYuLI8jX3lEFcfqudj1IAOX4ITnKCCMmL0WH9a6iGO6iTqM VtvODzsDChOrhWmhN8e7eIQo4mtoXFqZ2bQ02HlgfFRn3nU+eqhP3u3qjfyKI3ipX3mljh99hvBl2 8CIxqY8J3eGfZTxLpawVk8bvydwyObl+3hCkin4iOizmSPhQmNTmVyIyWp28pUF5T2ulw/Jp2zLy1 hgHNBkrQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdIm-0007d8-M0; Tue, 14 May 2019 19:41:28 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQdHp-0006KF-4N for linux-arm-kernel@lists.infradead.org; Tue, 14 May 2019 19:40:33 +0000 Received: by mail-pl1-x642.google.com with SMTP id n8so93213plp.10 for ; Tue, 14 May 2019 12:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ia/ySUxJkS3+hSIVLq78ZfkCxtyaJMeE+VOuGmqDALw=; b=qUgM2GWnBZEb56b7w82k9bjLgD8urRgngidn8AER1w1Gw2/lSjB83lCYdwMaaUHjJn djkg5WlBoXvr0H/jLM48sGThCCfdo0ABClOCASoheI1EMgdcC/ZucBK+WBfZyojuqh9l 2w80vOvVpIw8LJc6ffk71cR+oSNotsgHsPXdcj2rc2sKgCHkQKYj/WOQHAnGLTWxhMpj UsfKdjIxguoVWXYvEFC5KVabKhyQcRru6tr24nw9jTjgs/qEbCKHf3ZTxUwN3gTxeSkl 34b+EfoS2O+UHNGwqqjymJwu/0h87Xayy10/zw8JJ6ROcwm6ECDkTIFp5HdSQwS7uEI7 9tJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ia/ySUxJkS3+hSIVLq78ZfkCxtyaJMeE+VOuGmqDALw=; b=NvXNfK2lAfgUafO0N2uJ4OXWDpIAzyx7Bu4f5b36IERr6bkkGiLU8mXM7Jcj90uLwv WCuLT7eurGnj3vXcYZa7obBbr/7CdHwF1NUWGNjZSB/aDSAor8NHbk3aHGuAklCewnIx 6I/sxEmC09iBr70PsWldt1hXutGxqlkrTrErKjMhXpBA5tgk8ovbYEDyVqUaIK7dVEbr fOSCsrXuYCxlmbKLNOqr6h+FIlSADYKII209kzcW6ON2I79nvit/zpa+X4r0Hli85R0N PseWTsgWe/SHaqZ4X/d431+Ga7poExOuRu4QRXmweEgmHwhB5Y2H4n3DpE82iTLochZy evpQ== X-Gm-Message-State: APjAAAWzQa8jZGRp6QUtDKjn/l7o8XnqYaQS6YPPgg1zatUjAKr3YV5r KuF+2ytxkWXfM3Wx0Ko2BGMLbQgued0= X-Google-Smtp-Source: APXvYqyF1VnSiyFI3hyzpwKsDCwRgFp6cjiTx8SBby6RvC8Uoul668rWaG0PyrdbWrfTqp5UzSlY4Q== X-Received: by 2002:a17:902:5c5:: with SMTP id f63mr38408813plf.327.1557862827979; Tue, 14 May 2019 12:40:27 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id w66sm5791196pfb.47.2019.05.14.12.40.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:40:27 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 6/6] perf tools: Properly set the value of 'old' and 'head' in snapshot mode Date: Tue, 14 May 2019 13:40:18 -0600 Message-Id: <20190514194018.23420-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514194018.23420-1-mathieu.poirier@linaro.org> References: <20190514194018.23420-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190514_124029_530781_DA7F2C8C X-CRM114-Status: GOOD ( 22.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, leo.yan@linaro.org, mike.leach@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the necessay intelligence to properly compute the value of 'old' and 'head' when operating in snapshot mode. That way we can get the latest information in the AUX buffer and be compatible with the generic AUX ring buffer mechanic. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 124 ++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 5 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 911426721170..3734e3fd18f8 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -31,6 +31,8 @@ struct cs_etm_recording { struct auxtrace_record itr; struct perf_pmu *cs_etm_pmu; struct perf_evlist *evlist; + int wrapped_cnt; + bool *wrapped; bool snapshot_mode; size_t snapshot_size; }; @@ -536,16 +538,126 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, return 0; } -static int cs_etm_find_snapshot(struct auxtrace_record *itr __maybe_unused, +static int cs_etm_alloc_wrapped_array(struct cs_etm_recording *ptr, int idx) +{ + bool *wrapped; + int cnt = ptr->wrapped_cnt; + + /* Make @ptr->wrapped as big as @idx */ + while (cnt <= idx) + cnt++; + + /* Free'ed in cs_etm_recording_free() */ + wrapped = reallocarray(ptr->wrapped, cnt, sizeof(bool)); + if (!wrapped) + return -ENOMEM; + + ptr->wrapped_cnt = cnt; + ptr->wrapped = wrapped; + + return 0; +} + +static bool cs_etm_buffer_has_wrapped(unsigned char *buffer, + size_t buffer_size, u64 head) +{ + u64 i, watermark; + u64 *buf = (u64 *)buffer; + size_t buf_size = buffer_size; + + /* + * We want to look the very last 512 byte (chosen arbitrarily) in + * the ring buffer. + */ + watermark = buf_size - 512; + + /* + * @head is continuously increasing - if its value is equal or greater + * than the size of the ring buffer, it has wrapped around. + */ + if (head >= buffer_size) + return true; + + /* + * The value of @head is somewhere within the size of the ring buffer. + * This can be that there hasn't been enough data to fill the ring + * buffer yet or the trace time was so long that @head has numerically + * wrapped around. To find we need to check if we have data at the very + * end of the ring buffer. We can reliably do this because mmap'ed + * pages are zeroed out and there is a fresh mapping with every new + * session. + */ + + /* @head is less than 512 byte from the end of the ring buffer */ + if (head > watermark) + watermark = head; + + /* + * Speed things up by using 64 bit transactions (see "u64 *buf" above) + */ + watermark >>= 3; + buf_size >>= 3; + + /* + * If we find trace data at the end of the ring buffer, @head has + * been there and has numerically wrapped around at least once. + */ + for (i = watermark; i < buf_size; i++) + if (buf[i]) + return true; + + return false; +} + +static int cs_etm_find_snapshot(struct auxtrace_record *itr, int idx, struct auxtrace_mmap *mm, - unsigned char *data __maybe_unused, + unsigned char *data, u64 *head, u64 *old) { - pr_debug3("%s: mmap index %d old head %zu new head %zu size %zu\n", + int err; + bool wrapped; + struct cs_etm_recording *ptr = + container_of(itr, struct cs_etm_recording, itr); + + /* + * Allocate memory to keep track of wrapping if this is the first + * time we deal with this *mm. + */ + if (idx >= ptr->wrapped_cnt) { + err = cs_etm_alloc_wrapped_array(ptr, idx); + if (err) + return err; + } + + /* + * Check to see if *head has wrapped around. If it hasn't only the + * amount of data between *head and *old is snapshot'ed to avoid + * bloating the perf.data file with zeros. But as soon as *head has + * wrapped around the entire size of the AUX ring buffer it taken. + */ + wrapped = ptr->wrapped[idx]; + if (!wrapped && cs_etm_buffer_has_wrapped(data, mm->len, *head)) { + wrapped = true; + ptr->wrapped[idx] = true; + } + + pr_debug3("%s: mmap index %d old head %lx new head %lx size %lx\n", __func__, idx, (size_t)*old, (size_t)*head, mm->len); - *old = *head; - *head += mm->len; + /* No wrap has occurred, we can just use *head and *old. */ + if (!wrapped) + return 0; + + /* + * *head has wrapped around - adjust *head and *old to pickup the + * entire content of the AUX buffer. + */ + if (*head >= mm->len) { + *old = *head - mm->len; + } else { + *head += mm->len; + *old = *head - mm->len; + } return 0; } @@ -586,6 +698,8 @@ static void cs_etm_recording_free(struct auxtrace_record *itr) { struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); + + zfree(&ptr->wrapped); free(ptr); }