From patchwork Fri Feb 15 00:45:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 158464 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp103954jaa; Thu, 14 Feb 2019 16:48:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IbJPQgxznwlMSnGIWV5mYsMYBxSHSDrxVIs4UW0ex+VaDxv8AfJkJ7C+aHMKlePqXvGhs4U X-Received: by 2002:a63:ef50:: with SMTP id c16mr2726723pgk.3.1550191699337; Thu, 14 Feb 2019 16:48:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191699; cv=none; d=google.com; s=arc-20160816; b=NcKMoU4k8E48VBw1D2YSqtBVM3LH9sGsHbgwejuEXrRbnZxj0W6i1gJaJHNJ6kCWjz K0Mvbgxx0X8+A77SMb+jg3c+vdi0+YBv2HiL89lq6jRYjymQdZ2sHzp+bKfVJAdcaTy0 ErQFvZ1bUbDbqT6g76MHbp+IIPDO0nRiHTRBzrfl9L70aBjO3ZhX2TWWRgf26yWSy3NI qSscczM5pKjJ5D4XO8f7FBtqZdZ0JZ9EcJAD6XbD8lDGRrg78dOgxyXqgF2PvP/M1vMY k6od3NY7jXC5eEFnZ4q1z7TOM3au0/yzS7DC137xf/xiFQCJJ7OO5OZ/LQkCHI7Tf2x7 Q+SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oMIYQbUj7JEmltgX8qTX9q61qa3goDQdjeqkAL4du9c=; b=KwnT4v3a7FNi3prXeiV9+7WAlFFpuM1OqymgezyYGeb4UwdXreQ87LFq5PO9BN8iqq 2kL4S3emFxIpAfsb+NSxaiBg7TECAYWJZWJxdCYMMuV2JZ3SsaYFAdxyYLy/YgL90CEm 8r9z7tdKeXesH/njsPGqWCsM3zRXhxxzIkHJoLdlf6bJIGEgSeQiiLO1V3niutgwpNbI ghHP9Rlc+lIzmg3lc9v7L7qIdavx99FSmJBImEu0Sr1HSl7ytZwRLX90tkt8bnDVEa5g anNFnAaQ7H+/NDCkMCsu3br2C51IP99clXfMgzpg2BE15H3YEnlHHxSWqKF6i6i4DffV /Erw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l+kbDdZ8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si3595040pgv.204.2019.02.14.16.48.18; Thu, 14 Feb 2019 16:48:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l+kbDdZ8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730539AbfBOAsR (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:47294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389370AbfBOAsQ (ORCPT ); Thu, 14 Feb 2019 19:48:16 -0500 Received: from quaco.ghostprotocols.net (unknown [189.40.103.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D470222C9; Fri, 15 Feb 2019 00:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191695; bh=WFKhBGivstHsu/Fs+BfZ/htyrxFjYHkApYCCiKiHFX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l+kbDdZ8vnowMRYyDFsySlyuP4BTytgPEFwEzygpMOMgFhGMg/T2N6+bkwgMuElLg nTrhax+BqDCi5KcMrlQe9+SiTx2PWq0hSNTS0s/h4GiYlVACdFZqqbcSXNINJSUgfF FZGwZDE63wVn13Ka4S8Wrr4et7Kkwn8hbXARcCrg= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Jiri Olsa , Leo Yan , Peter Zijlstra , Suzuki K Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 33/43] perf cs-etm: Modularize main decoder function Date: Thu, 14 Feb 2019 21:45:29 -0300 Message-Id: <20190215004539.23571-34-acme@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215004539.23571-1-acme@kernel.org> References: <20190215004539.23571-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier Making the main decoder block modular so that it can be called from different decoding context (timeless vs. non-timeless), avoiding to repeat code. No change in functionality is introduced by this patch. Signed-off-by: Mathieu Poirier Cc: Jiri Olsa Cc: Leo Yan Cc: Peter Zijlstra Cc: Suzuki K Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190212171618.25355-12-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) -- 2.19.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d2c90b369e7c..cfa686fe223e 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1491,9 +1491,36 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) return 0; } +static int cs_etm__decode_data_block(struct cs_etm_queue *etmq) +{ + int ret = 0; + size_t processed = 0; + + /* + * Packets are decoded and added to the decoder's packet queue + * until the decoder packet processing callback has requested that + * processing stops or there is nothing left in the buffer. Normal + * operations that stop processing are a timestamp packet or a full + * decoder buffer queue. + */ + ret = cs_etm_decoder__process_data_block(etmq->decoder, + etmq->offset, + &etmq->buf[etmq->buf_used], + etmq->buf_len, + &processed); + if (ret) + goto out; + + etmq->offset += processed; + etmq->buf_used += processed; + etmq->buf_len -= processed; + +out: + return ret; +} + static int cs_etm__run_decoder(struct cs_etm_queue *etmq) { - size_t processed; int err = 0; /* Go through each buffer in the queue and decode them one by one */ @@ -1513,20 +1540,10 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) /* Run trace decoder until buffer consumed or end of trace */ do { - processed = 0; - err = cs_etm_decoder__process_data_block( - etmq->decoder, - etmq->offset, - &etmq->buf[etmq->buf_used], - etmq->buf_len, - &processed); + err = cs_etm__decode_data_block(etmq); if (err) return err; - etmq->offset += processed; - etmq->buf_used += processed; - etmq->buf_len -= processed; - /* Process each packet in this chunk */ while (1) { err = cs_etm_decoder__get_packet(etmq->decoder,