Home | History | Annotate | Download | only in linux_perf
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 'use strict';
      6 
      7 /**
      8  * @fileoverview Parses exynos events in the Linux event trace format.
      9  */
     10 base.require('tracing.importer.linux_perf.parser');
     11 base.exportTo('tracing.importer.linux_perf', function() {
     12 
     13   var Parser = tracing.importer.linux_perf.Parser;
     14 
     15   /**
     16    * Parses linux exynos trace events.
     17    * @constructor
     18    */
     19   function ExynosParser(importer) {
     20     Parser.call(this, importer);
     21 
     22     importer.registerEventHandler('exynos_flip_request',
     23         ExynosParser.prototype.flipEvent.bind(this));
     24     importer.registerEventHandler('exynos_flip_complete',
     25         ExynosParser.prototype.flipEvent.bind(this));
     26 
     27     importer.registerEventHandler('exynos_busfreq_target_int',
     28         ExynosParser.prototype.busfreqTargetIntEvent.bind(this));
     29     importer.registerEventHandler('exynos_busfreq_target_mif',
     30         ExynosParser.prototype.busfreqTargetMifEvent.bind(this));
     31   }
     32 
     33   ExynosParser.prototype = {
     34     __proto__: Parser.prototype,
     35 
     36     exynosFlipOpenSlice: function(ts, pipe) {
     37       // use pipe?
     38       var kthread = this.importer.getOrCreatePseudoThread('exynos_flip');
     39       kthread.openSliceTS = ts;
     40       kthread.openSlice = 'flip:' + pipe;
     41     },
     42 
     43     exynosFlipCloseSlice: function(ts, args) {
     44       var kthread = this.importer.getOrCreatePseudoThread('exynos_flip');
     45       if (kthread.openSlice) {
     46         var slice = new tracing.trace_model.Slice('', kthread.openSlice,
     47             tracing.getStringColorId(kthread.openSlice),
     48             kthread.openSliceTS,
     49             args,
     50             ts - kthread.openSliceTS);
     51 
     52         kthread.thread.sliceGroup.pushSlice(slice);
     53       }
     54       kthread.openSlice = undefined;
     55     },
     56 
     57     /**
     58      * Parses exynos events and sets up state in the importer.
     59      */
     60     flipEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
     61       var event = /pipe=(\d+)/.exec(eventBase.details);
     62       if (!event)
     63         return false;
     64 
     65       var pipe = parseInt(event[1]);
     66       if (eventName == 'exynos_flip_request')
     67         this.exynosFlipOpenSlice(ts, pipe);
     68       else
     69         this.exynosFlipCloseSlice(ts,
     70             {
     71               pipe: pipe
     72             });
     73       return true;
     74     },
     75 
     76     exynosBusfreqSample: function(name, ts, frequency) {
     77       var targetCpu = this.importer.getOrCreateCpuState(0);
     78       var counter = targetCpu.cpu.getOrCreateCounter('', name);
     79       if (counter.numSeries === 0) {
     80         counter.addSeries(new tracing.trace_model.CounterSeries('frequency',
     81             tracing.getStringColorId(counter.name + '.' + 'frequency')));
     82       }
     83       counter.series.forEach(function(series) {
     84         series.addSample(ts, frequency);
     85       });
     86     },
     87 
     88     /**
     89      * Parses exynos_busfreq_target_int events and sets up state.
     90      */
     91     busfreqTargetIntEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
     92       var event = /frequency=(\d+)/.exec(eventBase.details);
     93       if (!event)
     94         return false;
     95 
     96       this.exynosBusfreqSample('INT Frequency', ts, parseInt(event[1]));
     97       return true;
     98     },
     99 
    100     /**
    101      * Parses exynos_busfreq_target_mif events and sets up state.
    102      */
    103     busfreqTargetMifEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
    104       var event = /frequency=(\d+)/.exec(eventBase.details);
    105       if (!event)
    106         return false;
    107 
    108       this.exynosBusfreqSample('MIF Frequency', ts, parseInt(event[1]));
    109       return true;
    110     }
    111   };
    112 
    113   Parser.registerSubtype(ExynosParser);
    114 
    115   return {
    116     ExynosParser: ExynosParser
    117   };
    118 });
    119