From patchwork Thu Jul 1 09:35:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12353799 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=-17.2 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,USER_AGENT_GIT 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 839EBC11F64 for ; Thu, 1 Jul 2021 09:37:55 +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 491456144F for ; Thu, 1 Jul 2021 09:37:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 491456144F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kJf6VEagLcqb+JIL1rt1dNLcck0J4gpfVOjWcAB9MFg=; b=lclsYeQbUbad4k v8fc3V2/Jf4L+bCugTXP2SLQ3vb/ahxqD5zXKM1U9Po+pcknE4zfcBhC/2U+uxugJhWaM3iNuQeFy jw3CAeM2cVRQza4MlChJ0Uqvm6okp5j0Oms+ziFySSpN/YD5X7sGN1Tu+w7h3BMGoLA1aFg4tUtVZ d6RG/FsDB/25So6vNun9GtWKGanqQCdEwspPSl8MqVak9kYxlZBUNHEaSoWivUkHkmh+0s6bl0rFN jtLEHrN0DSyLh5UyWFjZAjzn2MpjBjTMtLMLBC4iAT6oCi2Ql2rKyOsKh165AHbIrfYZdP/+6C1dM p45VSacjywWle6Qv63KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyt75-00GjgU-0l; Thu, 01 Jul 2021 09:36:03 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyt6s-00GjZy-9K for linux-arm-kernel@lists.infradead.org; Thu, 01 Jul 2021 09:35:51 +0000 Received: by mail-pj1-x102c.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso5552773pjx.1 for ; Thu, 01 Jul 2021 02:35:50 -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 :mime-version:content-transfer-encoding; bh=iOBrU4X33EUBp4V/EjniBEwO3Y3JQt4rdTBeDxZ3ZjU=; b=Ro1G/8XHQBw9DM1CucpCzm+2U1QDj91479BVtMly5lyOWUDTY/gPVNDj97n77bym64 xe5oz7XC98GOW2PI1+kHWmhbfS2iLsEFoDZwnuOeQ536ORkNb2sHJc06VrmFtwkvChMb YUccL9tiXyZPPjdBBFLjCFI3bdhxycwVeiPxufhb14Q1lP3juZGmR7rzoCX2ClH4QrTY 6uOh8pDKBwDsLBPKl6wDKUNOLznX1Op8pDrIErSrd+LgTM6KkqX59zxYwt05aI4uEmDj PHkjKAY1rDlw40WmUXZ2KIhG9HxRMhvoXMLZxPYcxX13DX5uKkyBSWmWV4z2XaxNetKq k7eQ== 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:mime-version:content-transfer-encoding; bh=iOBrU4X33EUBp4V/EjniBEwO3Y3JQt4rdTBeDxZ3ZjU=; b=XLBAuOZlDWOgap4O3ItHED7X4oPdHr3+yhU1ShF/PPqMpNyw7XaBXR9hjFHCS0yuCl mocmWobP1UHEKPa5zsal+7u6LZsLJx8i3V69s1gOYmPoM21wGtCbBw8PjQhSrbr8SiVz nzsiSCRz9v4rt4GHlPFVGnZ2YlGYpthjOfXQM7ISHsoUGvAZq1Ye/7Xo5cyafZYJx/3b 2KFEpSUmdohFU5nj67qq3TbvUP5ENvxt8erSqAquOkkvQI1GVM6GvuDAjm2cIq/iiyr4 ZI4Yeb819CgRxapSmakCJym47vhHTZMQ4p4blXanO/jRNjeruZtRzgznKefy9ERgZOml 3LdA== X-Gm-Message-State: AOAM533huFXR+UZVBKOjUjLMQmjG0tgkAC0Os6dC6Yr3oLTmwMUuJ65W Fsf/fpmGJmDKL+zyWNHtNMcmSw== X-Google-Smtp-Source: ABdhPJwyKN/fMqHSiLSCFqje5xm7IfEYxX+ShLy7fld0Zm0G/MU9egeg+lMdTInUJSZ9GL2RV2WHvg== X-Received: by 2002:a17:902:8308:b029:129:220a:c455 with SMTP id bd8-20020a1709028308b0290129220ac455mr4895871plb.74.1625132149791; Thu, 01 Jul 2021 02:35:49 -0700 (PDT) Received: from localhost ([202.131.71.237]) by smtp.gmail.com with ESMTPSA id c184sm24002494pfa.38.2021.07.01.02.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jul 2021 02:35:49 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Daniel Kiss , Denis Nikitin Cc: Leo Yan Subject: [PATCH v2 1/3] coresight: tmc-etr: Use perf_output_handle::head for AUX ring buffer Date: Thu, 1 Jul 2021 17:35:35 +0800 Message-Id: <20210701093537.90759-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210701093537.90759-1-leo.yan@linaro.org> References: <20210701093537.90759-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210701_023550_373484_57A8E23C X-CRM114-Status: GOOD ( 19.36 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When enable the Arm CoreSight PMU event, the context for AUX ring buffer is prepared in the structure perf_output_handle, and its field "head" points the head of the AUX ring buffer and it is updated after filling AUX trace data into buffer. Current code uses an extra field etr_perf_buffer::head to maintain the header for the AUX ring buffer which is not necessary; alternatively, it's better to directly perf_output_handle::head. This patch removes the field etr_perf_buffer::head and directly used perf_output_handle::head for the head of AUX ring buffer. Signed-off-by: Leo Yan Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index acdb59e0e661..b22823d67680 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -32,7 +32,6 @@ struct etr_flat_buf { * @etr_buf - Actual buffer used by the ETR * @pid - The PID this etr_perf_buffer belongs to. * @snaphost - Perf session mode - * @head - handle->head at the beginning of the session. * @nr_pages - Number of pages in the ring buffer. * @pages - Array of Pages in the ring buffer. */ @@ -41,7 +40,6 @@ struct etr_perf_buffer { struct etr_buf *etr_buf; pid_t pid; bool snapshot; - unsigned long head; int nr_pages; void **pages; }; @@ -1437,16 +1435,16 @@ static void tmc_free_etr_buffer(void *config) * buffer to the perf ring buffer. */ static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf, + unsigned long head, unsigned long src_offset, unsigned long to_copy) { long bytes; long pg_idx, pg_offset; - unsigned long head = etr_perf->head; char **dst_pages, *src_buf; struct etr_buf *etr_buf = etr_perf->etr_buf; - head = etr_perf->head; + head = PERF_IDX2OFF(head, etr_perf); pg_idx = head >> PAGE_SHIFT; pg_offset = head & (PAGE_SIZE - 1); dst_pages = (char **)etr_perf->pages; @@ -1553,7 +1551,7 @@ tmc_update_etr_buffer(struct coresight_device *csdev, /* Insert barrier packets at the beginning, if there was an overflow */ if (lost) tmc_etr_buf_insert_barrier_packet(etr_buf, offset); - tmc_etr_sync_perf_buffer(etr_perf, offset, size); + tmc_etr_sync_perf_buffer(etr_perf, handle->head, offset, size); /* * In snapshot mode we simply increment the head by the number of byte @@ -1605,8 +1603,6 @@ static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, void *data) goto unlock_out; } - etr_perf->head = PERF_IDX2OFF(handle->head, etr_perf); - /* * No HW configuration is needed if the sink is already in * use for this session. From patchwork Thu Jul 1 09:35:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12353801 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=-17.2 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,USER_AGENT_GIT 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 05586C11F64 for ; Thu, 1 Jul 2021 09:38:07 +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 C68826144F for ; Thu, 1 Jul 2021 09:38:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C68826144F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ie++DHZCnWoAekuKWNECFzjgi/DC4e4BrLnw9f9wg+s=; b=wYJ9/szeELE521 8Mf/z4L2MtEjkOoeoTwXHbM70keA9VhzIf7+byWrfT2N/JvwV3V1xUxuV23D2Fd7+zD5Ha8oRAk1I KO90YO6N6BVRHWgEBLqrFkvKUFHK0Ad+hxALM2ctV2Q/SYJUeni6XXXwcYt+ooLEGx0/0oZJk5ZIZ fAUWCO/o+uUb4rNR4rc62p4qmzESiR4+kWDnP5ptKPtOAtnNFtXFNBGfbf8okP1G3PTmK8M61Fbvi padWhvbzkI5ksWqHArB8MNyB9IhBg3kRQ4eTesQJcWqPHb79ExFp6p7zMxamaUaBYHqnV/gY6nhZg QQIIhGszYEhi9/FlyMUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyt7G-00Gk3f-PH; Thu, 01 Jul 2021 09:36:14 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyt6w-00GjbB-9z for linux-arm-kernel@lists.infradead.org; Thu, 01 Jul 2021 09:35:56 +0000 Received: by mail-pg1-x52d.google.com with SMTP id a7so5567260pga.1 for ; Thu, 01 Jul 2021 02:35:53 -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 :mime-version:content-transfer-encoding; bh=YDDpm/dgelMrBHHum/u63M7DrWlUVDkZCNCbaXlSjZQ=; b=MYgymzoqyQLGPkTbVGm6NKk2dqZwDQHLFeazE2fE7D7W+8YeFX0WY7BVaXQGqA4i3L EUghuyJPZ1o0j6Vq/ma5t5h+Lj+JXfcg6LNpm6gI8lwWP3ejDyGRfwsfKXMBbZALA1Ho Yh0lO2cQC1OPKQRp9RFvXYBzyQYqa/F5Cco9Z2ZwWk73eU5VuT3a6zUUk1nWUD4oHeY1 qFAZFYha5LjkqFB6xc0z0D/3rdk9QQeo/7lVprr8gM/BGwlpKw1Mh3aAaNsx2KddJNfq HGNQjZbdT3TaT3qIM1M/cxM5NVvknkxA/FMffi/5Dmwg655o4/P+nAohWZCGNVKKz8bk bUAw== 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:mime-version:content-transfer-encoding; bh=YDDpm/dgelMrBHHum/u63M7DrWlUVDkZCNCbaXlSjZQ=; b=AlSyPyJ8XqKGLeVAgQvj0GeoYNW/IfqkTPQiZ8EvlqAIZd5ISHuDz7AytnhnzKijvv NacF4UvPDbB27ZctMNykGSYBEU9ZRuhvMhB/SVsQdxauQx1TXyY6v38ycpurFOV4I8qZ njwiLMcuIrMPh7nDnHNRi4EKrTOdnt89PANIi9hE5YAB+BUWtNB6sxUMSg4pvDbvYUqF qouNIuXgc1qYUwxjuz20DVpMgtS+jOJOyoMKX6M+D3tZKuyYtFM9fE38w1cp5oM9/Mlh I3emf/stsx/3cIo+EdYRJ3YYOr8SyMb84WJEsgOdC1vUQxRADG3uTtJwBC3N0SuGY1Gq xI/g== X-Gm-Message-State: AOAM531rtYNuV2fTsRYRbyEKDn9mRRCmgVuKLijEfwkBEAHnIUxIEKwk GElu0HNdv/1GwSN/lr7k0TY+YD5tNmheEA== X-Google-Smtp-Source: ABdhPJzfEo67wRZrhzqrJLBqArAerh2kWDlR1v/0ST8x3XabgE5TiG8nLXTQaMKbQNBStUg/rB4HPA== X-Received: by 2002:a63:65c5:: with SMTP id z188mr38547801pgb.174.1625132153364; Thu, 01 Jul 2021 02:35:53 -0700 (PDT) Received: from localhost ([202.131.71.237]) by smtp.gmail.com with ESMTPSA id cl14sm1773806pjb.40.2021.07.01.02.35.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jul 2021 02:35:52 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Daniel Kiss , Denis Nikitin Cc: Leo Yan , James Clark Subject: [PATCH v2 2/3] perf cs-etm: Remove callback cs_etm_find_snapshot() Date: Thu, 1 Jul 2021 17:35:36 +0800 Message-Id: <20210701093537.90759-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210701093537.90759-1-leo.yan@linaro.org> References: <20210701093537.90759-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210701_023554_405901_F42F25C0 X-CRM114-Status: GOOD ( 29.46 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The callback cs_etm_find_snapshot() is invoked for snapshot mode, its main purpose is to find the correct AUX trace data and returns "head" and "old" (we can call "old" as "old head") to the caller, the caller __auxtrace_mmap__read() uses these two pointers to decide the AUX trace data size. This patch removes cs_etm_find_snapshot() with below reasons: - The first thing in cs_etm_find_snapshot() is to check if the head has wrapped around, if it is not, directly bails out. The checking is pointless, this is because the "head" and "old" pointers both are monotonical increasing so they never wrap around. - cs_etm_find_snapshot() adjusts the "head" and "old" pointers and assumes the AUX ring buffer is fully filled with the hardware trace data, so it always subtracts the difference "mm->len" from "head" to get "old". Let's imagine the snapshot is taken in very short interval, the tracers only fill a small chunk of the trace data into the AUX ring buffer, in this case, it's wrongly to copy the whole the AUX ring buffer to perf file. - As the "head" and "old" pointers are monotonically increased, the function __auxtrace_mmap__read() handles these two pointers properly. It calculates the reminders for these two pointers, and the size is clamped to be never more than "snapshot_size". We can simply reply on the function __auxtrace_mmap__read() to calculate the correct result for data copying, it's not necessary to add Arm CoreSight specific callback. Signed-off-by: Leo Yan Reviewed-by: James Clark Tested-by: James Clark --- tools/perf/arch/arm/util/cs-etm.c | 133 ------------------------------ 1 file changed, 133 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index d942f118d32c..85168d87b2d7 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -38,8 +38,6 @@ struct cs_etm_recording { struct auxtrace_record itr; struct perf_pmu *cs_etm_pmu; struct evlist *evlist; - int wrapped_cnt; - bool *wrapped; bool snapshot_mode; size_t snapshot_size; }; @@ -734,135 +732,6 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, return 0; } -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(). Using realloc() to avoid - * cross compilation problems where the host's system supports - * reallocarray() but not the target. - */ - wrapped = realloc(ptr->wrapped, cnt * sizeof(bool)); - if (!wrapped) - return -ENOMEM; - - wrapped[cnt - 1] = false; - 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, - u64 *head, u64 *old) -{ - 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 %zu new head %zu size %zu\n", - __func__, idx, (size_t)*old, (size_t)*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; -} - static int cs_etm_snapshot_start(struct auxtrace_record *itr) { struct cs_etm_recording *ptr = @@ -900,7 +769,6 @@ 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); } @@ -928,7 +796,6 @@ struct auxtrace_record *cs_etm_record_init(int *err) ptr->itr.recording_options = cs_etm_recording_options; ptr->itr.info_priv_size = cs_etm_info_priv_size; ptr->itr.info_fill = cs_etm_info_fill; - ptr->itr.find_snapshot = cs_etm_find_snapshot; ptr->itr.snapshot_start = cs_etm_snapshot_start; ptr->itr.snapshot_finish = cs_etm_snapshot_finish; ptr->itr.reference = cs_etm_reference; From patchwork Thu Jul 1 09:35:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12353803 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=-17.2 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,USER_AGENT_GIT 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 E2FC8C11F64 for ; Thu, 1 Jul 2021 09:38:11 +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 B1C556144F for ; Thu, 1 Jul 2021 09:38:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1C556144F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dLTvNiKpDYHYC8qpfmPiMCC2w+ANuPhYlAZgr0B6FMw=; b=ecad+r9DysxW8T jvlRPRFAONw4heCQPTi7Hmp8/RxOSa2OZs6aYuoXpvNxNArPil514pwKm3uHDEMgf8cJ1nRZTFUP5 ZAj7OS6DKunqTxotVevOI2KIOjsK7/M3cZUWpAJRiRi7Bo0zO+6H5kAELv4gKN44u3Plf8CO/1Uwx vkhJpHG0Aa1AjpXPo+RnZIYWGOWvtjkLr8379GVeyZw9XdU+9/GYcrIDF8Q2jgyhKP+uCNL49pM4w pXo1O/tgTMxHOF4KHP/NZ5sKXnlDcOr05JuZN3ZNs7L9Gat5XGT4/wjSFlRDEshuANi9yf5+GqeOi k3y1kzGtZBlxOb7o4X1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyt7U-00GkYM-VO; Thu, 01 Jul 2021 09:36:29 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyt6z-00GjcO-DC for linux-arm-kernel@lists.infradead.org; Thu, 01 Jul 2021 09:35:58 +0000 Received: by mail-pl1-x636.google.com with SMTP id b5so3335845plg.2 for ; Thu, 01 Jul 2021 02:35:57 -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 :mime-version:content-transfer-encoding; bh=q4ZZRhosUp1CcazcGUG0vt93v9b9C4M9CrUlbcO8C/g=; b=MtlUQfURw0WXxxuNuMUXgJ+/ERQOOr5yxWHEW6MLQz7DV3RQdXBVsyHega5LHmSPUj kTqz3i3YRsz0VPKwCJN6ofcUQNMW/eicuwOOsk5AUIkp+8pG55er1Q2inHHuvvorNsae ahDHfw8nXjtsgRn7KKIYoHLGfMQwPi2C6oV2pTRSev4Y9Uh4Zsp+XCwlaugPsnGPork6 S1QRmOuKCgWphlOIkXezNIGyUIQ5rBmiBhiUsyMHhpdLv6GcaFbUKVQvHuenl2QfdwOl Fg54SQbIHecKRnZoLzj7Bd49iBxdAKYNO1dBq2ur7BxrlSe/0tmUNIWI7dPyw9+mLIHQ 0ZTw== 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:mime-version:content-transfer-encoding; bh=q4ZZRhosUp1CcazcGUG0vt93v9b9C4M9CrUlbcO8C/g=; b=ZzJ5mSCRqUvcjZd8XRG5THGb46jICWDrLsijhIgWIpkXT8EKKAnSiSumfHPotKdLK9 OYhrQyKK2cqPxkENX8F7o7Mk6iGHRNq02LbYA7hJPKA11Np7BKVi1fXmmROS8w0ofan+ AWO/znzvDeIxKZLSYxPv4h5e5/sipqP9293FqgynVlC0wSlkmmZj5unZWt6QPCKr+GN4 ynnMbBFF02yjf2D+m+a6mDpBlrteeVL2V2vHdh5lk57CWTQGdUk74dRYkFsPKe/SEBot wINPuGC1bs0jZNtb0s2uKcSkE2BH9fhVIIhVoyUiwlwR0QSbrvPsVYH17ytIFlvtxBgg 7hQA== X-Gm-Message-State: AOAM530QVwH9l2HhFE1RTuQzPfArvhpjc6CUsCMWipu6hZNpZYkCX+iO 410JI1NByo9DhfEjlyP05xVSWA== X-Google-Smtp-Source: ABdhPJyNAkTr6TG4gwd0yAmimm0dzypa9fXjWmKkYxb7d1333M1b1+Pbi0cCt1vqIGAXMhaERHFKeQ== X-Received: by 2002:a17:903:1243:b029:ed:8298:7628 with SMTP id u3-20020a1709031243b02900ed82987628mr35822148plh.11.1625132156604; Thu, 01 Jul 2021 02:35:56 -0700 (PDT) Received: from localhost ([202.131.71.237]) by smtp.gmail.com with ESMTPSA id a33sm15459119pga.68.2021.07.01.02.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jul 2021 02:35:56 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Daniel Kiss , Denis Nikitin Cc: Leo Yan Subject: [PATCH v2 3/3] coresight: Update comments for removing cs_etm_find_snapshot() Date: Thu, 1 Jul 2021 17:35:37 +0800 Message-Id: <20210701093537.90759-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210701093537.90759-1-leo.yan@linaro.org> References: <20210701093537.90759-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210701_023557_503341_3EA115B5 X-CRM114-Status: GOOD ( 17.64 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since the function cs_etm_find_snapshot() has been removed in the user space, it directly uses the perf common function __auxtrace_mmap__read() to calcualte the head and size for AUX trace data in snapshot mode. Updates the comments in drivers to reflect the changes. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etb10.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index f775cbee12b8..1cdb627d6c38 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -557,7 +557,7 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev, /* * In snapshot mode we simply increment the head by the number of byte - * that were written. User space function cs_etm_find_snapshot() will + * that were written. User space function __auxtrace_mmap__read() will * figure out how many bytes to get from the AUX buffer based on the * position of the head. */ diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 45b85edfc690..fec8ef3694cf 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -546,7 +546,7 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, /* * In snapshot mode we simply increment the head by the number of byte - * that were written. User space function cs_etm_find_snapshot() will + * that were written. User space function __auxtrace_mmap__read() will * figure out how many bytes to get from the AUX buffer based on the * position of the head. */ diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index b22823d67680..960515e01171 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1555,7 +1555,7 @@ tmc_update_etr_buffer(struct coresight_device *csdev, /* * In snapshot mode we simply increment the head by the number of byte - * that were written. User space function cs_etm_find_snapshot() will + * that were written. User space function __auxtrace_mmap__read() will * figure out how many bytes to get from the AUX buffer based on the * position of the head. */