1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 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 EBPF_STDTYPE_H 17 #define EBPF_STDTYPE_H 18 #include "base_stdtype.h" 19 20 namespace SysTuning { 21 namespace TraceStdtype { 22 23 struct FileSystemSampleRow { 24 /* data */ 25 uint32_t callChainId = INVALID_UINT32; 26 uint16_t type = INVALID_UINT16; 27 uint32_t ipid = INVALID_UINT32; 28 uint32_t itid = INVALID_UINT32; 29 uint64_t startTs = INVALID_UINT64; 30 uint64_t endTs = INVALID_UINT64; 31 uint64_t dur = INVALID_UINT64; 32 DataIndex returnValue = INVALID_DATAINDEX; 33 DataIndex errorCode = INVALID_DATAINDEX; 34 size_t size; 35 int32_t fd = INVALID_UINT32; 36 DataIndex fileId = INVALID_DATAINDEX; 37 DataIndex firstArgument = INVALID_DATAINDEX; 38 DataIndex secondArgument = INVALID_DATAINDEX; 39 DataIndex thirdArgument = INVALID_DATAINDEX; 40 DataIndex fourthArgument = INVALID_DATAINDEX; 41 }; 42 43 class FileSystemSample : public CacheBase { 44 public: 45 size_t AppendNewData(const FileSystemSampleRow &context); 46 const std::deque<uint32_t> &CallChainIds() const; 47 const std::deque<uint16_t> &Types() const; 48 const std::deque<uint32_t> &Ipids() const; 49 const std::deque<uint32_t> &Itids() const; 50 const std::deque<uint64_t> &StartTs() const; 51 const std::deque<uint64_t> &EndTs() const; 52 const std::deque<uint64_t> &Durs() const; 53 const std::deque<DataIndex> &ReturnValues() const; 54 const std::deque<DataIndex> &ErrorCodes() const; 55 const std::deque<int32_t> &Fds() const; 56 const std::deque<DataIndex> &FileIds() const; 57 const std::deque<size_t> &Sizes() const; 58 const std::deque<DataIndex> &FirstArguments() const; 59 const std::deque<DataIndex> &SecondArguments() const; 60 const std::deque<DataIndex> &ThirdArguments() const; 61 const std::deque<DataIndex> &FourthArguments() const; Clear()62 void Clear() override 63 { 64 CacheBase::Clear(); 65 callChainIds_.clear(); 66 types_.clear(); 67 ipids_.clear(); 68 itids_.clear(); 69 startTs_.clear(); 70 endTs_.clear(); 71 durs_.clear(); 72 returnValues_.clear(); 73 errorCodes_.clear(); 74 fds_.clear(); 75 Sizes_.clear(); 76 firstArguments_.clear(); 77 secondArguments_.clear(); 78 thirdArguments_.clear(); 79 fourthArguments_.clear(); 80 } 81 82 private: 83 std::deque<uint32_t> callChainIds_ = {}; 84 std::deque<uint16_t> types_ = {}; 85 std::deque<uint32_t> ipids_ = {}; 86 std::deque<uint32_t> itids_ = {}; 87 std::deque<uint64_t> startTs_ = {}; 88 std::deque<uint64_t> endTs_ = {}; 89 std::deque<uint64_t> durs_ = {}; 90 std::deque<DataIndex> returnValues_ = {}; 91 std::deque<DataIndex> errorCodes_ = {}; 92 std::deque<int32_t> fds_ = {}; 93 std::deque<DataIndex> fileIds_ = {}; 94 std::deque<size_t> Sizes_ = {}; 95 std::deque<DataIndex> firstArguments_ = {}; 96 std::deque<DataIndex> secondArguments_ = {}; 97 std::deque<DataIndex> thirdArguments_ = {}; 98 std::deque<DataIndex> fourthArguments_ = {}; 99 }; 100 101 struct PagedMemorySampleDataRow { 102 /* data */ 103 uint32_t callChainId = INVALID_UINT32; 104 uint16_t type = INVALID_UINT16; 105 uint32_t ipid = INVALID_UINT32; 106 uint64_t startTs = INVALID_UINT64; 107 uint64_t endTs = INVALID_UINT64; 108 uint64_t dur = INVALID_UINT64; 109 size_t size; 110 DataIndex addr = INVALID_DATAINDEX; 111 uint32_t itid = INVALID_UINT32; 112 }; 113 114 class PagedMemorySampleData : public CacheBase { 115 public: 116 size_t AppendNewData(const PagedMemorySampleDataRow &context); 117 const std::deque<uint32_t> &CallChainIds() const; 118 const std::deque<uint16_t> &Types() const; 119 const std::deque<uint32_t> &Ipids() const; 120 const std::deque<uint64_t> &StartTs() const; 121 const std::deque<uint64_t> &EndTs() const; 122 const std::deque<uint64_t> &Durs() const; 123 const std::deque<size_t> &Sizes() const; 124 const std::deque<DataIndex> &Addr() const; 125 const std::deque<uint32_t> &Itids() const; Clear()126 void Clear() override 127 { 128 CacheBase::Clear(); 129 callChainIds_.clear(); 130 types_.clear(); 131 ipids_.clear(); 132 startTs_.clear(); 133 endTs_.clear(); 134 durs_.clear(); 135 Sizes_.clear(); 136 addrs_.clear(); 137 itids_.clear(); 138 } 139 140 private: 141 std::deque<uint32_t> callChainIds_ = {}; 142 std::deque<uint16_t> types_ = {}; 143 std::deque<uint32_t> ipids_ = {}; 144 std::deque<uint64_t> startTs_ = {}; 145 std::deque<uint64_t> endTs_ = {}; 146 std::deque<uint64_t> durs_ = {}; 147 std::deque<size_t> Sizes_ = {}; 148 std::deque<DataIndex> addrs_ = {}; 149 std::deque<uint32_t> itids_ = {}; 150 }; 151 152 struct BioLatencySampleDataRow { 153 /* data */ 154 uint32_t callChainId = INVALID_UINT32; 155 uint64_t type = INVALID_UINT64; 156 uint32_t ipid = INVALID_UINT32; 157 uint32_t itid = INVALID_UINT32; 158 uint64_t startTs = INVALID_UINT64; 159 uint64_t endTs = INVALID_UINT64; 160 uint64_t latencyDur = INVALID_UINT64; 161 uint32_t tier = INVALID_UINT32; 162 uint64_t size = INVALID_UINT64; 163 uint64_t blockNumber = INVALID_UINT64; 164 uint64_t filePathId = INVALID_UINT64; 165 uint64_t durPer4k = INVALID_UINT64; 166 }; 167 168 class BioLatencySampleData : public CacheBase { 169 public: 170 void AppendNewData(const BioLatencySampleDataRow &context); 171 const std::deque<uint32_t> &CallChainIds() const; 172 const std::deque<uint64_t> &Types() const; 173 const std::deque<uint32_t> &Ipids() const; 174 const std::deque<uint32_t> &Itids() const; 175 const std::deque<uint64_t> &StartTs() const; 176 const std::deque<uint64_t> &EndTs() const; 177 const std::deque<uint64_t> &LatencyDurs() const; 178 const std::deque<uint32_t> &Tiers() const; 179 const std::deque<uint64_t> &Sizes() const; 180 const std::deque<uint64_t> &BlockNumbers() const; 181 const std::deque<uint64_t> &FilePathIds() const; 182 const std::deque<uint64_t> &DurPer4k() const; Clear()183 void Clear() override 184 { 185 CacheBase::Clear(); 186 callChainIds_.clear(); 187 types_.clear(); 188 ipids_.clear(); 189 itids_.clear(); 190 startTs_.clear(); 191 endTs_.clear(); 192 latencyDurs_.clear(); 193 tiers_.clear(); 194 sizes_.clear(); 195 blockNumbers_.clear(); 196 filePathIds_.clear(); 197 durPer4ks_.clear(); 198 } 199 200 private: 201 std::deque<uint32_t> callChainIds_ = {}; 202 std::deque<uint64_t> types_ = {}; 203 std::deque<uint32_t> ipids_ = {}; 204 std::deque<uint32_t> itids_ = {}; 205 std::deque<uint64_t> startTs_ = {}; 206 std::deque<uint64_t> endTs_ = {}; 207 std::deque<uint64_t> latencyDurs_ = {}; 208 std::deque<uint32_t> tiers_ = {}; 209 std::deque<uint64_t> sizes_ = {}; 210 std::deque<uint64_t> blockNumbers_ = {}; 211 std::deque<uint64_t> filePathIds_ = {}; 212 std::deque<uint64_t> durPer4ks_ = {}; 213 uint32_t rowCount_ = 0; 214 }; 215 216 struct EbpfCallStackDataRow { 217 /* data */ 218 uint32_t callChainId = INVALID_UINT32; 219 uint32_t depth = INVALID_UINT32; 220 DataIndex ip = INVALID_DATAINDEX; 221 DataIndex symbolId = INVALID_DATAINDEX; 222 DataIndex filePathId = INVALID_DATAINDEX; 223 uint64_t vaddr = INVALID_UINT64; 224 }; 225 226 class EbpfCallStackData : public CacheBase { 227 public: 228 size_t AppendNewData(const EbpfCallStackDataRow &context); 229 void UpdateEbpfSymbolInfo(size_t row, DataIndex symbolId); 230 const std::deque<uint32_t> &CallChainIds() const; 231 const std::deque<uint32_t> &Depths() const; 232 const std::deque<DataIndex> &Ips() const; 233 const std::deque<DataIndex> &SymbolIds() const; 234 const std::deque<DataIndex> &FilePathIds() const; 235 const std::deque<uint64_t> &Vaddrs() const; Clear()236 void Clear() override 237 { 238 CacheBase::Clear(); 239 callChainIds_.clear(); 240 depths_.clear(); 241 symbolIds_.clear(); 242 filePathIds_.clear(); 243 vaddrs_.clear(); 244 } 245 246 private: 247 std::deque<uint32_t> callChainIds_ = {}; 248 std::deque<uint32_t> depths_ = {}; 249 std::deque<DataIndex> ips_ = {}; 250 std::deque<DataIndex> symbolIds_ = {}; 251 std::deque<DataIndex> filePathIds_ = {}; 252 std::deque<uint64_t> vaddrs_ = {}; 253 }; 254 } // namespace TraceStdtype 255 } // namespace SysTuning 256 #endif // EBPF_STDTYPE_H 257