diff options
Diffstat (limited to 'mm/vmstat.c')
-rw-r--r-- | mm/vmstat.c | 305 |
1 files changed, 206 insertions, 99 deletions
diff --git a/mm/vmstat.c b/mm/vmstat.c index c64d169537bf..3b5e9043e7db 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -353,23 +353,6 @@ void refresh_cpu_vm_stats(int cpu) | |||
353 | } | 353 | } |
354 | } | 354 | } |
355 | 355 | ||
356 | static void __refresh_cpu_vm_stats(void *dummy) | ||
357 | { | ||
358 | refresh_cpu_vm_stats(smp_processor_id()); | ||
359 | } | ||
360 | |||
361 | /* | ||
362 | * Consolidate all counters. | ||
363 | * | ||
364 | * Note that the result is less inaccurate but still inaccurate | ||
365 | * if concurrent processes are allowed to run. | ||
366 | */ | ||
367 | void refresh_vm_stats(void) | ||
368 | { | ||
369 | on_each_cpu(__refresh_cpu_vm_stats, NULL, 0, 1); | ||
370 | } | ||
371 | EXPORT_SYMBOL(refresh_vm_stats); | ||
372 | |||
373 | #endif | 356 | #endif |
374 | 357 | ||
375 | #ifdef CONFIG_NUMA | 358 | #ifdef CONFIG_NUMA |
@@ -398,6 +381,13 @@ void zone_statistics(struct zonelist *zonelist, struct zone *z) | |||
398 | 381 | ||
399 | #include <linux/seq_file.h> | 382 | #include <linux/seq_file.h> |
400 | 383 | ||
384 | static char * const migratetype_names[MIGRATE_TYPES] = { | ||
385 | "Unmovable", | ||
386 | "Reclaimable", | ||
387 | "Movable", | ||
388 | "Reserve", | ||
389 | }; | ||
390 | |||
401 | static void *frag_start(struct seq_file *m, loff_t *pos) | 391 | static void *frag_start(struct seq_file *m, loff_t *pos) |
402 | { | 392 | { |
403 | pg_data_t *pgdat; | 393 | pg_data_t *pgdat; |
@@ -422,28 +412,144 @@ static void frag_stop(struct seq_file *m, void *arg) | |||
422 | { | 412 | { |
423 | } | 413 | } |
424 | 414 | ||
425 | /* | 415 | /* Walk all the zones in a node and print using a callback */ |
426 | * This walks the free areas for each zone. | 416 | static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat, |
427 | */ | 417 | void (*print)(struct seq_file *m, pg_data_t *, struct zone *)) |
428 | static int frag_show(struct seq_file *m, void *arg) | ||
429 | { | 418 | { |
430 | pg_data_t *pgdat = (pg_data_t *)arg; | ||
431 | struct zone *zone; | 419 | struct zone *zone; |
432 | struct zone *node_zones = pgdat->node_zones; | 420 | struct zone *node_zones = pgdat->node_zones; |
433 | unsigned long flags; | 421 | unsigned long flags; |
434 | int order; | ||
435 | 422 | ||
436 | for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { | 423 | for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { |
437 | if (!populated_zone(zone)) | 424 | if (!populated_zone(zone)) |
438 | continue; | 425 | continue; |
439 | 426 | ||
440 | spin_lock_irqsave(&zone->lock, flags); | 427 | spin_lock_irqsave(&zone->lock, flags); |
441 | seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); | 428 | print(m, pgdat, zone); |
442 | for (order = 0; order < MAX_ORDER; ++order) | ||
443 | seq_printf(m, "%6lu ", zone->free_area[order].nr_free); | ||
444 | spin_unlock_irqrestore(&zone->lock, flags); | 429 | spin_unlock_irqrestore(&zone->lock, flags); |
430 | } | ||
431 | } | ||
432 | |||
433 | static void frag_show_print(struct seq_file *m, pg_data_t *pgdat, | ||
434 | struct zone *zone) | ||
435 | { | ||
436 | int order; | ||
437 | |||
438 | seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); | ||
439 | for (order = 0; order < MAX_ORDER; ++order) | ||
440 | seq_printf(m, "%6lu ", zone->free_area[order].nr_free); | ||
441 | seq_putc(m, '\n'); | ||
442 | } | ||
443 | |||
444 | /* | ||
445 | * This walks the free areas for each zone. | ||
446 | */ | ||
447 | static int frag_show(struct seq_file *m, void *arg) | ||
448 | { | ||
449 | pg_data_t *pgdat = (pg_data_t *)arg; | ||
450 | walk_zones_in_node(m, pgdat, frag_show_print); | ||
451 | return 0; | ||
452 | } | ||
453 | |||
454 | static void pagetypeinfo_showfree_print(struct seq_file *m, | ||
455 | pg_data_t *pgdat, struct zone *zone) | ||
456 | { | ||
457 | int order, mtype; | ||
458 | |||
459 | for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) { | ||
460 | seq_printf(m, "Node %4d, zone %8s, type %12s ", | ||
461 | pgdat->node_id, | ||
462 | zone->name, | ||
463 | migratetype_names[mtype]); | ||
464 | for (order = 0; order < MAX_ORDER; ++order) { | ||
465 | unsigned long freecount = 0; | ||
466 | struct free_area *area; | ||
467 | struct list_head *curr; | ||
468 | |||
469 | area = &(zone->free_area[order]); | ||
470 | |||
471 | list_for_each(curr, &area->free_list[mtype]) | ||
472 | freecount++; | ||
473 | seq_printf(m, "%6lu ", freecount); | ||
474 | } | ||
445 | seq_putc(m, '\n'); | 475 | seq_putc(m, '\n'); |
446 | } | 476 | } |
477 | } | ||
478 | |||
479 | /* Print out the free pages at each order for each migatetype */ | ||
480 | static int pagetypeinfo_showfree(struct seq_file *m, void *arg) | ||
481 | { | ||
482 | int order; | ||
483 | pg_data_t *pgdat = (pg_data_t *)arg; | ||
484 | |||
485 | /* Print header */ | ||
486 | seq_printf(m, "%-43s ", "Free pages count per migrate type at order"); | ||
487 | for (order = 0; order < MAX_ORDER; ++order) | ||
488 | seq_printf(m, "%6d ", order); | ||
489 | seq_putc(m, '\n'); | ||
490 | |||
491 | walk_zones_in_node(m, pgdat, pagetypeinfo_showfree_print); | ||
492 | |||
493 | return 0; | ||
494 | } | ||
495 | |||
496 | static void pagetypeinfo_showblockcount_print(struct seq_file *m, | ||
497 | pg_data_t *pgdat, struct zone *zone) | ||
498 | { | ||
499 | int mtype; | ||
500 | unsigned long pfn; | ||
501 | unsigned long start_pfn = zone->zone_start_pfn; | ||
502 | unsigned long end_pfn = start_pfn + zone->spanned_pages; | ||
503 | unsigned long count[MIGRATE_TYPES] = { 0, }; | ||
504 | |||
505 | for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) { | ||
506 | struct page *page; | ||
507 | |||
508 | if (!pfn_valid(pfn)) | ||
509 | continue; | ||
510 | |||
511 | page = pfn_to_page(pfn); | ||
512 | mtype = get_pageblock_migratetype(page); | ||
513 | |||
514 | count[mtype]++; | ||
515 | } | ||
516 | |||
517 | /* Print counts */ | ||
518 | seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); | ||
519 | for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) | ||
520 | seq_printf(m, "%12lu ", count[mtype]); | ||
521 | seq_putc(m, '\n'); | ||
522 | } | ||
523 | |||
524 | /* Print out the free pages at each order for each migratetype */ | ||
525 | static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg) | ||
526 | { | ||
527 | int mtype; | ||
528 | pg_data_t *pgdat = (pg_data_t *)arg; | ||
529 | |||
530 | seq_printf(m, "\n%-23s", "Number of blocks type "); | ||
531 | for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) | ||
532 | seq_printf(m, "%12s ", migratetype_names[mtype]); | ||
533 | seq_putc(m, '\n'); | ||
534 | walk_zones_in_node(m, pgdat, pagetypeinfo_showblockcount_print); | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
539 | /* | ||
540 | * This prints out statistics in relation to grouping pages by mobility. | ||
541 | * It is expensive to collect so do not constantly read the file. | ||
542 | */ | ||
543 | static int pagetypeinfo_show(struct seq_file *m, void *arg) | ||
544 | { | ||
545 | pg_data_t *pgdat = (pg_data_t *)arg; | ||
546 | |||
547 | seq_printf(m, "Page block order: %d\n", pageblock_order); | ||
548 | seq_printf(m, "Pages per block: %lu\n", pageblock_nr_pages); | ||
549 | seq_putc(m, '\n'); | ||
550 | pagetypeinfo_showfree(m, pgdat); | ||
551 | pagetypeinfo_showblockcount(m, pgdat); | ||
552 | |||
447 | return 0; | 553 | return 0; |
448 | } | 554 | } |
449 | 555 | ||
@@ -454,6 +560,13 @@ const struct seq_operations fragmentation_op = { | |||
454 | .show = frag_show, | 560 | .show = frag_show, |
455 | }; | 561 | }; |
456 | 562 | ||
563 | const struct seq_operations pagetypeinfo_op = { | ||
564 | .start = frag_start, | ||
565 | .next = frag_next, | ||
566 | .stop = frag_stop, | ||
567 | .show = pagetypeinfo_show, | ||
568 | }; | ||
569 | |||
457 | #ifdef CONFIG_ZONE_DMA | 570 | #ifdef CONFIG_ZONE_DMA |
458 | #define TEXT_FOR_DMA(xx) xx "_dma", | 571 | #define TEXT_FOR_DMA(xx) xx "_dma", |
459 | #else | 572 | #else |
@@ -532,84 +645,78 @@ static const char * const vmstat_text[] = { | |||
532 | #endif | 645 | #endif |
533 | }; | 646 | }; |
534 | 647 | ||
535 | /* | 648 | static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, |
536 | * Output information about zones in @pgdat. | 649 | struct zone *zone) |
537 | */ | ||
538 | static int zoneinfo_show(struct seq_file *m, void *arg) | ||
539 | { | 650 | { |
540 | pg_data_t *pgdat = arg; | 651 | int i; |
541 | struct zone *zone; | 652 | seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name); |
542 | struct zone *node_zones = pgdat->node_zones; | 653 | seq_printf(m, |
543 | unsigned long flags; | 654 | "\n pages free %lu" |
544 | 655 | "\n min %lu" | |
545 | for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; zone++) { | 656 | "\n low %lu" |
546 | int i; | 657 | "\n high %lu" |
547 | 658 | "\n scanned %lu (a: %lu i: %lu)" | |
548 | if (!populated_zone(zone)) | 659 | "\n spanned %lu" |
549 | continue; | 660 | "\n present %lu", |
550 | 661 | zone_page_state(zone, NR_FREE_PAGES), | |
551 | spin_lock_irqsave(&zone->lock, flags); | 662 | zone->pages_min, |
552 | seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name); | 663 | zone->pages_low, |
553 | seq_printf(m, | 664 | zone->pages_high, |
554 | "\n pages free %lu" | 665 | zone->pages_scanned, |
555 | "\n min %lu" | 666 | zone->nr_scan_active, zone->nr_scan_inactive, |
556 | "\n low %lu" | 667 | zone->spanned_pages, |
557 | "\n high %lu" | 668 | zone->present_pages); |
558 | "\n scanned %lu (a: %lu i: %lu)" | ||
559 | "\n spanned %lu" | ||
560 | "\n present %lu", | ||
561 | zone_page_state(zone, NR_FREE_PAGES), | ||
562 | zone->pages_min, | ||
563 | zone->pages_low, | ||
564 | zone->pages_high, | ||
565 | zone->pages_scanned, | ||
566 | zone->nr_scan_active, zone->nr_scan_inactive, | ||
567 | zone->spanned_pages, | ||
568 | zone->present_pages); | ||
569 | 669 | ||
570 | for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) | 670 | for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) |
571 | seq_printf(m, "\n %-12s %lu", vmstat_text[i], | 671 | seq_printf(m, "\n %-12s %lu", vmstat_text[i], |
572 | zone_page_state(zone, i)); | 672 | zone_page_state(zone, i)); |
573 | 673 | ||
574 | seq_printf(m, | 674 | seq_printf(m, |
575 | "\n protection: (%lu", | 675 | "\n protection: (%lu", |
576 | zone->lowmem_reserve[0]); | 676 | zone->lowmem_reserve[0]); |
577 | for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++) | 677 | for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++) |
578 | seq_printf(m, ", %lu", zone->lowmem_reserve[i]); | 678 | seq_printf(m, ", %lu", zone->lowmem_reserve[i]); |
579 | seq_printf(m, | 679 | seq_printf(m, |
580 | ")" | 680 | ")" |
581 | "\n pagesets"); | 681 | "\n pagesets"); |
582 | for_each_online_cpu(i) { | 682 | for_each_online_cpu(i) { |
583 | struct per_cpu_pageset *pageset; | 683 | struct per_cpu_pageset *pageset; |
584 | int j; | 684 | int j; |
585 | 685 | ||
586 | pageset = zone_pcp(zone, i); | 686 | pageset = zone_pcp(zone, i); |
587 | for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) { | 687 | for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) { |
588 | seq_printf(m, | 688 | seq_printf(m, |
589 | "\n cpu: %i pcp: %i" | 689 | "\n cpu: %i pcp: %i" |
590 | "\n count: %i" | 690 | "\n count: %i" |
591 | "\n high: %i" | 691 | "\n high: %i" |
592 | "\n batch: %i", | 692 | "\n batch: %i", |
593 | i, j, | 693 | i, j, |
594 | pageset->pcp[j].count, | 694 | pageset->pcp[j].count, |
595 | pageset->pcp[j].high, | 695 | pageset->pcp[j].high, |
596 | pageset->pcp[j].batch); | 696 | pageset->pcp[j].batch); |
597 | } | 697 | } |
598 | #ifdef CONFIG_SMP | 698 | #ifdef CONFIG_SMP |
599 | seq_printf(m, "\n vm stats threshold: %d", | 699 | seq_printf(m, "\n vm stats threshold: %d", |
600 | pageset->stat_threshold); | 700 | pageset->stat_threshold); |
601 | #endif | 701 | #endif |
602 | } | ||
603 | seq_printf(m, | ||
604 | "\n all_unreclaimable: %u" | ||
605 | "\n prev_priority: %i" | ||
606 | "\n start_pfn: %lu", | ||
607 | zone->all_unreclaimable, | ||
608 | zone->prev_priority, | ||
609 | zone->zone_start_pfn); | ||
610 | spin_unlock_irqrestore(&zone->lock, flags); | ||
611 | seq_putc(m, '\n'); | ||
612 | } | 702 | } |
703 | seq_printf(m, | ||
704 | "\n all_unreclaimable: %u" | ||
705 | "\n prev_priority: %i" | ||
706 | "\n start_pfn: %lu", | ||
707 | zone->all_unreclaimable, | ||
708 | zone->prev_priority, | ||
709 | zone->zone_start_pfn); | ||
710 | seq_putc(m, '\n'); | ||
711 | } | ||
712 | |||
713 | /* | ||
714 | * Output information about zones in @pgdat. | ||
715 | */ | ||
716 | static int zoneinfo_show(struct seq_file *m, void *arg) | ||
717 | { | ||
718 | pg_data_t *pgdat = (pg_data_t *)arg; | ||
719 | walk_zones_in_node(m, pgdat, zoneinfo_show_print); | ||
613 | return 0; | 720 | return 0; |
614 | } | 721 | } |
615 | 722 | ||
@@ -741,7 +848,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb, | |||
741 | static struct notifier_block __cpuinitdata vmstat_notifier = | 848 | static struct notifier_block __cpuinitdata vmstat_notifier = |
742 | { &vmstat_cpuup_callback, NULL, 0 }; | 849 | { &vmstat_cpuup_callback, NULL, 0 }; |
743 | 850 | ||
744 | int __init setup_vmstat(void) | 851 | static int __init setup_vmstat(void) |
745 | { | 852 | { |
746 | int cpu; | 853 | int cpu; |
747 | 854 | ||