1<!DOCTYPE html> 2<!-- 3Copyright (c) 2012 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/extras/importer/linux_perf/parser.html"> 9 10<script> 11'use strict'; 12 13/** 14 * @fileoverview Parses workqueue events in the Linux event trace format. 15 */ 16tr.exportTo('tr.e.importer.linux_perf', function() { 17 18 var ColorScheme = tr.b.ColorScheme; 19 var Parser = tr.e.importer.linux_perf.Parser; 20 21 /** 22 * Parses linux workqueue trace events. 23 * @constructor 24 */ 25 function WorkqueueParser(importer) { 26 Parser.call(this, importer); 27 28 importer.registerEventHandler('workqueue_execute_start', 29 WorkqueueParser.prototype.executeStartEvent.bind(this)); 30 importer.registerEventHandler('workqueue_execute_end', 31 WorkqueueParser.prototype.executeEndEvent.bind(this)); 32 importer.registerEventHandler('workqueue_queue_work', 33 WorkqueueParser.prototype.executeQueueWork.bind(this)); 34 importer.registerEventHandler('workqueue_activate_work', 35 WorkqueueParser.prototype.executeActivateWork.bind(this)); 36 } 37 38 // Matches the workqueue_execute_start record 39 // workqueue_execute_start: work struct c7a8a89c: function MISRWrapper 40 var workqueueExecuteStartRE = /work struct (.+): function (\S+)/; 41 42 // Matches the workqueue_execute_start record 43 // workqueue_execute_end: work struct c7a8a89c 44 var workqueueExecuteEndRE = /work struct (.+)/; 45 46 WorkqueueParser.prototype = { 47 __proto__: Parser.prototype, 48 49 /** 50 * Parses workqueue events and sets up state in the importer. 51 */ 52 executeStartEvent: function(eventName, cpuNumber, pid, ts, eventBase) { 53 var event = workqueueExecuteStartRE.exec(eventBase.details); 54 if (!event) 55 return false; 56 57 var kthread = this.importer.getOrCreateKernelThread(eventBase.threadName, 58 pid, pid); 59 kthread.openSliceTS = ts; 60 kthread.openSlice = event[2]; 61 return true; 62 }, 63 64 executeEndEvent: function(eventName, cpuNumber, pid, ts, eventBase) { 65 var event = workqueueExecuteEndRE.exec(eventBase.details); 66 if (!event) 67 return false; 68 69 var kthread = this.importer.getOrCreateKernelThread(eventBase.threadName, 70 pid, pid); 71 if (kthread.openSlice) { 72 var slice = new tr.model.Slice('', kthread.openSlice, 73 ColorScheme.getColorIdForGeneralPurposeString(kthread.openSlice), 74 kthread.openSliceTS, 75 {}, 76 ts - kthread.openSliceTS); 77 78 kthread.thread.sliceGroup.pushSlice(slice); 79 } 80 kthread.openSlice = undefined; 81 return true; 82 }, 83 84 executeQueueWork: function(eventName, cpuNumber, pid, ts, eventBase) { 85 // TODO: Do something with this event? 86 return true; 87 }, 88 89 executeActivateWork: function(eventName, cpuNumber, pid, ts, eventBase) { 90 // TODO: Do something with this event? 91 return true; 92 } 93 94 }; 95 96 Parser.register(WorkqueueParser); 97 98 return { 99 WorkqueueParser: WorkqueueParser 100 }; 101}); 102</script> 103 104