From patchwork Fri Feb 15 00:45:31 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: 158466 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp104080jaa; Thu, 14 Feb 2019 16:48:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IZCxiaKCTiPFLxnOegUB2JP7ckyES8QG9aKrnd9SsofPsQ1bsWwe4eeiMWPZ2tbNS22V2SH X-Received: by 2002:aa7:8d57:: with SMTP id s23mr6932565pfe.237.1550191710250; Thu, 14 Feb 2019 16:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550191710; cv=none; d=google.com; s=arc-20160816; b=ZunD9XMHU3SCMx0EKO9xPthQy1r4IvAucW8YxQieDGdBG//jNxsq3RNwL4pVJZybha 02kAfKtAroG6jYr24w/stIXVwCH+Owzo0ytPi6mQz/e1V4S5ytzZPvdLn87flZcZH/pS n5AamzgHP5F9V3/q2U0e6U+hxD2gyVy1/yaNa6M8pPKmESNuXvQho+cGNWYiJjHgTdWl 564SNJbbgI4nn0hxSU9MnLezyyg3TSdaac+mE+lBnpVLNZGV4zhyz85PVL0wcC5KHA4n zdD/Daj9ijpEs1aGhTXpTA93SGSrlS8GptAB+lYoamqqljMD6EGZb0j7ASX9vSye5ug/ Cxiw== 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=HEOd/lgCZc4aTLaEIsiGWhLEAKp6aoFTst/DvChQZnE=; b=AxLQdwhPPaEw0brM4SIzIRhEMYi4XJWizfTnuw1PWIF9Nl6uRab3SsJ3v5t0xuMcM8 ThJCSvFA5G0aS/D8EXgS+d9i1HTtIZ9UVmLqmWOBdTflF7ryq9+vAYLSvUyOGantG+ju eE+LA6vZR/69a9kHfZdr2crZ0ga6KAdkZUbNx4hMEEwSHOJH0OLn2TeLBNWT5VBqBkr4 ndMMYN5bI2E5YncTt9KbTFD7NVLCiSl3qDmV5jE2hBCL0tTxfU/XDj5vM0Pq91NJDpEb vrOEESQj3uAC+ncbeCamuuVCIGatZTMIgwCg8JaOGcfuqAhtPZq2x4vNDk1wVEP30C6D ftmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xwhLmUcp; 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 o3si3784644pls.265.2019.02.14.16.48.29; Thu, 14 Feb 2019 16:48:30 -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=xwhLmUcp; 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 S2389667AbfBOAs1 (ORCPT + 31 others); Thu, 14 Feb 2019 19:48:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:47516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389617AbfBOAsY (ORCPT ); Thu, 14 Feb 2019 19:48:24 -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 8511A222A1; Fri, 15 Feb 2019 00:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550191704; bh=6LdzrCVx8YqnpmPcRdemWeu0Aj6Lfc4MEov3VXtbxS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xwhLmUcpYFD23RrowCfeVr66BAmigTql/10xm+6AD7Rlx3E6d1mVK/YeawQok3boj t273uf9QOKK/WSVN8POqfY3zGjBbZ0V4LzsK7GOnzQ6FfaywWj5XeKYvEjNpKY+d3l tV7FUVmi7LbcxGHNtYUSzIfSrXcwxe6ICFJQioFI= 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 35/43] perf cs-etm: Modularize auxtrace_buffer fetch function Date: Thu, 14 Feb 2019 21:45:31 -0300 Message-Id: <20190215004539.23571-36-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 auxtrace_buffer fetch function 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-14-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 f607bc58bd03..110804936fc3 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1152,6 +1152,32 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq) return 0; } +/* + * cs_etm__get_data_block: Fetch a block from the auxtrace_buffer queue + * if need be. + * Returns: < 0 if error + * = 0 if no more auxtrace_buffer to read + * > 0 if the current buffer isn't empty yet + */ +static int cs_etm__get_data_block(struct cs_etm_queue *etmq) +{ + int ret; + + if (!etmq->buf_len) { + ret = cs_etm__get_trace(etmq); + if (ret <= 0) + return ret; + /* + * We cannot assume consecutive blocks in the data file + * are contiguous, reset the decoder to force re-sync. + */ + ret = cs_etm_decoder__reset(etmq->decoder); + if (ret) + return ret; + } + + return etmq->buf_len; +} static bool cs_etm__is_svc_instr(struct cs_etm_queue *etmq, struct cs_etm_packet *packet, @@ -1591,18 +1617,9 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) /* Go through each buffer in the queue and decode them one by one */ while (1) { - if (!etmq->buf_len) { - err = cs_etm__get_trace(etmq); - if (err <= 0) - return err; - /* - * We cannot assume consecutive blocks in the data file - * are contiguous, reset the decoder to force re-sync. - */ - err = cs_etm_decoder__reset(etmq->decoder); - if (err != 0) - return err; - } + err = cs_etm__get_data_block(etmq); + if (err <= 0) + return err; /* Run trace decoder until buffer consumed or end of trace */ do {