1 // Copyright (C) 2015 The Android Open Source Project
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef _IOTOP_TASKSTATS_H
21 #define _IOTOP_TASKSTATS_H
26 class TaskStatistics {
28 TaskStatistics(const taskstats&);
29 TaskStatistics() = default;
30 TaskStatistics(const TaskStatistics&) = default;
31 void AddPidToTgid(const TaskStatistics&);
32 TaskStatistics Update(const TaskStatistics&);
34 pid_t pid() const { return pid_; }
35 const std::string& comm() const { return comm_; }
36 uint64_t read() const { return read_bytes_; }
37 uint64_t write() const { return write_bytes_; }
38 uint64_t read_write() const { return read_write_bytes_; }
39 uint64_t delay_io() const { return block_io_delay_ns_; }
40 uint64_t delay_swap() const { return swap_in_delay_ns_; }
41 uint64_t delay_sched() const { return cpu_delay_ns_; }
42 uint64_t delay_mem() const { return reclaim_delay_ns_; }
43 uint64_t delay_total() const { return total_delay_ns_; }
44 int threads() const { return threads_; }
46 void set_pid(pid_t pid) { pid_ = pid; }
55 uint64_t cpu_delay_count_;
56 uint64_t cpu_delay_ns_;
58 uint64_t block_io_delay_count_;
59 uint64_t block_io_delay_ns_;
61 uint64_t swap_in_delay_count_;
62 uint64_t swap_in_delay_ns_;
64 uint64_t reclaim_delay_count_;
65 uint64_t reclaim_delay_ns_;
67 uint64_t total_delay_ns_;
69 uint64_t cpu_time_real_;
70 uint64_t cpu_time_virtual_;
73 uint64_t write_bytes_;
74 uint64_t read_write_bytes_;
75 uint64_t cancelled_write_bytes_;
80 class TaskstatsSocket {
86 bool GetPidStats(int, TaskStatistics&);
87 bool GetTgidStats(int, TaskStatistics&);
89 bool GetStats(int, int, TaskStatistics& stats);
90 std::unique_ptr<nl_sock, void(*)(nl_sock*)> nl_;
94 #endif // _IOTOP_TASKSTATS_H