From patchwork Tue Jan 29 12:28:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 156979 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4603012jaa; Tue, 29 Jan 2019 04:30:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN6hHbUAl6Bsd/xePJiKWbYWJGeYUEVl3QRxVaX9t92boTZ5cTNDHUk7G21GZr3xurOG2GLQ X-Received: by 2002:a17:902:14e:: with SMTP id 72mr25968675plb.287.1548765003832; Tue, 29 Jan 2019 04:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548765003; cv=none; d=google.com; s=arc-20160816; b=xPvCHBqeEm3UAPYsk/BpGkdlcd8IuytuTCOgAX66sbhP4qnwTIUHfhX8btj8E2j92H /6R3RcImUhaKurpwInvdzeJM6g0c0Q73bmK2fnnb50XB9HJd+aFGwmZpwukdqIEwUaCy vSzVoPA8b2Z8d9k86ryk9dykX8UUVESay5XSCceLBUzJfNAbZRO6iUpOY8Eekh4kTFub kjUSUVVKa6IDwOp1SKlnhLhJZ7GitglnHGRZ7O18MgvK0yyBxvSZ5nQ01HOwOOvhRuHL vmRDFfGs/eqpshilBh0CZ0m1IyYacHC3ic8RkqyJv0lARRAu15kjxwj0J/pG/u+0a7T3 d0Ng== 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=wCTfSFlK4C7FXgdKOX/CUsRQoqsszJ7JLDVdsKNX608=; b=g+8h0BYg94tOiL/8gvzrlF+HYZqbPf3weyCIvdYbH8Qs4fkTbzDeYt+MuPdDu793aQ LP9P1kSEj9JOgbL9CDFp0vv/LMnopKyXc3GzpI6AL1raKcFXn4jrahRwfl03hRmmmGg5 AlQiIFbfaMr+3x9TysN+xDj8v9YRiLERZ1yF2lUG57HTlXBrGuMCkiJdhy76UyLDYEBB ZcuMTNIB7vBGD/SyeS69skiG13V99Qn9gOF99pkXa6lGHVgTD7g2NW+hQxAh6fPmltl8 cLGXT2wybcigI1SsrIAOebphuCCFQwvcMGjdMVMBJPSdAEdgSwvhrHhT36KSEWat6by/ Oafw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="h62oC/St"; 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 v7si35552921plo.12.2019.01.29.04.30.03; Tue, 29 Jan 2019 04:30:03 -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="h62oC/St"; 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 S1728758AbfA2MaC (ORCPT + 31 others); Tue, 29 Jan 2019 07:30:02 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36788 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725772AbfA2MaA (ORCPT ); Tue, 29 Jan 2019 07:30:00 -0500 Received: by mail-pf1-f196.google.com with SMTP id b85so9599964pfc.3 for ; Tue, 29 Jan 2019 04:30:00 -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=wCTfSFlK4C7FXgdKOX/CUsRQoqsszJ7JLDVdsKNX608=; b=h62oC/St4ysiVkeDn5+gNpBIxbddW/cR8Q7J5/A4VfBEdO0y1pPxXkDwcdTwEhsCOm HNrpKoUj0H8ltawqSDNgqMqrVX/gJchBmGIGkmYSr/HNTHnt1Aca8ZxacPUkQyhGRnEA kJnGIKcu8w8fqD5SjPk8Ip/Q2CnCFfeYeflJQ= 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=wCTfSFlK4C7FXgdKOX/CUsRQoqsszJ7JLDVdsKNX608=; b=kvOItoLewgm/Nz/4XX3abZ86ZLpqiLcUtX7whsTqwCIfkvA3C57OS8xCaELlEVnGaj ++BJmontwUixX2+rE9M5ddAn7yLDkFGnBGD6z4Rxo3RHroL+WccrBttHqCRd/T9Z1Nu2 ExTd7SzHEzic+aIlrCuPcWMCtY7nbxlEVeLbAgxSxE91pXYUachEtHRelljRJnu1JjV7 EMcr0R5X0sqQEqqKH79nWSVWlFSzgTEbN8ssPOyVrCMHm7VD4Q+Uj3wqFVOXQzRM1xoJ 7/thadnbqMqRW86sgeVk+kP2Dn6KPrvKpY1iK7J0FAY8h+sVLDXgL5PFNWz130DZ91IN G7Vg== X-Gm-Message-State: AJcUukd7APK2Qg1k/M/nFRnLlEj1o+UyhVrw+9rdWVQqmtC2fxAINPgx dthjxWTn/ICS+sejRpKiIgQBlIvRz6Y= X-Received: by 2002:a63:2586:: with SMTP id l128mr23899786pgl.104.1548764999906; Tue, 29 Jan 2019 04:29:59 -0800 (PST) Received: from localhost.localdomain (li569-141.members.linode.com. [192.155.82.141]) by smtp.gmail.com with ESMTPSA id h64sm59552502pfc.142.2019.01.29.04.29.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 04:29:59 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mike Leach , Robert Walker , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Coresight ML Cc: Leo Yan Subject: [PATCH v7 3/8] perf cs-etm: Set sample flags for trace discontinuity Date: Tue, 29 Jan 2019 20:28:37 +0800 Message-Id: <20190129122842.32041-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190129122842.32041-1-leo.yan@linaro.org> References: <20190129122842.32041-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the middle of trace stream, it might be interrupted thus the trace data is not continuous, the trace stream firstly is ended for previous trace block and restarted for next block. To display related information for showing trace is restarted, this patch set sample flags for trace discontinuity: - If one discontinuity packet is coming, append flag PERF_IP_FLAG_TRACE_END to the previous packet to indicate the trace has been ended; - If one instruction packet is following discontinuity packet, this instruction packet is the first one packet to restarting trace. So set flag PERF_IP_FLAG_TRACE_START to discontinuity packet, this flag will be used to generate sample when connect with the sequential instruction packet. Signed-off-by: Leo Yan Reviewed-by: Mathieu Poirier --- tools/perf/util/cs-etm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d05cac5295f1..1aa29633ce77 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1111,6 +1111,7 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq) static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) { struct cs_etm_packet *packet = etmq->packet; + struct cs_etm_packet *prev_packet = etmq->prev_packet; switch (packet->sample_type) { case CS_ETM_RANGE: @@ -1170,8 +1171,26 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) packet->last_instr_subtype == OCSD_S_INSTR_V8_RET) packet->flags = PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN; + + /* + * Decoder might insert a discontinuity in the middle of + * instruction packets, fixup prev_packet with flag + * PERF_IP_FLAG_TRACE_BEGIN to indicate restarting trace. + */ + if (prev_packet->sample_type == CS_ETM_DISCONTINUITY) + prev_packet->flags |= PERF_IP_FLAG_BRANCH | + PERF_IP_FLAG_TRACE_BEGIN; break; case CS_ETM_DISCONTINUITY: + /* + * The trace is discontinuous, if the previous packet is + * instruction packet, set flag PERF_IP_FLAG_TRACE_END + * for previous packet. + */ + if (prev_packet->sample_type == CS_ETM_RANGE) + prev_packet->flags |= PERF_IP_FLAG_BRANCH | + PERF_IP_FLAG_TRACE_END; + break; case CS_ETM_EXCEPTION: case CS_ETM_EXCEPTION_RET: case CS_ETM_EMPTY: