• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2024 The Android Open Source Project
3--
4-- Licensed under the Apache License, Version 2.0 (the "License");
5-- you may not use this file except in compliance with the License.
6-- You may obtain a copy of the License at
7--
8--     https://www.apache.org/licenses/LICENSE-2.0
9--
10-- Unless required by applicable law or agreed to in writing, software
11-- distributed under the License is distributed on an "AS IS" BASIS,
12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-- See the License for the specific language governing permissions and
14-- limitations under the License.
15
16INCLUDE PERFETTO MODULE intervals.overlap;
17
18-- View tracking the number of IO operations remaining in the kernel IO queue or
19-- a block device
20CREATE PERFETTO VIEW linux_active_block_io_operations_by_device (
21  -- timestamp when block_io_start or block_io_done happened
22  ts LONG,
23  -- the number of IO operations in the kernel queue or the device
24  ops_in_queue_or_device LONG,
25  -- the device processing the IO operations
26  dev LONG
27) AS
28WITH
29  block_io_slice AS (
30    SELECT
31      slice.ts AS ts,
32      slice.dur AS dur,
33      extract_arg(track.dimension_arg_set_id, 'block_device') AS dev
34    FROM slice
35    JOIN track
36      ON slice.track_id = track.id AND track.type = 'block_io'
37  )
38SELECT
39  ts,
40  value AS ops_in_queue_or_device,
41  group_name AS dev
42FROM intervals_overlap_count_by_group!(block_io_slice, ts, dur, dev);
43
44-- Extracts the major id from a device id
45CREATE PERFETTO FUNCTION linux_device_major_id(
46    -- device id (userland dev_t value)
47    dev LONG
48)
49-- 12 bits major id
50RETURNS LONG AS
51SELECT
52  (
53    $dev >> 8
54  ) & (
55    (
56      1 << 12
57    ) - 1
58  );
59
60-- Extracts the minor id from a device id
61CREATE PERFETTO FUNCTION linux_device_minor_id(
62    -- device id (userland dev_t value)
63    dev LONG
64)
65-- 20 bits minor id
66RETURNS LONG AS
67SELECT
68  (
69    $dev & (
70      (
71        1 << 8
72      ) - 1
73    )
74  ) | (
75    (
76      $dev >> 20
77    ) << 8
78  );
79