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=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 1A038C433DB for ; Wed, 3 Mar 2021 15:39:08 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 D145E64EBD for ; Wed, 3 Mar 2021 15:39:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D145E64EBD 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FjiwKSHvlG46iafqR/NjqE7HS8MwhHBXD2txdnnoYHA=; b=G68sbXdy0BfFEKYf9mdUfvyo1 HypSL81MWoXAHK3yrpiacojYoKbdJxyoOVCBOeCvSBmnm46OQX4/YOoPsZ5eo7YZan/iiWYlxCgfK Gcc6uP1j8mOExEAdmYXaYq6iaYN/4jiE20qOx4couF7myWtYdDRFdC2QF/VYgFpLuYHYvmd+/bcFN iRmIDd7K+iUQEgYxnGp0wBqhtHxBJP5pXVuKCbo0D+MLlBrJaOLMIBeWiJpX90JJGssst9BJUyes+ vkzv+T1o5wCuhA7izBnF1tR6HipN+nQjitd4xHLaFuxFPCnS8Dk04EUg/gyheffU87/6OvTVdJzYg GF1sE/XWw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHTYL-005PmG-Bt; Wed, 03 Mar 2021 15:36:46 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHSV2-0058A4-8H for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 14:29:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=rIWiD5GiL0TDlarCC4Pp88TxrYDHIkIQwJWeubejCZw=; b=Ivm4AoUULVwEhPIJYLd8Mz5oZK Cnq2VuTqy1CunFLFs3DddDP+fBXYHg7g6p0FyugZEaNtCTkWaM57QFdsBf+VphsHwT2c1AzeZJTAc vPm+ED/CwkBed0TrdhQUt9bbm4GgrrlZLh6DJKWeVIrM8xWtaF2+qtRkKAR3qXF4Zh67BfYlieWCn j2MDg94Rns3kfQIiTdUM8K1Z3nIkgfeylm/22Mze8oTbVzBlhGYRtoNF8tfY/UMHCBjn4pNJAAFwE swskPKcM21yPF7/494cR2Yip5ZWFwPbNBTOBmhCLum3kPa+HPSWybe6IlQDlPrSL+xn1DrQA8aBWs x+ka30Tg==; Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH3lT-00H4CS-IT for linux-arm-kernel@lists.infradead.org; Tue, 02 Mar 2021 12:04:39 +0000 Received: by mail-pf1-x42a.google.com with SMTP id w18so13684707pfu.9 for ; Tue, 02 Mar 2021 04:04:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rIWiD5GiL0TDlarCC4Pp88TxrYDHIkIQwJWeubejCZw=; b=Z2ql1VtJpudQr/wL14jJCXO1cyb7mWjyuWQNwJvnKzhceewwjzURrioyUXO7M3hBsD Hz7xh6Iy482ZTb+WKZ2gPaOhfgbw+0Y5KBagZbPQjnBJVO2G/94WnqjigmMGMf5ZWC1w t4xf7QwpqDDDMmfwwQM6Js4EMzJ8N6aWgIABMGlaNR48YWl5tzYtiqc3K3HGq497kcCU horZ2U9vJPFxa4Np9toTapsckU2SMJeSYfWLdg4ehW9YmMIeSMp6nLYyE2Om64Jp6ns6 K5VyKtj+OScVkp2ymnCFnLJWekAXAmH10xwosrbDw+7A+CJfg3jjwsZmUdln1knTuSg5 Aa/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rIWiD5GiL0TDlarCC4Pp88TxrYDHIkIQwJWeubejCZw=; b=R1Vx9KmsU7bpcdPt5IQ4SV4Zgp1ULoDb060rRpyldlVJ2x33RfZ4yUr/9+/k3vxD/o 5taZDx80kO3y9ApdPAZDqVueIy3nCbxebIRPzleOVeRBDcqZWg6vsmSFi3sQNLFzpc6d Wi8nmm0l0uWuoQ61Ea1kRq4SJSPtdB4DdDcSw2KJXLzoNVJ7FbulbXEv6xDmCu3qGlAf 5pZf4oGyLgVu2PVsCIHBQsCM+g+9bkN7eLgHbv0ht4QNjNcGpgHgmK/+4wT3DYdTaKGd s98tGhGrOVt6no76NgrHaH5cE9JY8QnYwRgUGhHzgihPfFttgzBrOO0rrtEUiHj3xhw9 pgOQ== X-Gm-Message-State: AOAM532qFuAcdA/L62RVgQjpva8ytKLGblRcjsxjlI1S7Z51ZkpT6wpZ 1yYuduKk9v2716h2C+p3ODVkKw== X-Google-Smtp-Source: ABdhPJxynBEJyyt2MHAxxYsdcMCQf+YI6anmXatlVk21dULcnDritPsKJcuWqgNsNqkWLKt1a1kyKA== X-Received: by 2002:a63:e42:: with SMTP id 2mr17786056pgo.100.1614686612281; Tue, 02 Mar 2021 04:03:32 -0800 (PST) Received: from leoy-ThinkPad-X240s ([204.124.180.153]) by smtp.gmail.com with ESMTPSA id jt21sm3080691pjb.51.2021.03.02.04.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 04:03:31 -0800 (PST) Date: Tue, 2 Mar 2021 20:03:25 +0800 From: Leo Yan To: James Clark Cc: coresight@lists.linaro.org, al.grant@arm.com, branislav.rankov@arm.com, denik@chromium.org, suzuki.poulose@arm.com, Mike Leach , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Will Deacon , Mathieu Poirier , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/7] perf cs-etm: Save aux records in each etm queue Message-ID: <20210302120325.GB30731@leoy-ThinkPad-X240s> References: <20210212144513.31765-1-james.clark@arm.com> <20210212144513.31765-4-james.clark@arm.com> <20210227071056.GA3317@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_120439_043404_B46201D2 X-CRM114-Status: GOOD ( 34.23 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 01, 2021 at 05:43:43PM +0200, James Clark wrote: [...] > > I'd like to propose to add a new field "cs_etm_queue::buf_rec_len", it > > stands for the record length based on the RECORD_AUX event. In > > theory, this value should be always less than "cs_etm_queue::buf_len". > > > > When every time the "PERF_RECORD_AUX" event is coming, we find out the > > corresponding queue (so this can be applied for "1:1" or "N:1" models > > for source and sink), and accumulate "perf_record_aux::aux_size" into > > "cs_etm_queue::buf_rec_len". > > > > At the decoder side, it decreases "etmq->buf_rec_len" until to zero for > > the current round of decoding (see cs_etm__decode_data_block()). Since > > all the "PERF_RECORD_AUX" event will be processed before > > "PERF_RECORD_EXIT" event, so we don't worry the tail trace data will be > > ignored. > > > > The main reason for this suggestion is it don't need to change the > > significant logic in current code. I will try to do experiment for this > > idea and share back. > > > > James, if you think I miss anything, please correct me as needed. > > Thanks! > > > > This is an interesting idea, I think we could push decoded packets into the > min heap as the aux records are received, and not do anything with them until > the end of the data is reached. That way instead of saving aux records, we'd > save the result of the decode for each aux record. > > Currently each cs_etm_queue has a cs_etm_traceid_queue/cs_etm_packet_queue for each > stream, but that would have to be changed to have multiple ones because multiple > packets could be decoded to get through the whole aux record. > > It would be a similarly sized change, and could also have a bigger impact on > memory. So I'm not sure if it would help to reduce the changes, but it is possible. Below change is still very coarse and I just did very basic testing for it, so didn't cover all cases; so simply use it to demonstrate the basic idea. Before the event PERF_RECORD_AUX arrives, we don't decode any trace data. And after PERF_RECORD_AUX coming, the aux buffer size will be accumulated into the queue, and decode the trace data for the queue based on the accumulated buffer length. diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index b9c1d329a7f1..3bd5609b6de4 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -89,7 +89,7 @@ struct cs_etm_queue { u8 pending_timestamp; u64 offset; const unsigned char *buf; - size_t buf_len, buf_used; + size_t aux_buf_len, buf_len, buf_used; /* Conversion between traceID and index in traceid_queues array */ struct intlist *traceid_queues_list; struct cs_etm_traceid_queue **traceid_queues; @@ -1085,6 +1085,7 @@ cs_etm__get_trace(struct cs_etm_queue *etmq) if (old_buffer) auxtrace_buffer__drop_data(old_buffer); etmq->buf_len = 0; + etmq->aux_buf_len = 0; return 0; } @@ -2052,6 +2053,7 @@ static int cs_etm__decode_data_block(struct cs_etm_queue *etmq) etmq->offset += processed; etmq->buf_used += processed; etmq->buf_len -= processed; + etmq->aux_buf_len -= processed; out: return ret; @@ -2177,7 +2179,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) */ err = cs_etm__process_traceid_queue(etmq, tidq); - } while (etmq->buf_len); + } while (etmq->aux_buf_len > 0); if (err == 0) /* Flush any remaining branch stack entries */ @@ -2216,6 +2218,27 @@ static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, return 0; } +static void cs_etm__update_aux_buf_len(struct cs_etm_auxtrace *etm, + struct perf_record_aux *aux) +{ + unsigned int cs_queue_nr, queue_nr; + struct auxtrace_queue *queue; + struct cs_etm_queue *etmq; + + if (!etm->heap.heap_cnt) + return; + + /* Take the entry at the top of the min heap */ + cs_queue_nr = etm->heap.heap_array[0].queue_nr; + queue_nr = TO_QUEUE_NR(cs_queue_nr); + queue = &etm->queues.queue_array[queue_nr]; + etmq = queue->priv; + + etmq->aux_buf_len += aux->aux_size; + fprintf(stderr, "%s: aux_buf_len=%ld\n", __func__, etmq->aux_buf_len); + return; +} + static int cs_etm__process_queues(struct cs_etm_auxtrace *etm) { int ret = 0; @@ -2272,6 +2295,9 @@ static int cs_etm__process_queues(struct cs_etm_auxtrace *etm) if (ret < 0) goto out; + if (etmq->aux_buf_len <= 0) + goto out; + /* * No more auxtrace_buffers to process in this etmq, simply * move on to another entry in the auxtrace_heap. @@ -2414,9 +2440,15 @@ static int cs_etm__process_event(struct perf_session *session, else if (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE) return cs_etm__process_switch_cpu_wide(etm, event); + fprintf(stderr, "%s: event->header.type=%d\n", __func__, event->header.type); + if (!etm->timeless_decoding && - event->header.type == PERF_RECORD_AUX) + event->header.type == PERF_RECORD_AUX) { + + fprintf(stderr, "%s: aux_size=%lld\n", __func__, event->aux.aux_size); + cs_etm__update_aux_buf_len(etm, &event->aux); return cs_etm__process_queues(etm); + } return 0; } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel