Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp280257ybv; Wed, 19 Feb 2020 21:28:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwtp8lIZkraqsTVR/JmHySepUrTFs9QzMDZ9Xqek9TTPIdtWJzhBwjjCTbXQ1C5sARJulut X-Received: by 2002:aca:d610:: with SMTP id n16mr889596oig.108.1582176521972; Wed, 19 Feb 2020 21:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582176521; cv=none; d=google.com; s=arc-20160816; b=WdDyIi5KCb1TrIXRd9L601+h98X4wL1NqU6qDY21kAQYrU/6somrc42EEHdOK6FAE9 EmiBCu7jgZOAkad8X1e6BE+22Z4rL2Td7ldnOlQT3MTEP1vtTYmyP4BnxSh8SaXYW9wx 1/Hp5/053ZWXAT5VDS/uFlPP93XhUirQydCD8xlLu5iyUAKr0Q+DcwTdLME2hfmdIv7L UCQc+PW8k0odo484/gMtXqz8eyUzaGuZuQrre4YnABMnLngybxLR+Wng5Jza9Cn+aKwH RLQkl9Ttn4eFAJdLHVdZWwCB/FzVwdFMaCKH9VBikp065nvCVwwSHZI/KtJaqGPMhO6/ NA2g== 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=Zv8Ik+PS8AssCatpWlWw7JuaIsf6nNBGZuIjVAxbnH8=; b=hDY9YmM7/t9n0tk/Xk5cSmA4dQWnNnKo7KfhWMkiRDMt9jT2Cm+ARtBVR7RNSfHuUx +MLGHg2pc5h75KHwgA8P5NYMoWnV5gtlKq075NV1UpyayW5N+fy+lBTM2thJWHgFVFyR Nn8K8k/5BIWWTSHuwun0tFPFw8oQkzdoImWh9cihuw3mnEnzQGcgjvPT4GdNhXLSgUFG lb4PUt5OSNGv7UmD7abjldJ6b1hnQqiGMfUDnbSNpEcj7bV5KEcS1fY40oIf4o4tWXnJ 8+FsOYrVJUjWJAD8OKRT53cSu8O8ZKsRYW7y3QaqXlVLTMGZtWDHlkmgM1gkkoHVjD7n LzJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rlEkO17u; 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 i13si1067666otc.228.2020.02.19.21.28.29; Wed, 19 Feb 2020 21:28:41 -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=rlEkO17u; 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 S1726637AbgBTF14 (ORCPT + 99 others); Thu, 20 Feb 2020 00:27:56 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41158 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbgBTF1z (ORCPT ); Thu, 20 Feb 2020 00:27:55 -0500 Received: by mail-pl1-f196.google.com with SMTP id t14so1074482plr.8 for ; Wed, 19 Feb 2020 21:27:55 -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=Zv8Ik+PS8AssCatpWlWw7JuaIsf6nNBGZuIjVAxbnH8=; b=rlEkO17uvEGvk0dn8yYsc27klZVZJ/lkHWFe3Tku0KVIgUNR/WgssxdT5U2cdauGal BQ6N3c36LHNmKngNGkWNQCTyIqzU6khb8OlNQk6lt4dY50F85NTSPgGIwj99h4AbzaJa qHB7os3Xo3/0FqjRye3utyyccDi8vqbuh4NX/EXFEQBSs84EgQ/cjNWYc4+EcLGqlICl OAmszArsEqhORyIkzAh//uTx3P2ZyU2ihbyVGFPjxCqxE8VVs46TSY3d2bpfn8Ao4G0b UZyzjp7cBC1zfWHCfwzFLtfpdWQhfegmm9DYEJVfKXW2Zsk0o40iNWrcliCLpfRDA07U I2pw== 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=Zv8Ik+PS8AssCatpWlWw7JuaIsf6nNBGZuIjVAxbnH8=; b=n2yIj/7AFrlo0qPtJh15mdrq8HWwlpcU8wfoDSxLvy1oLgqqFkbApRbFeN0JlVOtPC CjDjvIaegCzFZMMn+cWEvGtGz1PNji6Yc8jZm2K4JGhYCQX3BQEa3s6u7vbP8msgz4i7 A3d3uHqXr3YXIiiUkQvzx6fvBTBmo2Tv7QVCi2I46XgJGcOWgQSsFDS+KyvwghaSAHlH Cbkb7gcBDvOc3/GjQoORBuIE/m0XLGKcKIaSgZfkMEbz0iKaiyDraQTYLLzi4wc3sTPB W61PX7pUA5L3/isY7w/GLSwzJWJMGqWhMP7kNLlNppMIHWsKH5EuSBpYdmLO7e8Qd3PW qfzA== X-Gm-Message-State: APjAAAWHSeE67pzHvNG810wI/DUiZOnN0cc/ZwpRppkEXnLgujETUUv8 TfIrFR+5XdTeRru38DkYrLNZCQ== X-Received: by 2002:a17:902:8a85:: with SMTP id p5mr30524442plo.154.1582176474820; Wed, 19 Feb 2020 21:27:54 -0800 (PST) Received: from localhost.localdomain (li1441-214.members.linode.com. [45.118.134.214]) by smtp.gmail.com with ESMTPSA id l69sm1535663pgd.1.2020.02.19.21.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 21:27:54 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mark Rutland , Mike Leach , Robert Walker , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Coresight ML Cc: Leo Yan Subject: [PATCH v5 1/9] perf cs-etm: Defer to assign exception sample flag Date: Thu, 20 Feb 2020 13:26:53 +0800 Message-Id: <20200220052701.7754-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200220052701.7754-1-leo.yan@linaro.org> References: <20200220052701.7754-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, neither the exception entry packet nor the exception return packet isn't used to generate samples; so the exception packet is only used as an affiliate packet, and the exception sample flag is assigned to its previous range packet, this is finished in the function cs_etm__set_sample_flags(). This patch moves the exception sample flag assignment from cs_etm__set_sample_flags() to cs_etm__exception(), essentially it defers to assign exception sample flag to the previous range packet, thus this gives us a chance to keep the previous range packet's original sample flag. So this patch is only a preparation for later patches and doesn't include any change for the functionality; based on it, we can add extra processing between the exception packet and its previous range packet. To reduce the indenting, this patch bails out directly at the entry of cs_etm__exception() if detects the previous packet is not a range packet. Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index bba969d48076..48932a7a933f 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1479,6 +1479,13 @@ static int cs_etm__sample(struct cs_etm_queue *etmq, static int cs_etm__exception(struct cs_etm_traceid_queue *tidq) { + /* + * Usually the exception packet follows a range packet, if it's not the + * case, directly bail out. + */ + if (tidq->prev_packet->sample_type != CS_ETM_RANGE) + return 0; + /* * When the exception packet is inserted, whether the last instruction * in previous range packet is taken branch or not, we need to force @@ -1490,8 +1497,16 @@ static int cs_etm__exception(struct cs_etm_traceid_queue *tidq) * swap PACKET with PREV_PACKET. This keeps PREV_PACKET to be useful * for generating instruction and branch samples. */ - if (tidq->prev_packet->sample_type == CS_ETM_RANGE) - tidq->prev_packet->last_instr_taken_branch = true; + tidq->prev_packet->last_instr_taken_branch = true; + + /* + * Since the exception packet is not used standalone for generating + * samples and it's affiliation to the previous instruction range + * packet; so set previous range packet flags to tell perf it is an + * exception taken branch. + */ + if (tidq->packet->sample_type == CS_ETM_EXCEPTION) + tidq->prev_packet->flags = tidq->packet->flags; return 0; } @@ -1916,15 +1931,6 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq, PERF_IP_FLAG_CALL | PERF_IP_FLAG_INTERRUPT; - /* - * When the exception packet is inserted, since exception - * packet is not used standalone for generating samples - * and it's affiliation to the previous instruction range - * packet; so set previous range packet flags to tell perf - * it is an exception taken branch. - */ - if (prev_packet->sample_type == CS_ETM_RANGE) - prev_packet->flags = packet->flags; break; case CS_ETM_EXCEPTION_RET: /* -- 2.17.1