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 android.oom_adjuster; 17 18INCLUDE PERFETTO MODULE linux.memory.process; 19 20-- OOM score tables 21 22CREATE VIRTUAL TABLE _mem_ooms_sj USING SPAN_OUTER_JOIN ( 23 android_oom_adj_intervals PARTITIONED upid, 24 _memory_rss_and_swap_per_process_table PARTITIONED upid); 25 26-- Process memory and it's OOM adjuster scores. Detects transitions, each new 27-- interval means that either the memory or OOM adjuster score of the process changed. 28CREATE PERFETTO TABLE memory_oom_score_with_rss_and_swap_per_process ( 29 -- Timestamp the oom_adj score or memory of the process changed 30 ts TIMESTAMP, 31 -- Duration until the next oom_adj score or memory change of the process. 32 dur DURATION, 33 -- oom adjuster score of the process. 34 score LONG, 35 -- oom adjuster bucket of the process. 36 bucket STRING, 37 -- Upid of the process having an oom_adj update. 38 upid JOINID(process.id), 39 -- Name of the process having an oom_adj update. 40 process_name STRING, 41 -- Pid of the process having an oom_adj update. 42 pid LONG, 43 -- Slice of the latest oom_adj update in the system_server. 44 oom_adj_id JOINID(slice.id), 45 -- Timestamp of the latest oom_adj update in the system_server. 46 oom_adj_ts TIMESTAMP, 47 -- Duration of the latest oom_adj update in the system_server. 48 oom_adj_dur DURATION, 49 -- Track of the latest oom_adj update in the system_server. Alias of 50 -- `track.id`. 51 oom_adj_track_id JOINID(track.id), 52 -- Thread name of the latest oom_adj update in the system_server. 53 oom_adj_thread_name STRING, 54 -- Reason for the latest oom_adj update in the system_server. 55 oom_adj_reason STRING, 56 -- Trigger for the latest oom_adj update in the system_server. 57 oom_adj_trigger STRING, 58 -- Anon RSS counter value 59 anon_rss LONG, 60 -- File RSS counter value 61 file_rss LONG, 62 -- Shared memory RSS counter value 63 shmem_rss LONG, 64 -- Total RSS value. Sum of `anon_rss`, `file_rss` and `shmem_rss`. Returns 65 -- value even if one of the values is NULL. 66 rss LONG, 67 -- Swap counter value 68 swap LONG, 69 -- Sum or `anon_rss` and `swap`. Returns value even if one of the values is 70 -- NULL. 71 anon_rss_and_swap LONG, 72 -- Sum or `rss` and `swap`. Returns value even if one of the values is NULL. 73 rss_and_swap LONG 74) AS 75SELECT 76 ts, 77 dur, 78 score, 79 bucket, 80 upid, 81 process_name, 82 pid, 83 oom_adj_id, 84 oom_adj_ts, 85 oom_adj_dur, 86 oom_adj_track_id, 87 oom_adj_thread_name, 88 oom_adj_reason, 89 oom_adj_trigger, 90 anon_rss, 91 file_rss, 92 shmem_rss, 93 file_rss + anon_rss + coalesce(shmem_rss, 0) AS rss, 94 swap, 95 anon_rss + coalesce(swap, 0) AS anon_rss_and_swap, 96 anon_rss + file_rss + coalesce(shmem_rss, 0) + coalesce(swap, 0) AS rss_and_swap 97FROM _mem_ooms_sj 98JOIN process 99 USING (upid); 100