From patchwork Tue Feb 12 17:16: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: 158168 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4089116jaa; Tue, 12 Feb 2019 09:16:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IaA/Bd4g5fhjrTWNeJ9k7bn02nBouHHqZHuIMO9l6xtmCiN6sqqxn9m/AGYIOhWmgMq+VyN X-Received: by 2002:a62:61c3:: with SMTP id v186mr4985657pfb.55.1549991805490; Tue, 12 Feb 2019 09:16:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549991805; cv=none; d=google.com; s=arc-20160816; b=M/TpWZn2F/vgFCd4HsZVOeNjcip7x1z6Y1An6lZ4DunRLUEoz9BFokX32Ez0SHkLMk b5pCz+QVC0kyxUWsvYVjijS7D3fMJTMhfDaWfpqtRXuyoaDdw9VrnUAgZE0fF84VTMZ4 CLJtG6ZqyJi3BApW39WRA0/D8t0CxZHb1evgAY5VGBXTGvulB9QO7mHIY10E01u6LS7W Ui5BytIrviGI++egGaBo6mBKRbXWGTxG+8U2/wLG91tFIeEzSQXnAdYUwKyO4Eak2giJ 7snJDMcjsdBeQEMDjvtNNmoCjRsZ9awr5mZCoycP6fo3uT6asXtXXt8gujBVNTR5BdEh XwOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=qkiQiMGL+p9I6/iS3vRnEYYc23edBwfSeQJiedeTSRc=; b=gPIhsET9r/5dht1zYXVMrWuG1kmUl312LmUtt03QtgRFDdcFUfU3x9Oldex3MRdvMr 6z8jcn/Iq9aAjeJKnwREGUo/DHNmEDjm5IlhGwTXh5BlAIkE5KMwgY0IOD/ui+tmAy0o Ud4HNBGWTC3miB9QaoUVWR/6EMGHKaH72fDjfD88uJAkZsnRViFwQbOgG7byf8bHsZjh Fz082ALGs7Eql/tkpmBib+MB9gYbKsN0Lifue08xzCsllll84jZ2iFNmvXBWxnbU6+f4 uNMjHGs/qM73yoIqfDSYPQ+PlcXrZpUHWbGlIOpr8KZc+2uDwQ+72OamHmtb5wZCRLdU U44w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sVIhgAj1; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y129si5007421pgy.175.2019.02.12.09.16.45; Tue, 12 Feb 2019 09:16:45 -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=@linaro.org header.s=google header.b=sVIhgAj1; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731843AbfBLRQj (ORCPT + 31 others); Tue, 12 Feb 2019 12:16:39 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33124 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731819AbfBLRQf (ORCPT ); Tue, 12 Feb 2019 12:16:35 -0500 Received: by mail-pl1-f196.google.com with SMTP id y10so1622188plp.0 for ; Tue, 12 Feb 2019 09:16:35 -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=qkiQiMGL+p9I6/iS3vRnEYYc23edBwfSeQJiedeTSRc=; b=sVIhgAj1YxApYOZcGkQA8IOcPqUHNNfVOBXsJ3MIFFlT1Hp8bmWs5av4xevdXiVNZW FSC1Yo1a8IBZkR46UdZoVR3FzPxk79HkIZCfHoTxlU8GGBKw8v8cOrzeCP54IGWvsR8v PzMzDOol6q8ak1JwyqPhqIVjqViUCZIG9JLB5SZUtCUZFE9WQIA8YFOKafHfRMcpwksv /KbApTEcZ92QxjNlFM9SVa3rUX1XD/RHSE+zlfpd9Po0e8bq1JYHfK3fA5fMbe3UteYg vcupn0WP+VnbtW/3yDgT6jB0RLT7I35yBoSiTePGbd5SNZIGI/BeE40t1UPLDRoc5QhJ lluw== 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=qkiQiMGL+p9I6/iS3vRnEYYc23edBwfSeQJiedeTSRc=; b=oW/Qngxz1+82nvMsGMBnnFsUAWvnbZhptDqcPAOQLb69kaUHfgD4Edvd0JPdFATgGi 2gB3YcWDnQpTvmxshdytWzORaQnFfbc1z8EQkd4QDruBbzRoJoxmhanvEChx8LFS+cDc dlq1bwhAZQne4SEiKeQvr9TnV0lx1iZ6kw5uLot2OOuFaOiOAU43vIBU25YEvLLS475b JD7vUIc69rEoqkkpxqcqrYzg28BsggCW3Z5Z4vu4HVkgS4a0XE+zOyJEY5bVto/SCTsx dRcIMfSRCFq3y1zbHAMwcBBS7pvjxajBmmU+yfAFv4oKaBpKD/Qy7W9SQV0ubg9BZ9e6 lkQw== X-Gm-Message-State: AHQUAuYJmjvKi2TIoTSG1hHs3UCvdrH9t+fG+VlN0XRN+i6sXckZhGeC 4z+iOvtE2VLq7Rd56lAeQIr9KQ== X-Received: by 2002:a17:902:14b:: with SMTP id 69mr4904861plb.120.1549991795240; Tue, 12 Feb 2019 09:16:35 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:34 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org Cc: suzuki.poulose@arm.com, mingo@redhat.com, peterz@infradead.org, jolsa@redhat.com, leo.yan@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/13] perf tools: Modularize auxtrace_buffer fetch function Date: Tue, 12 Feb 2019 10:16:18 -0700 Message-Id: <20190212171618.25355-14-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- tools/perf/util/cs-etm.c | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) -- 2.17.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 {