1 /* 2 * Copyright (C) 2021 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 * http://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 */ 16 17 package com.android.internal.os; 18 19 import android.annotation.Nullable; 20 21 /** Wrapper around libdmabufinfo. */ 22 public final class DmabufInfoReader { DmabufInfoReader()23 private DmabufInfoReader() {} 24 25 /** Process dma-buf stats. */ 26 public static final class ProcessDmabuf { 27 /** Size of buffers retained by the process. */ 28 public final int retainedSizeKb; 29 /** Number of buffers retained by the process. */ 30 public final int retainedBuffersCount; 31 /** Size of buffers mapped to the address space. */ 32 public final int mappedSizeKb; 33 /** Count of buffers mapped to the address space. */ 34 public final int mappedBuffersCount; 35 ProcessDmabuf(int retainedSizeKb, int retainedBuffersCount, int mappedSizeKb, int mappedBuffersCount)36 ProcessDmabuf(int retainedSizeKb, int retainedBuffersCount, 37 int mappedSizeKb, int mappedBuffersCount) { 38 this.retainedSizeKb = retainedSizeKb; 39 this.retainedBuffersCount = retainedBuffersCount; 40 this.mappedSizeKb = mappedSizeKb; 41 this.mappedBuffersCount = mappedBuffersCount; 42 } 43 } 44 45 /** 46 * Return stats for DMA-BUFs retained by process pid or null if the DMA-BUF 47 * stats could not be read. 48 */ 49 @Nullable getProcessStats(int pid)50 public static native ProcessDmabuf getProcessStats(int pid); 51 } 52