perf cs-etm: Don’t check cs_etm_queue::prev_packet validity [Linux 5.1]

perf cs-etm: Don’t check cs_etm_queue::prev_packet validity [Linux 5.1]

This Linux kernel change "perf cs-etm: Don’t check cs_etm_queue::prev_packet validity" is included in the Linux 5.1 release. This change is authored by Leo Yan <leo.yan [at] linaro.org> on Sun Apr 28 16:32:28 2019 +0800. The commit for this change in Linux stable tree is cf0c37b (patch).

perf cs-etm: Don't check cs_etm_queue::prev_packet validity

Since cs_etm_queue::prev_packet is allocated for all cases, it will
never be NULL pointer; now validity checking prev_packet is pointless,
remove all of them.

Signed-off-by: Leo Yan <[email protected]>
Tested-by: Robert Walker <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mathieu Poirier <[email protected]>
Cc: Mike Leach <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Suzuki K Poulouse <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 tools/perf/util/cs-etm.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 1108049..7777cfc 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -981,7 +981,6 @@ static int cs_etm__sample(struct cs_etm_queue *etmq)
     * PREV_PACKET is a branch.
     */
    if (etm->synth_opts.last_branch &&
-       etmq->prev_packet &&
        etmq->prev_packet->sample_type == CS_ETM_RANGE &&
        etmq->prev_packet->last_instr_taken_branch)
        cs_etm__update_last_branch_rb(etmq);
@@ -1014,7 +1013,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq)
        etmq->period_instructions = instrs_over;
    }

-   if (etm->sample_branches && etmq->prev_packet) {
+   if (etm->sample_branches) {
        bool generate_sample = false;

        /* Generate sample for tracing on packet */
@@ -1071,9 +1070,6 @@ static int cs_etm__flush(struct cs_etm_queue *etmq)
    struct cs_etm_auxtrace *etm = etmq->etm;
    struct cs_etm_packet *tmp;

-   if (!etmq->prev_packet)
-       return 0;
-
    /* Handle start tracing packet */
    if (etmq->prev_packet->sample_type == CS_ETM_EMPTY)
        goto swap_packet;

Leave a Reply

Your email address will not be published. Required fields are marked *