/* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SRC_TRACE_PROCESSOR_TYPES_TASK_STATE_H_ #define SRC_TRACE_PROCESSOR_TYPES_TASK_STATE_H_ #include <stdint.h> #include <array> #include <optional> #include "src/trace_processor/types/version_number.h" namespace perfetto { namespace trace_processor { namespace ftrace_utils { // Linux kernel scheduling events (sched_switch) contain a bitmask of the // switched-out task's state (prev_state). Perfetto doesn't record the event // format string during tracing, the trace contains only the raw bitmask as an // integer. Certain kernel versions made backwards incompatible changes to the // bitmask's raw representation, so this class guesses how to decode the flags // based on the kernel's major+minor version as recorded in the trace. Note: // this means we can be wrong if patch backports change the flags, or the // kernel diverged from upstream. But this has worked well enough in practice // so far. // // There are three specific kernel version intervals we handle: // * [4.14, ...) // * [4.8, 4.14) // * (..., 4.8), where we assume the 4.4 bitmask // // (Therefore kernels before 4.2 most likely have incorrect preemption flag // parsing.) // // For 4.14, we assume that the kernel has a backport of the bugfix // https://github.com/torvalds/linux/commit/3f5fe9fe ("sched/debug: Fix task // state recording/printout"). In other words, traces collected on unpatched // 4.14 kernels will have incorrect flags decoded. class TaskState { … }; } // namespace ftrace_utils } // namespace trace_processor } // namespace perfetto #endif // SRC_TRACE_PROCESSOR_TYPES_TASK_STATE_H_