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=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,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 94B63C282C4 for ; Tue, 12 Feb 2019 17:19:45 +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 668C5222C0 for ; Tue, 12 Feb 2019 17:19:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KYnnvN11"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Wmd0f4y5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 668C5222C0 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+infradead-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.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=dQy3bMKTKnzSRYp5fhh8gtdYY68G1Hv5jDGGuFzWT8E=; b=KYnnvN11eMzD3GNxB02My7A+Is 6NqtkKK+l7ENClxca9pkweNiGfX0v3Xp4yokGQRI/MDei+IrAMiMgiTRx/p19OXpnGvU9Icfnx378 NKYHrvtA5XGjFJojNF8Qygm/KNzN/SP8++24IykeK4DBoDb0G2yEH9lHZJgZKRTsiGm1u/QJFoBHV puUCivoRRDAzps5ySuJS9TfS2IyOL9QuU7rm08qLP+/23XIFKstpw6+KJeto7RVmbqSwlzauVJKzF KMfaoOrTDiTDUG0bt+EfvL+rwdWx9PqSTQ1vsK4BZjdFCsjvkpD3Kc84QNVh5d95mk6iBPLzJovCS 9IJMQfjw==; 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 1gtbib-0004Gv-AD; Tue, 12 Feb 2019 17:19:37 +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 1gtbfe-0001U1-Qx for linux-arm-kernel@lists.infradead.org; Tue, 12 Feb 2019 17:16:51 +0000 Received: by mail-pl1-x643.google.com with SMTP id w4so1615285plz.1 for ; Tue, 12 Feb 2019 09:16:34 -0800 (PST) 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=fPu8+x56+bPaqE+Kt7QPAly49dZ2m5zcnSswTAaxNxU=; b=Wmd0f4y5WvxofS4IIk+dxekor1GLWA5HfI5d997lyaW20uM6gGnPRhTpEjUcN2xYhr XfdDxPEaxyvelxa9DuAKy+wIo/vZZXq5kpL1aYRyrWfV2R2NLEnU3R0f8BYjGKjBalFu U5tjNeJbUVnHwuZ1O1gYT6Bam1FmRP7Njaye9A9CZ/Rjqv4k1fuxD4afpTgcz4afOgIp 1VV9aLv2+tEQQS8my2EHZp70eY4gYPJ1GF55AQUfHhVMlknG0upE1pWRsv0dR5dvfsun 0NEmlUObt9WSKKmJRsZdNnT0y0Xqp+Cr/DgtU8QISnCP01VYvzOs5iBYceEop0GQfqIh WTNg== 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=fPu8+x56+bPaqE+Kt7QPAly49dZ2m5zcnSswTAaxNxU=; b=LsY4xYQ2cm0uodNdMHgrSeAs1+toFwKbtbjl7aJY3wO16yQOVyX2DGuEmEOPI6x6Fi 5IBsZytFaWVHGUf7KYSdH1rIMslkL7f8GFRNo3z75UHZAdERazyDkcKSWDQ0Rquk0UE2 9DJTzitpbwElyFSnA6TYGE/VLF9etnsS77t4ZnM9LGolnBNmDTGOYEugWZli7Khvn8MY c+koGAcQY3UmVJdisIAuroc5R49VivBLND0XvHcdCgn/GvkcpDEAP3gGddFBoTNILY5K k3Lr2FICXb2jVvqplsFfCsqFD0edaWhBQWCqnPhaX75ZH2uBqOTN5aLUwUeZ6FBS6G5q FcgQ== X-Gm-Message-State: AHQUAuY0uU94onqPnBa0Kd1mr3/Fg9MGTI5vqC7lsGPEDJUCDddynUo7 6EqNVuT+L5hRd3SiRg+Kf8Pc9Q== X-Google-Smtp-Source: AHgI3IaZSfmJpvPaEi6xZg4Ttp0Sjv+78UJL6/7Q+XeG1Dd7ab+aNBtu9L20qwrLlgvG0xl1rHv1WQ== X-Received: by 2002:a17:902:b581:: with SMTP id a1mr4999975pls.36.1549991794044; Tue, 12 Feb 2019 09:16:34 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:33 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org Subject: [PATCH 12/13] perf tools: Modularize main packet processing loop Date: Tue, 12 Feb 2019 10:16:17 -0700 Message-Id: <20190212171618.25355-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190212_091637_152985_5024A927 X-CRM114-Status: GOOD ( 17.11 ) 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, peterz@infradead.org, linux-kernel@vger.kernel.org, mingo@redhat.com, leo.yan@linaro.org, jolsa@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Making the main packet processing loop modular so that it can be called from different decoding context (timeless vs. non-timless), avoiding to repeat code. Signed-off-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 129 ++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 57 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index cfa686fe223e..f607bc58bd03 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1519,6 +1519,72 @@ static int cs_etm__decode_data_block(struct cs_etm_queue *etmq) return ret; } +static int cs_etm__process_decoder_queue(struct cs_etm_queue *etmq) +{ + int ret; + + /* Process each packet in this chunk */ + while (1) { + ret = cs_etm_decoder__get_packet(etmq->decoder, + etmq->packet); + if (ret <= 0) + /* + * Stop processing this chunk on + * end of data or error + */ + break; + + /* + * Since packet addresses are swapped in packet + * handling within below switch() statements, + * thus setting sample flags must be called + * prior to switch() statement to use address + * information before packets swapping. + */ + ret = cs_etm__set_sample_flags(etmq); + if (ret < 0) + break; + + switch (etmq->packet->sample_type) { + case CS_ETM_RANGE: + /* + * If the packet contains an instruction + * range, generate instruction sequence + * events. + */ + cs_etm__sample(etmq); + break; + case CS_ETM_EXCEPTION: + case CS_ETM_EXCEPTION_RET: + /* + * If the exception packet is coming, + * make sure the previous instruction + * range packet to be handled properly. + */ + cs_etm__exception(etmq); + break; + case CS_ETM_DISCONTINUITY: + /* + * Discontinuity in trace, flush + * previous branch stack + */ + cs_etm__flush(etmq); + break; + case CS_ETM_EMPTY: + /* + * Should not receive empty packet, + * report error. + */ + pr_err("CS ETM Trace: empty packet\n"); + return -EINVAL; + default: + break; + } + } + + return ret; +} + static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { int err = 0; @@ -1544,64 +1610,13 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) if (err) return err; - /* Process each packet in this chunk */ - while (1) { - err = cs_etm_decoder__get_packet(etmq->decoder, - etmq->packet); - if (err <= 0) - /* - * Stop processing this chunk on - * end of data or error - */ - break; + /* + * Process each packet in this chunk, nothing to do if + * an error occurs other than hoping the next one will + * be better. + */ + err = cs_etm__process_decoder_queue(etmq); - /* - * Since packet addresses are swapped in packet - * handling within below switch() statements, - * thus setting sample flags must be called - * prior to switch() statement to use address - * information before packets swapping. - */ - err = cs_etm__set_sample_flags(etmq); - if (err < 0) - break; - - switch (etmq->packet->sample_type) { - case CS_ETM_RANGE: - /* - * If the packet contains an instruction - * range, generate instruction sequence - * events. - */ - cs_etm__sample(etmq); - break; - case CS_ETM_EXCEPTION: - case CS_ETM_EXCEPTION_RET: - /* - * If the exception packet is coming, - * make sure the previous instruction - * range packet to be handled properly. - */ - cs_etm__exception(etmq); - break; - case CS_ETM_DISCONTINUITY: - /* - * Discontinuity in trace, flush - * previous branch stack - */ - cs_etm__flush(etmq); - break; - case CS_ETM_EMPTY: - /* - * Should not receive empty packet, - * report error. - */ - pr_err("CS ETM Trace: empty packet\n"); - return -EINVAL; - default: - break; - } - } } while (etmq->buf_len); if (err == 0) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel