1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef IRQ_FILTER_H 17 #define IRQ_FILTER_H 18 19 #include <unordered_set> 20 #include "args_set.h" 21 #include "filter_base.h" 22 #include "trace_data_cache.h" 23 #include "trace_streamer_filters.h" 24 namespace SysTuning { 25 namespace TraceStreamer { 26 class IrqFilter : private FilterBase { 27 public: 28 IrqFilter(TraceDataCache*, const TraceStreamerFilters*); 29 IrqFilter(const IrqFilter&) = delete; 30 IrqFilter& operator=(const IrqFilter&) = delete; 31 ~IrqFilter() override; 32 33 public: 34 void IrqHandlerEntry(int64_t ts, uint32_t cpu, DataIndex nameId); 35 void IrqHandlerExit(int64_t ts, uint32_t cpu, uint32_t ret); 36 void SoftIrqEntry(int64_t ts, uint32_t cpu, uint32_t vec); 37 void SoftIrqExit(int64_t ts, uint32_t cpu, uint32_t vec); 38 void Clear(); 39 private: 40 const DataIndex irqId_ = traceDataCache_->GetDataIndex("irq_id"); 41 const DataIndex irqRet_ = traceDataCache_->GetDataIndex("irq_ret"); 42 const DataIndex irqHandled_ = traceDataCache_->GetDataIndex("handled"); 43 const DataIndex irqUnHandled_ = traceDataCache_->GetDataIndex("unhandled"); 44 const DataIndex irqCatalog_ = traceDataCache_->GetDataIndex("irq"); 45 const DataIndex softIrqCatalog_ = traceDataCache_->GetDataIndex("softirq"); 46 std::unordered_map<uint64_t, int64_t> lastEventTs_ = {}; 47 std::unordered_set<uint64_t> transReplyWaitingReply_ = {}; 48 std::unordered_map<uint64_t, FilterId> transWaitingRcv_ = {}; 49 std::unordered_map<uint64_t, ArgsSet> transNoNeedReply_ = {}; 50 std::unordered_map<int, std::string> binderFlagDescs_ = {}; 51 std::vector<std::string> irqActionNames_ = {"HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", 52 "BLOCK_IOPOLL", "TASKLET", "SCHED", "HRTIMER", "RCU"}; 53 std::vector<DataIndex> irqActionNameIds_ = {}; 54 }; 55 } // namespace TraceStreamer 56 } // namespace SysTuning 57 58 #endif // IRQ_FILTER_H 59