|
17 | 17 | #include <linux/cpu.h>
|
18 | 18 | #include <linux/cpumask.h>
|
19 | 19 | #include <linux/vmstat.h>
|
| 20 | +#include <linux/proc_fs.h> |
| 21 | +#include <linux/seq_file.h> |
| 22 | +#include <linux/debugfs.h> |
20 | 23 | #include <linux/sched.h>
|
21 | 24 | #include <linux/math64.h>
|
22 | 25 | #include <linux/writeback.h>
|
@@ -670,66 +673,6 @@ int fragmentation_index(struct zone *zone, unsigned int order)
|
670 | 673 | }
|
671 | 674 | #endif
|
672 | 675 |
|
673 |
| -#if defined(CONFIG_PROC_FS) || defined(CONFIG_COMPACTION) |
674 |
| -#include <linux/proc_fs.h> |
675 |
| -#include <linux/seq_file.h> |
676 |
| - |
677 |
| -static char * const migratetype_names[MIGRATE_TYPES] = { |
678 |
| - "Unmovable", |
679 |
| - "Reclaimable", |
680 |
| - "Movable", |
681 |
| - "Reserve", |
682 |
| -#ifdef CONFIG_CMA |
683 |
| - "CMA", |
684 |
| -#endif |
685 |
| -#ifdef CONFIG_MEMORY_ISOLATION |
686 |
| - "Isolate", |
687 |
| -#endif |
688 |
| -}; |
689 |
| - |
690 |
| -static void *frag_start(struct seq_file *m, loff_t *pos) |
691 |
| -{ |
692 |
| - pg_data_t *pgdat; |
693 |
| - loff_t node = *pos; |
694 |
| - for (pgdat = first_online_pgdat(); |
695 |
| - pgdat && node; |
696 |
| - pgdat = next_online_pgdat(pgdat)) |
697 |
| - --node; |
698 |
| - |
699 |
| - return pgdat; |
700 |
| -} |
701 |
| - |
702 |
| -static void *frag_next(struct seq_file *m, void *arg, loff_t *pos) |
703 |
| -{ |
704 |
| - pg_data_t *pgdat = (pg_data_t *)arg; |
705 |
| - |
706 |
| - (*pos)++; |
707 |
| - return next_online_pgdat(pgdat); |
708 |
| -} |
709 |
| - |
710 |
| -static void frag_stop(struct seq_file *m, void *arg) |
711 |
| -{ |
712 |
| -} |
713 |
| - |
714 |
| -/* Walk all the zones in a node and print using a callback */ |
715 |
| -static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat, |
716 |
| - void (*print)(struct seq_file *m, pg_data_t *, struct zone *)) |
717 |
| -{ |
718 |
| - struct zone *zone; |
719 |
| - struct zone *node_zones = pgdat->node_zones; |
720 |
| - unsigned long flags; |
721 |
| - |
722 |
| - for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { |
723 |
| - if (!populated_zone(zone)) |
724 |
| - continue; |
725 |
| - |
726 |
| - spin_lock_irqsave(&zone->lock, flags); |
727 |
| - print(m, pgdat, zone); |
728 |
| - spin_unlock_irqrestore(&zone->lock, flags); |
729 |
| - } |
730 |
| -} |
731 |
| -#endif |
732 |
| - |
733 | 676 | #if defined(CONFIG_PROC_FS) || defined(CONFIG_SYSFS) || defined(CONFIG_NUMA)
|
734 | 677 | #ifdef CONFIG_ZONE_DMA
|
735 | 678 | #define TEXT_FOR_DMA(xx) xx "_dma",
|
@@ -907,7 +850,66 @@ const char * const vmstat_text[] = {
|
907 | 850 | #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
|
908 | 851 |
|
909 | 852 |
|
| 853 | +#if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)) || \ |
| 854 | + defined(CONFIG_PROC_FS) |
| 855 | +static void *frag_start(struct seq_file *m, loff_t *pos) |
| 856 | +{ |
| 857 | + pg_data_t *pgdat; |
| 858 | + loff_t node = *pos; |
| 859 | + |
| 860 | + for (pgdat = first_online_pgdat(); |
| 861 | + pgdat && node; |
| 862 | + pgdat = next_online_pgdat(pgdat)) |
| 863 | + --node; |
| 864 | + |
| 865 | + return pgdat; |
| 866 | +} |
| 867 | + |
| 868 | +static void *frag_next(struct seq_file *m, void *arg, loff_t *pos) |
| 869 | +{ |
| 870 | + pg_data_t *pgdat = (pg_data_t *)arg; |
| 871 | + |
| 872 | + (*pos)++; |
| 873 | + return next_online_pgdat(pgdat); |
| 874 | +} |
| 875 | + |
| 876 | +static void frag_stop(struct seq_file *m, void *arg) |
| 877 | +{ |
| 878 | +} |
| 879 | + |
| 880 | +/* Walk all the zones in a node and print using a callback */ |
| 881 | +static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat, |
| 882 | + void (*print)(struct seq_file *m, pg_data_t *, struct zone *)) |
| 883 | +{ |
| 884 | + struct zone *zone; |
| 885 | + struct zone *node_zones = pgdat->node_zones; |
| 886 | + unsigned long flags; |
| 887 | + |
| 888 | + for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { |
| 889 | + if (!populated_zone(zone)) |
| 890 | + continue; |
| 891 | + |
| 892 | + spin_lock_irqsave(&zone->lock, flags); |
| 893 | + print(m, pgdat, zone); |
| 894 | + spin_unlock_irqrestore(&zone->lock, flags); |
| 895 | + } |
| 896 | +} |
| 897 | +#endif |
| 898 | + |
910 | 899 | #ifdef CONFIG_PROC_FS
|
| 900 | +static char * const migratetype_names[MIGRATE_TYPES] = { |
| 901 | + "Unmovable", |
| 902 | + "Reclaimable", |
| 903 | + "Movable", |
| 904 | + "Reserve", |
| 905 | +#ifdef CONFIG_CMA |
| 906 | + "CMA", |
| 907 | +#endif |
| 908 | +#ifdef CONFIG_MEMORY_ISOLATION |
| 909 | + "Isolate", |
| 910 | +#endif |
| 911 | +}; |
| 912 | + |
911 | 913 | static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
|
912 | 914 | struct zone *zone)
|
913 | 915 | {
|
@@ -1536,8 +1538,6 @@ static int __init setup_vmstat(void)
|
1536 | 1538 | module_init(setup_vmstat)
|
1537 | 1539 |
|
1538 | 1540 | #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)
|
1539 |
| -#include <linux/debugfs.h> |
1540 |
| - |
1541 | 1541 |
|
1542 | 1542 | /*
|
1543 | 1543 | * Return an index indicating how much of the available free memory is
|
|
0 commit comments