• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Settings


Commit MetaInfo

Revisãoa0fc2b88f8814de735269ccc7deed1d0f5363cf8 (tree)
Hora2015-10-30 11:25:05
AutorDianne Hackborn <hackbod@goog...>
CommiterThe Android Automerger

Mensagem de Log

Fix issue #25371736: Don't include z-ram allocations in Android OS

Just distribute them across all of the running apps, by creating
an additional fake "z-ram" process for each of them.

Change-Id: I9b4efe9c7b907779a0ec76cb8652709619e2e686

Mudança Sumário

Diff

--- a/src/com/android/settings/applications/ProcStatsData.java
+++ b/src/com/android/settings/applications/ProcStatsData.java
@@ -157,6 +157,9 @@ public class ProcStatsData {
157157 ProcessStats.ALL_SCREEN_ADJ, mMemStates, ProcessStats.NON_CACHED_PROC_STATES);
158158
159159 createPkgMap(getProcs(bgTotals, runTotals), bgTotals, runTotals);
160+ if (totalMem.sysMemZRamWeight > 0) {
161+ distributeZRam(totalMem.sysMemZRamWeight);
162+ }
160163
161164 ProcStatsPackageEntry osPkg = createOsEntry(bgTotals, runTotals, totalMem,
162165 mMemInfo.baseCacheRam);
@@ -180,6 +183,41 @@ public class ProcStatsData {
180183 }
181184 }
182185
186+ private void distributeZRam(double zramWeight) {
187+ // Distribute kernel's Z-Ram across processes, based on how much they have been running.
188+ // The idea is that the memory used by the kernel for this is not really the kernel's
189+ // responsibility, but that of whoever got swapped in to it... and we will take how
190+ // much a process runs for as a sign of the proportion of Z-Ram it is responsible for.
191+
192+ long zramMem = (long) (zramWeight / memTotalTime);
193+ long totalTime = 0;
194+ for (int i = pkgEntries.size() - 1; i >= 0; i--) {
195+ ProcStatsPackageEntry entry = pkgEntries.get(i);
196+ for (int j = entry.mEntries.size() - 1; j >= 0; j--) {
197+ ProcStatsEntry proc = entry.mEntries.get(j);
198+ totalTime += proc.mRunDuration;
199+ }
200+ }
201+ for (int i = pkgEntries.size() - 1; i >= 0 && totalTime > 0; i--) {
202+ ProcStatsPackageEntry entry = pkgEntries.get(i);
203+ long pkgRunTime = 0;
204+ for (int j = entry.mEntries.size() - 1; j >= 0; j--) {
205+ ProcStatsEntry proc = entry.mEntries.get(j);
206+ pkgRunTime += proc.mRunDuration;
207+ }
208+ long pkgZRam = (zramMem*pkgRunTime)/totalTime;
209+ if (pkgZRam > 0) {
210+ zramMem -= pkgZRam;
211+ totalTime -= pkgRunTime;
212+ ProcStatsEntry procEntry = new ProcStatsEntry(entry.mPackage, 0,
213+ mContext.getString(R.string.process_stats_os_zram), memTotalTime,
214+ pkgZRam);
215+ procEntry.evaluateTargetPackage(mPm, mStats, null, null, sEntryCompare, mUseUss);
216+ entry.addEntry(procEntry);
217+ }
218+ }
219+ }
220+
183221 private ProcStatsPackageEntry createOsEntry(ProcessDataCollection bgTotals,
184222 ProcessDataCollection runTotals, TotalMemoryUseCollection totalMem, long baseCacheRam) {
185223 // Add in fake entry representing the OS itself.
@@ -199,6 +237,7 @@ public class ProcStatsData {
199237 osEntry.evaluateTargetPackage(mPm, mStats, bgTotals, runTotals, sEntryCompare, mUseUss);
200238 osPkg.addEntry(osEntry);
201239 }
240+ /* Turned off now -- zram is being distributed across running apps.
202241 if (totalMem.sysMemZRamWeight > 0) {
203242 osEntry = new ProcStatsEntry(Utils.OS_PKG, 0,
204243 mContext.getString(R.string.process_stats_os_zram), memTotalTime,
@@ -206,6 +245,7 @@ public class ProcStatsData {
206245 osEntry.evaluateTargetPackage(mPm, mStats, bgTotals, runTotals, sEntryCompare, mUseUss);
207246 osPkg.addEntry(osEntry);
208247 }
248+ */
209249 if (baseCacheRam > 0) {
210250 osEntry = new ProcStatsEntry(Utils.OS_PKG, 0,
211251 mContext.getString(R.string.process_stats_os_cache), memTotalTime,