Loading core/java/com/android/internal/app/procstats/ProcessStats.java +40 −13 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.Parcelable; import android.os.SystemClock; import android.os.SystemClock; import android.os.SystemProperties; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserHandle; import android.service.procstats.ProcessStatsAvailablePagesProto; import android.service.procstats.ProcessStatsPackageProto; import android.service.procstats.ProcessStatsPackageProto; import android.service.procstats.ProcessStatsSectionProto; import android.service.procstats.ProcessStatsSectionProto; import android.text.format.DateFormat; import android.text.format.DateFormat; Loading Loading @@ -178,7 +179,7 @@ public final class ProcessStats implements Parcelable { {"proc", "pkg-proc", "pkg-svc", "pkg-asc", "pkg-all", "all"}; {"proc", "pkg-proc", "pkg-svc", "pkg-asc", "pkg-all", "all"}; // Current version of the parcel format. // Current version of the parcel format. private static final int PARCEL_VERSION = 35; private static final int PARCEL_VERSION = 36; // In-memory Parcel magic number, used to detect attempts to unmarshall bad data // In-memory Parcel magic number, used to detect attempts to unmarshall bad data private static final int MAGIC = 0x50535454; private static final int MAGIC = 0x50535454; Loading Loading @@ -237,10 +238,11 @@ public final class ProcessStats implements Parcelable { ArrayList<String> mIndexToCommonString; ArrayList<String> mIndexToCommonString; private static final Pattern sPageTypeRegex = Pattern.compile( private static final Pattern sPageTypeRegex = Pattern.compile( "^Node\\s+(\\d+),.*. type\\s+(\\w+)\\s+([\\s\\d]+?)\\s*$"); "^Node\\s+(\\d+),.* zone\\s+(\\w+),.* type\\s+(\\w+)\\s+([\\s\\d]+?)\\s*$"); private final ArrayList<Integer> mPageTypeZones = new ArrayList<Integer>(); private final ArrayList<Integer> mPageTypeNodes = new ArrayList<>(); private final ArrayList<String> mPageTypeLabels = new ArrayList<String>(); private final ArrayList<String> mPageTypeZones = new ArrayList<>(); private final ArrayList<int[]> mPageTypeSizes = new ArrayList<int[]>(); private final ArrayList<String> mPageTypeLabels = new ArrayList<>(); private final ArrayList<int[]> mPageTypeSizes = new ArrayList<>(); public ProcessStats(boolean running) { public ProcessStats(boolean running) { mRunning = running; mRunning = running; Loading Loading @@ -621,6 +623,7 @@ public final class ProcessStats implements Parcelable { try { try { reader = new BufferedReader(new FileReader("/proc/pagetypeinfo")); reader = new BufferedReader(new FileReader("/proc/pagetypeinfo")); final Matcher matcher = sPageTypeRegex.matcher(""); final Matcher matcher = sPageTypeRegex.matcher(""); mPageTypeNodes.clear(); mPageTypeZones.clear(); mPageTypeZones.clear(); mPageTypeLabels.clear(); mPageTypeLabels.clear(); mPageTypeSizes.clear(); mPageTypeSizes.clear(); Loading @@ -631,16 +634,18 @@ public final class ProcessStats implements Parcelable { } } matcher.reset(line); matcher.reset(line); if (matcher.matches()) { if (matcher.matches()) { final Integer zone = Integer.valueOf(matcher.group(1), 10); final Integer node = Integer.valueOf(matcher.group(1), 10); if (zone == null) { if (node == null) { continue; continue; } } mPageTypeZones.add(zone); mPageTypeNodes.add(node); mPageTypeLabels.add(matcher.group(2)); mPageTypeZones.add(matcher.group(2)); mPageTypeSizes.add(splitAndParseNumbers(matcher.group(3))); mPageTypeLabels.add(matcher.group(3)); mPageTypeSizes.add(splitAndParseNumbers(matcher.group(4))); } } } } } catch (IOException ex) { } catch (IOException ex) { mPageTypeNodes.clear(); mPageTypeZones.clear(); mPageTypeZones.clear(); mPageTypeLabels.clear(); mPageTypeLabels.clear(); mPageTypeSizes.clear(); mPageTypeSizes.clear(); Loading Loading @@ -935,7 +940,8 @@ public final class ProcessStats implements Parcelable { final int NPAGETYPES = mPageTypeLabels.size(); final int NPAGETYPES = mPageTypeLabels.size(); out.writeInt(NPAGETYPES); out.writeInt(NPAGETYPES); for (int i=0; i<NPAGETYPES; i++) { for (int i=0; i<NPAGETYPES; i++) { out.writeInt(mPageTypeZones.get(i)); out.writeInt(mPageTypeNodes.get(i)); out.writeString(mPageTypeZones.get(i)); out.writeString(mPageTypeLabels.get(i)); out.writeString(mPageTypeLabels.get(i)); out.writeIntArray(mPageTypeSizes.get(i)); out.writeIntArray(mPageTypeSizes.get(i)); } } Loading Loading @@ -1244,6 +1250,8 @@ public final class ProcessStats implements Parcelable { // Fragmentation info // Fragmentation info final int NPAGETYPES = in.readInt(); final int NPAGETYPES = in.readInt(); mPageTypeNodes.clear(); mPageTypeNodes.ensureCapacity(NPAGETYPES); mPageTypeZones.clear(); mPageTypeZones.clear(); mPageTypeZones.ensureCapacity(NPAGETYPES); mPageTypeZones.ensureCapacity(NPAGETYPES); mPageTypeLabels.clear(); mPageTypeLabels.clear(); Loading @@ -1251,7 +1259,8 @@ public final class ProcessStats implements Parcelable { mPageTypeSizes.clear(); mPageTypeSizes.clear(); mPageTypeSizes.ensureCapacity(NPAGETYPES); mPageTypeSizes.ensureCapacity(NPAGETYPES); for (int i=0; i<NPAGETYPES; i++) { for (int i=0; i<NPAGETYPES; i++) { mPageTypeZones.add(in.readInt()); mPageTypeNodes.add(in.readInt()); mPageTypeZones.add(in.readString()); mPageTypeLabels.add(in.readString()); mPageTypeLabels.add(in.readString()); mPageTypeSizes.add(in.createIntArray()); mPageTypeSizes.add(in.createIntArray()); } } Loading Loading @@ -1764,7 +1773,8 @@ public final class ProcessStats implements Parcelable { pw.println("Available pages by page size:"); pw.println("Available pages by page size:"); final int NPAGETYPES = mPageTypeLabels.size(); final int NPAGETYPES = mPageTypeLabels.size(); for (int i=0; i<NPAGETYPES; i++) { for (int i=0; i<NPAGETYPES; i++) { pw.format("Zone %3d %14s ", mPageTypeZones.get(i), mPageTypeLabels.get(i)); pw.format("Node %3d Zone %7s %14s ", mPageTypeNodes.get(i), mPageTypeZones.get(i), mPageTypeLabels.get(i)); final int[] sizes = mPageTypeSizes.get(i); final int[] sizes = mPageTypeSizes.get(i); final int N = sizes == null ? 0 : sizes.length; final int N = sizes == null ? 0 : sizes.length; for (int j=0; j<N; j++) { for (int j=0; j<N; j++) { Loading Loading @@ -2095,6 +2105,9 @@ public final class ProcessStats implements Parcelable { pw.print(","); pw.print(","); pw.print(mPageTypeZones.get(i)); pw.print(mPageTypeZones.get(i)); pw.print(","); pw.print(","); // Wasn't included in original output. //pw.print(mPageTypeNodes.get(i)); //pw.print(","); final int[] sizes = mPageTypeSizes.get(i); final int[] sizes = mPageTypeSizes.get(i); final int N = sizes == null ? 0 : sizes.length; final int N = sizes == null ? 0 : sizes.length; for (int j=0; j<N; j++) { for (int j=0; j<N; j++) { Loading Loading @@ -2135,6 +2148,20 @@ public final class ProcessStats implements Parcelable { proto.write(ProcessStatsSectionProto.STATUS, ProcessStatsSectionProto.STATUS_PARTIAL); proto.write(ProcessStatsSectionProto.STATUS, ProcessStatsSectionProto.STATUS_PARTIAL); } } final int NPAGETYPES = mPageTypeLabels.size(); for (int i = 0; i < NPAGETYPES; i++) { final long token = proto.start(ProcessStatsSectionProto.AVAILABLE_PAGES); proto.write(ProcessStatsAvailablePagesProto.NODE, mPageTypeNodes.get(i)); proto.write(ProcessStatsAvailablePagesProto.ZONE, mPageTypeZones.get(i)); proto.write(ProcessStatsAvailablePagesProto.LABEL, mPageTypeLabels.get(i)); final int[] sizes = mPageTypeSizes.get(i); final int N = sizes == null ? 0 : sizes.length; for (int j = 0; j < N; j++) { proto.write(ProcessStatsAvailablePagesProto.PAGES_PER_ORDER, sizes[j]); } proto.end(token); } final ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); final ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); if ((section & REPORT_PROC_STATS) != 0) { if ((section & REPORT_PROC_STATS) != 0) { for (int ip = 0; ip < procMap.size(); ip++) { for (int ip = 0; ip < procMap.size(); ip++) { Loading core/proto/android/service/procstats.proto +22 −1 Original line number Original line Diff line number Diff line Loading @@ -43,7 +43,7 @@ message ProcessStatsServiceDumpProto { * Data model from /frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java * Data model from /frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java * This proto is defined based on the writeToParcel method. * This proto is defined based on the writeToParcel method. * * * Next Tag: 10 * Next Tag: 11 */ */ message ProcessStatsSectionProto { message ProcessStatsSectionProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; option (android.msg_privacy).dest = DEST_AUTOMATIC; Loading Loading @@ -76,6 +76,9 @@ message ProcessStatsSectionProto { } } repeated Status status = 7; repeated Status status = 7; // Number of pages available of various types and sizes, representation fragmentation. repeated ProcessStatsAvailablePagesProto available_pages = 10; // Stats for each process. // Stats for each process. repeated ProcessStatsProto process_stats = 8; repeated ProcessStatsProto process_stats = 8; Loading @@ -83,6 +86,24 @@ message ProcessStatsSectionProto { repeated ProcessStatsPackageProto package_stats = 9; repeated ProcessStatsPackageProto package_stats = 9; } } // Next Tag: 5 message ProcessStatsAvailablePagesProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; // Node these pages are in (as per /proc/pagetypeinfo) optional int32 node = 1; // Zone these pages are in (as per /proc/pagetypeinfo) optional string zone = 2; // Label for the type of these pages (as per /proc/pagetypeinfo) optional string label = 3; // Distribution of number of pages available by order size. First entry in array is // order 0, second is order 1, etc. Each order increase is a doubling of page size. repeated int32 pages_per_order = 4; } // Next Tag: 10 // Next Tag: 10 message ProcessStatsStateProto { message ProcessStatsStateProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; option (android.msg_privacy).dest = DEST_AUTOMATIC; Loading Loading
core/java/com/android/internal/app/procstats/ProcessStats.java +40 −13 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.Parcelable; import android.os.SystemClock; import android.os.SystemClock; import android.os.SystemProperties; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserHandle; import android.service.procstats.ProcessStatsAvailablePagesProto; import android.service.procstats.ProcessStatsPackageProto; import android.service.procstats.ProcessStatsPackageProto; import android.service.procstats.ProcessStatsSectionProto; import android.service.procstats.ProcessStatsSectionProto; import android.text.format.DateFormat; import android.text.format.DateFormat; Loading Loading @@ -178,7 +179,7 @@ public final class ProcessStats implements Parcelable { {"proc", "pkg-proc", "pkg-svc", "pkg-asc", "pkg-all", "all"}; {"proc", "pkg-proc", "pkg-svc", "pkg-asc", "pkg-all", "all"}; // Current version of the parcel format. // Current version of the parcel format. private static final int PARCEL_VERSION = 35; private static final int PARCEL_VERSION = 36; // In-memory Parcel magic number, used to detect attempts to unmarshall bad data // In-memory Parcel magic number, used to detect attempts to unmarshall bad data private static final int MAGIC = 0x50535454; private static final int MAGIC = 0x50535454; Loading Loading @@ -237,10 +238,11 @@ public final class ProcessStats implements Parcelable { ArrayList<String> mIndexToCommonString; ArrayList<String> mIndexToCommonString; private static final Pattern sPageTypeRegex = Pattern.compile( private static final Pattern sPageTypeRegex = Pattern.compile( "^Node\\s+(\\d+),.*. type\\s+(\\w+)\\s+([\\s\\d]+?)\\s*$"); "^Node\\s+(\\d+),.* zone\\s+(\\w+),.* type\\s+(\\w+)\\s+([\\s\\d]+?)\\s*$"); private final ArrayList<Integer> mPageTypeZones = new ArrayList<Integer>(); private final ArrayList<Integer> mPageTypeNodes = new ArrayList<>(); private final ArrayList<String> mPageTypeLabels = new ArrayList<String>(); private final ArrayList<String> mPageTypeZones = new ArrayList<>(); private final ArrayList<int[]> mPageTypeSizes = new ArrayList<int[]>(); private final ArrayList<String> mPageTypeLabels = new ArrayList<>(); private final ArrayList<int[]> mPageTypeSizes = new ArrayList<>(); public ProcessStats(boolean running) { public ProcessStats(boolean running) { mRunning = running; mRunning = running; Loading Loading @@ -621,6 +623,7 @@ public final class ProcessStats implements Parcelable { try { try { reader = new BufferedReader(new FileReader("/proc/pagetypeinfo")); reader = new BufferedReader(new FileReader("/proc/pagetypeinfo")); final Matcher matcher = sPageTypeRegex.matcher(""); final Matcher matcher = sPageTypeRegex.matcher(""); mPageTypeNodes.clear(); mPageTypeZones.clear(); mPageTypeZones.clear(); mPageTypeLabels.clear(); mPageTypeLabels.clear(); mPageTypeSizes.clear(); mPageTypeSizes.clear(); Loading @@ -631,16 +634,18 @@ public final class ProcessStats implements Parcelable { } } matcher.reset(line); matcher.reset(line); if (matcher.matches()) { if (matcher.matches()) { final Integer zone = Integer.valueOf(matcher.group(1), 10); final Integer node = Integer.valueOf(matcher.group(1), 10); if (zone == null) { if (node == null) { continue; continue; } } mPageTypeZones.add(zone); mPageTypeNodes.add(node); mPageTypeLabels.add(matcher.group(2)); mPageTypeZones.add(matcher.group(2)); mPageTypeSizes.add(splitAndParseNumbers(matcher.group(3))); mPageTypeLabels.add(matcher.group(3)); mPageTypeSizes.add(splitAndParseNumbers(matcher.group(4))); } } } } } catch (IOException ex) { } catch (IOException ex) { mPageTypeNodes.clear(); mPageTypeZones.clear(); mPageTypeZones.clear(); mPageTypeLabels.clear(); mPageTypeLabels.clear(); mPageTypeSizes.clear(); mPageTypeSizes.clear(); Loading Loading @@ -935,7 +940,8 @@ public final class ProcessStats implements Parcelable { final int NPAGETYPES = mPageTypeLabels.size(); final int NPAGETYPES = mPageTypeLabels.size(); out.writeInt(NPAGETYPES); out.writeInt(NPAGETYPES); for (int i=0; i<NPAGETYPES; i++) { for (int i=0; i<NPAGETYPES; i++) { out.writeInt(mPageTypeZones.get(i)); out.writeInt(mPageTypeNodes.get(i)); out.writeString(mPageTypeZones.get(i)); out.writeString(mPageTypeLabels.get(i)); out.writeString(mPageTypeLabels.get(i)); out.writeIntArray(mPageTypeSizes.get(i)); out.writeIntArray(mPageTypeSizes.get(i)); } } Loading Loading @@ -1244,6 +1250,8 @@ public final class ProcessStats implements Parcelable { // Fragmentation info // Fragmentation info final int NPAGETYPES = in.readInt(); final int NPAGETYPES = in.readInt(); mPageTypeNodes.clear(); mPageTypeNodes.ensureCapacity(NPAGETYPES); mPageTypeZones.clear(); mPageTypeZones.clear(); mPageTypeZones.ensureCapacity(NPAGETYPES); mPageTypeZones.ensureCapacity(NPAGETYPES); mPageTypeLabels.clear(); mPageTypeLabels.clear(); Loading @@ -1251,7 +1259,8 @@ public final class ProcessStats implements Parcelable { mPageTypeSizes.clear(); mPageTypeSizes.clear(); mPageTypeSizes.ensureCapacity(NPAGETYPES); mPageTypeSizes.ensureCapacity(NPAGETYPES); for (int i=0; i<NPAGETYPES; i++) { for (int i=0; i<NPAGETYPES; i++) { mPageTypeZones.add(in.readInt()); mPageTypeNodes.add(in.readInt()); mPageTypeZones.add(in.readString()); mPageTypeLabels.add(in.readString()); mPageTypeLabels.add(in.readString()); mPageTypeSizes.add(in.createIntArray()); mPageTypeSizes.add(in.createIntArray()); } } Loading Loading @@ -1764,7 +1773,8 @@ public final class ProcessStats implements Parcelable { pw.println("Available pages by page size:"); pw.println("Available pages by page size:"); final int NPAGETYPES = mPageTypeLabels.size(); final int NPAGETYPES = mPageTypeLabels.size(); for (int i=0; i<NPAGETYPES; i++) { for (int i=0; i<NPAGETYPES; i++) { pw.format("Zone %3d %14s ", mPageTypeZones.get(i), mPageTypeLabels.get(i)); pw.format("Node %3d Zone %7s %14s ", mPageTypeNodes.get(i), mPageTypeZones.get(i), mPageTypeLabels.get(i)); final int[] sizes = mPageTypeSizes.get(i); final int[] sizes = mPageTypeSizes.get(i); final int N = sizes == null ? 0 : sizes.length; final int N = sizes == null ? 0 : sizes.length; for (int j=0; j<N; j++) { for (int j=0; j<N; j++) { Loading Loading @@ -2095,6 +2105,9 @@ public final class ProcessStats implements Parcelable { pw.print(","); pw.print(","); pw.print(mPageTypeZones.get(i)); pw.print(mPageTypeZones.get(i)); pw.print(","); pw.print(","); // Wasn't included in original output. //pw.print(mPageTypeNodes.get(i)); //pw.print(","); final int[] sizes = mPageTypeSizes.get(i); final int[] sizes = mPageTypeSizes.get(i); final int N = sizes == null ? 0 : sizes.length; final int N = sizes == null ? 0 : sizes.length; for (int j=0; j<N; j++) { for (int j=0; j<N; j++) { Loading Loading @@ -2135,6 +2148,20 @@ public final class ProcessStats implements Parcelable { proto.write(ProcessStatsSectionProto.STATUS, ProcessStatsSectionProto.STATUS_PARTIAL); proto.write(ProcessStatsSectionProto.STATUS, ProcessStatsSectionProto.STATUS_PARTIAL); } } final int NPAGETYPES = mPageTypeLabels.size(); for (int i = 0; i < NPAGETYPES; i++) { final long token = proto.start(ProcessStatsSectionProto.AVAILABLE_PAGES); proto.write(ProcessStatsAvailablePagesProto.NODE, mPageTypeNodes.get(i)); proto.write(ProcessStatsAvailablePagesProto.ZONE, mPageTypeZones.get(i)); proto.write(ProcessStatsAvailablePagesProto.LABEL, mPageTypeLabels.get(i)); final int[] sizes = mPageTypeSizes.get(i); final int N = sizes == null ? 0 : sizes.length; for (int j = 0; j < N; j++) { proto.write(ProcessStatsAvailablePagesProto.PAGES_PER_ORDER, sizes[j]); } proto.end(token); } final ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); final ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); if ((section & REPORT_PROC_STATS) != 0) { if ((section & REPORT_PROC_STATS) != 0) { for (int ip = 0; ip < procMap.size(); ip++) { for (int ip = 0; ip < procMap.size(); ip++) { Loading
core/proto/android/service/procstats.proto +22 −1 Original line number Original line Diff line number Diff line Loading @@ -43,7 +43,7 @@ message ProcessStatsServiceDumpProto { * Data model from /frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java * Data model from /frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java * This proto is defined based on the writeToParcel method. * This proto is defined based on the writeToParcel method. * * * Next Tag: 10 * Next Tag: 11 */ */ message ProcessStatsSectionProto { message ProcessStatsSectionProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; option (android.msg_privacy).dest = DEST_AUTOMATIC; Loading Loading @@ -76,6 +76,9 @@ message ProcessStatsSectionProto { } } repeated Status status = 7; repeated Status status = 7; // Number of pages available of various types and sizes, representation fragmentation. repeated ProcessStatsAvailablePagesProto available_pages = 10; // Stats for each process. // Stats for each process. repeated ProcessStatsProto process_stats = 8; repeated ProcessStatsProto process_stats = 8; Loading @@ -83,6 +86,24 @@ message ProcessStatsSectionProto { repeated ProcessStatsPackageProto package_stats = 9; repeated ProcessStatsPackageProto package_stats = 9; } } // Next Tag: 5 message ProcessStatsAvailablePagesProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; // Node these pages are in (as per /proc/pagetypeinfo) optional int32 node = 1; // Zone these pages are in (as per /proc/pagetypeinfo) optional string zone = 2; // Label for the type of these pages (as per /proc/pagetypeinfo) optional string label = 3; // Distribution of number of pages available by order size. First entry in array is // order 0, second is order 1, etc. Each order increase is a doubling of page size. repeated int32 pages_per_order = 4; } // Next Tag: 10 // Next Tag: 10 message ProcessStatsStateProto { message ProcessStatsStateProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; option (android.msg_privacy).dest = DEST_AUTOMATIC; Loading