OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/process_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <malloc.h> | 8 #include <malloc.h> |
9 #include <sys/time.h> | 9 #include <sys/time.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // usually video memory otherwise invisible to the OS. Unfortunately, the | 670 // usually video memory otherwise invisible to the OS. Unfortunately, the |
671 // meminfo format varies on different hardware so we have to search for the | 671 // meminfo format varies on different hardware so we have to search for the |
672 // string. It always appears after "Cached:". | 672 // string. It always appears after "Cached:". |
673 for (size_t i = kMemCachedIndex+2; i < meminfo_fields.size(); i += 3) { | 673 for (size_t i = kMemCachedIndex+2; i < meminfo_fields.size(); i += 3) { |
674 if (meminfo_fields[i] == "Shmem:") { | 674 if (meminfo_fields[i] == "Shmem:") { |
675 base::StringToInt(meminfo_fields[i+1], &meminfo->shmem); | 675 base::StringToInt(meminfo_fields[i+1], &meminfo->shmem); |
676 break; | 676 break; |
677 } | 677 } |
678 } | 678 } |
679 #endif | 679 #endif |
| 680 |
| 681 // Check for gem data and report if present. |
| 682 FilePath geminfo_file("/sys/kernel/debug/dri/0/i915_gem_objects"); |
| 683 std::string geminfo_data; |
| 684 meminfo->gem_objects = -1; |
| 685 meminfo->gem_size = -1; |
| 686 if (file_util::ReadFileToString(geminfo_file, &geminfo_data)) { |
| 687 int gem_objects = -1; |
| 688 long long gem_size = -1; |
| 689 int num_res = sscanf(geminfo_data.c_str(), |
| 690 "%d objects, %lld bytes", |
| 691 &gem_objects, &gem_size); |
| 692 if (num_res == 2) { |
| 693 meminfo->gem_objects = gem_objects; |
| 694 meminfo->gem_size = gem_size; |
| 695 } |
| 696 } |
| 697 |
680 return true; | 698 return true; |
681 } | 699 } |
682 | 700 |
683 size_t GetSystemCommitCharge() { | 701 size_t GetSystemCommitCharge() { |
684 SystemMemoryInfoKB meminfo; | 702 SystemMemoryInfoKB meminfo; |
685 if (!GetSystemMemoryInfo(&meminfo)) | 703 if (!GetSystemMemoryInfo(&meminfo)) |
686 return 0; | 704 return 0; |
687 return meminfo.total - meminfo.free - meminfo.buffers - meminfo.cached; | 705 return meminfo.total - meminfo.free - meminfo.buffers - meminfo.cached; |
688 } | 706 } |
689 | 707 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 int score_len = static_cast<int>(score_str.length()); | 858 int score_len = static_cast<int>(score_str.length()); |
841 return (score_len == file_util::WriteFile(oom_file, | 859 return (score_len == file_util::WriteFile(oom_file, |
842 score_str.c_str(), | 860 score_str.c_str(), |
843 score_len)); | 861 score_len)); |
844 } | 862 } |
845 | 863 |
846 return false; | 864 return false; |
847 } | 865 } |
848 | 866 |
849 } // namespace base | 867 } // namespace base |
OLD | NEW |