OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/process_metrics.h" | 5 #include "base/process/process_metrics.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 const size_t kDiskWriteTime = 10; | 528 const size_t kDiskWriteTime = 10; |
529 const size_t kDiskIO = 11; | 529 const size_t kDiskIO = 11; |
530 const size_t kDiskIOTime = 12; | 530 const size_t kDiskIOTime = 12; |
531 const size_t kDiskWeightedIOTime = 13; | 531 const size_t kDiskWeightedIOTime = 13; |
532 | 532 |
533 } // namespace | 533 } // namespace |
534 | 534 |
535 SystemMemoryInfoKB::SystemMemoryInfoKB() { | 535 SystemMemoryInfoKB::SystemMemoryInfoKB() { |
536 total = 0; | 536 total = 0; |
537 free = 0; | 537 free = 0; |
538 #if defined(OS_LINUX) | |
539 available = 0; | 538 available = 0; |
540 #endif | |
541 buffers = 0; | 539 buffers = 0; |
542 cached = 0; | 540 cached = 0; |
543 active_anon = 0; | 541 active_anon = 0; |
544 inactive_anon = 0; | 542 inactive_anon = 0; |
545 active_file = 0; | 543 active_file = 0; |
546 inactive_file = 0; | 544 inactive_file = 0; |
547 swap_total = 0; | 545 swap_total = 0; |
548 swap_free = 0; | 546 swap_free = 0; |
549 dirty = 0; | 547 dirty = 0; |
| 548 reclaimable = 0; |
550 | 549 |
551 pswpin = 0; | 550 pswpin = 0; |
552 pswpout = 0; | 551 pswpout = 0; |
553 pgmajfault = 0; | 552 pgmajfault = 0; |
554 | 553 |
555 #ifdef OS_CHROMEOS | 554 #ifdef OS_CHROMEOS |
556 shmem = 0; | 555 shmem = 0; |
557 slab = 0; | 556 slab = 0; |
558 gem_objects = -1; | 557 gem_objects = -1; |
559 gem_size = -1; | 558 gem_size = -1; |
560 #endif | 559 #endif |
561 } | 560 } |
562 | 561 |
563 SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = | 562 SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = |
564 default; | 563 default; |
565 | 564 |
566 std::unique_ptr<Value> SystemMemoryInfoKB::ToValue() const { | 565 std::unique_ptr<Value> SystemMemoryInfoKB::ToValue() const { |
567 std::unique_ptr<DictionaryValue> res(new DictionaryValue()); | 566 std::unique_ptr<DictionaryValue> res(new DictionaryValue()); |
568 | 567 |
569 res->SetInteger("total", total); | 568 res->SetInteger("total", total); |
570 res->SetInteger("free", free); | 569 res->SetInteger("free", free); |
571 #if defined(OS_LINUX) | |
572 res->SetInteger("available", available); | 570 res->SetInteger("available", available); |
573 #endif | |
574 res->SetInteger("buffers", buffers); | 571 res->SetInteger("buffers", buffers); |
575 res->SetInteger("cached", cached); | 572 res->SetInteger("cached", cached); |
576 res->SetInteger("active_anon", active_anon); | 573 res->SetInteger("active_anon", active_anon); |
577 res->SetInteger("inactive_anon", inactive_anon); | 574 res->SetInteger("inactive_anon", inactive_anon); |
578 res->SetInteger("active_file", active_file); | 575 res->SetInteger("active_file", active_file); |
579 res->SetInteger("inactive_file", inactive_file); | 576 res->SetInteger("inactive_file", inactive_file); |
580 res->SetInteger("swap_total", swap_total); | 577 res->SetInteger("swap_total", swap_total); |
581 res->SetInteger("swap_free", swap_free); | 578 res->SetInteger("swap_free", swap_free); |
582 res->SetInteger("swap_used", swap_total - swap_free); | 579 res->SetInteger("swap_used", swap_total - swap_free); |
583 res->SetInteger("dirty", dirty); | 580 res->SetInteger("dirty", dirty); |
| 581 res->SetInteger("reclaimable", reclaimable); |
584 res->SetInteger("pswpin", pswpin); | 582 res->SetInteger("pswpin", pswpin); |
585 res->SetInteger("pswpout", pswpout); | 583 res->SetInteger("pswpout", pswpout); |
586 res->SetInteger("pgmajfault", pgmajfault); | 584 res->SetInteger("pgmajfault", pgmajfault); |
587 #ifdef OS_CHROMEOS | 585 #ifdef OS_CHROMEOS |
588 res->SetInteger("shmem", shmem); | 586 res->SetInteger("shmem", shmem); |
589 res->SetInteger("slab", slab); | 587 res->SetInteger("slab", slab); |
590 res->SetInteger("gem_objects", gem_objects); | 588 res->SetInteger("gem_objects", gem_objects); |
591 res->SetInteger("gem_size", gem_size); | 589 res->SetInteger("gem_size", gem_size); |
592 #endif | 590 #endif |
593 | 591 |
(...skipping 27 matching lines...) Expand all Loading... |
621 DLOG(WARNING) << "meminfo: tokens: " << tokens.size() | 619 DLOG(WARNING) << "meminfo: tokens: " << tokens.size() |
622 << " malformed line: " << line.as_string(); | 620 << " malformed line: " << line.as_string(); |
623 continue; | 621 continue; |
624 } | 622 } |
625 | 623 |
626 int* target = NULL; | 624 int* target = NULL; |
627 if (tokens[0] == "MemTotal:") | 625 if (tokens[0] == "MemTotal:") |
628 target = &meminfo->total; | 626 target = &meminfo->total; |
629 else if (tokens[0] == "MemFree:") | 627 else if (tokens[0] == "MemFree:") |
630 target = &meminfo->free; | 628 target = &meminfo->free; |
631 #if defined(OS_LINUX) | |
632 else if (tokens[0] == "MemAvailable:") | 629 else if (tokens[0] == "MemAvailable:") |
633 target = &meminfo->available; | 630 target = &meminfo->available; |
634 #endif | |
635 else if (tokens[0] == "Buffers:") | 631 else if (tokens[0] == "Buffers:") |
636 target = &meminfo->buffers; | 632 target = &meminfo->buffers; |
637 else if (tokens[0] == "Cached:") | 633 else if (tokens[0] == "Cached:") |
638 target = &meminfo->cached; | 634 target = &meminfo->cached; |
639 else if (tokens[0] == "Active(anon):") | 635 else if (tokens[0] == "Active(anon):") |
640 target = &meminfo->active_anon; | 636 target = &meminfo->active_anon; |
641 else if (tokens[0] == "Inactive(anon):") | 637 else if (tokens[0] == "Inactive(anon):") |
642 target = &meminfo->inactive_anon; | 638 target = &meminfo->inactive_anon; |
643 else if (tokens[0] == "Active(file):") | 639 else if (tokens[0] == "Active(file):") |
644 target = &meminfo->active_file; | 640 target = &meminfo->active_file; |
645 else if (tokens[0] == "Inactive(file):") | 641 else if (tokens[0] == "Inactive(file):") |
646 target = &meminfo->inactive_file; | 642 target = &meminfo->inactive_file; |
647 else if (tokens[0] == "SwapTotal:") | 643 else if (tokens[0] == "SwapTotal:") |
648 target = &meminfo->swap_total; | 644 target = &meminfo->swap_total; |
649 else if (tokens[0] == "SwapFree:") | 645 else if (tokens[0] == "SwapFree:") |
650 target = &meminfo->swap_free; | 646 target = &meminfo->swap_free; |
651 else if (tokens[0] == "Dirty:") | 647 else if (tokens[0] == "Dirty:") |
652 target = &meminfo->dirty; | 648 target = &meminfo->dirty; |
| 649 else if (tokens[0] == "SReclaimable:") |
| 650 target = &meminfo->reclaimable; |
653 #if defined(OS_CHROMEOS) | 651 #if defined(OS_CHROMEOS) |
654 // Chrome OS has a tweaked kernel that allows us to query Shmem, which is | 652 // Chrome OS has a tweaked kernel that allows us to query Shmem, which is |
655 // usually video memory otherwise invisible to the OS. | 653 // usually video memory otherwise invisible to the OS. |
656 else if (tokens[0] == "Shmem:") | 654 else if (tokens[0] == "Shmem:") |
657 target = &meminfo->shmem; | 655 target = &meminfo->shmem; |
658 else if (tokens[0] == "Slab:") | 656 else if (tokens[0] == "Slab:") |
659 target = &meminfo->slab; | 657 target = &meminfo->slab; |
660 #endif | 658 #endif |
661 if (target) | 659 if (target) |
662 StringToInt(tokens[1], target); | 660 StringToInt(tokens[1], target); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 #if defined(OS_LINUX) | 964 #if defined(OS_LINUX) |
967 int ProcessMetrics::GetIdleWakeupsPerSecond() { | 965 int ProcessMetrics::GetIdleWakeupsPerSecond() { |
968 uint64_t wake_ups; | 966 uint64_t wake_ups; |
969 const char kWakeupStat[] = "se.statistics.nr_wakeups"; | 967 const char kWakeupStat[] = "se.statistics.nr_wakeups"; |
970 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? | 968 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? |
971 CalculateIdleWakeupsPerSecond(wake_ups) : 0; | 969 CalculateIdleWakeupsPerSecond(wake_ups) : 0; |
972 } | 970 } |
973 #endif // defined(OS_LINUX) | 971 #endif // defined(OS_LINUX) |
974 | 972 |
975 } // namespace base | 973 } // namespace base |
OLD | NEW |