]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm/balloon_compaction: add vmstat counters and kpageflags bit
authorKonstantin Khlebnikov <k.khlebnikov@samsung.com>
Thu, 9 Oct 2014 22:29:32 +0000 (15:29 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 10 Oct 2014 02:26:01 +0000 (22:26 -0400)
Always mark pages with PageBalloon even if balloon compaction is disabled
and expose this mark in /proc/kpageflags as KPF_BALLOON.

Also this patch adds three counters into /proc/vmstat: "balloon_inflate",
"balloon_deflate" and "balloon_migrate".  They accumulate balloon
activity.  Current size of balloon is (balloon_inflate - balloon_deflate)
pages.

All generic balloon code now gathered under option CONFIG_MEMORY_BALLOON.
It should be selected by ballooning driver which wants use this feature.
Currently virtio-balloon is the only user.

Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Cc: Rafael Aquini <aquini@redhat.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/virtio/Kconfig
drivers/virtio/virtio_balloon.c
fs/proc/page.c
include/linux/balloon_compaction.h
include/linux/vm_event_item.h
include/uapi/linux/kernel-page-flags.h
mm/Kconfig
mm/Makefile
mm/balloon_compaction.c
mm/vmstat.c
tools/vm/page-types.c

index c6683f2e396c3ef93effefe61d272627a4e4a24a..00b2286382743203027b834c300a62745caa4a3f 100644 (file)
@@ -25,6 +25,7 @@ config VIRTIO_PCI
 config VIRTIO_BALLOON
        tristate "Virtio balloon driver"
        depends on VIRTIO
+       select MEMORY_BALLOON
        ---help---
         This driver supports increasing and decreasing the amount
         of memory within a KVM guest.
index 2bad7f9dd2aca0abbce3277c0fdca25edf49a783..f893148a107bf44d23c953f5df1c0b905b2e3c08 100644 (file)
@@ -396,6 +396,7 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
        spin_lock_irqsave(&vb_dev_info->pages_lock, flags);
        balloon_page_insert(vb_dev_info, newpage);
        vb_dev_info->isolated_pages--;
+       __count_vm_event(BALLOON_MIGRATE);
        spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags);
        vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
        set_page_pfns(vb->pfns, newpage);
index e647c55275d9ff9f96b92ac859e65c10fc03d318..1e3187da1fedbb76fedd9252a8969c159d7c15a2 100644 (file)
@@ -133,6 +133,9 @@ u64 stable_page_flags(struct page *page)
        if (PageBuddy(page))
                u |= 1 << KPF_BUDDY;
 
+       if (PageBalloon(page))
+               u |= 1 << KPF_BALLOON;
+
        u |= kpf_copy_bit(k, KPF_LOCKED,        PG_locked);
 
        u |= kpf_copy_bit(k, KPF_SLAB,          PG_slab);
index bc3d2985cc9aad6d92272d97413ae799b7ef17a7..9b0a15d06a4fd3447de1d1345560c093b2c4e4a8 100644 (file)
@@ -166,11 +166,13 @@ static inline gfp_t balloon_mapping_gfp_mask(void)
 static inline void balloon_page_insert(struct balloon_dev_info *balloon,
                                       struct page *page)
 {
+       __SetPageBalloon(page);
        list_add(&page->lru, &balloon->pages);
 }
 
 static inline void balloon_page_delete(struct page *page)
 {
+       __ClearPageBalloon(page);
        list_del(&page->lru);
 }
 
index ced92345c96307f559d165c56af092e520be3a06..730334cdf037c8ea14dc83377eb61073bb9678ed 100644 (file)
@@ -72,6 +72,13 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                THP_ZERO_PAGE_ALLOC,
                THP_ZERO_PAGE_ALLOC_FAILED,
 #endif
+#ifdef CONFIG_MEMORY_BALLOON
+               BALLOON_INFLATE,
+               BALLOON_DEFLATE,
+#ifdef CONFIG_BALLOON_COMPACTION
+               BALLOON_MIGRATE,
+#endif
+#endif
 #ifdef CONFIG_DEBUG_TLBFLUSH
 #ifdef CONFIG_SMP
                NR_TLB_REMOTE_FLUSH,    /* cpu tried to flush others' tlbs */
index 5116a0e48172fd27110bdbcda32189473853cb9e..2f96d233c980bdaef504c0d6936f5e381e8cc532 100644 (file)
@@ -31,6 +31,7 @@
 
 #define KPF_KSM                        21
 #define KPF_THP                        22
+#define KPF_BALLOON            23
 
 
 #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */
index 0ceb8a567dab2b53f4fe22acf4dd39ed163da597..1d1ae6b078fdd9121abbd01409f01437bb67e1e8 100644 (file)
@@ -230,12 +230,17 @@ config SPLIT_PTLOCK_CPUS
 config ARCH_ENABLE_SPLIT_PMD_PTLOCK
        boolean
 
+#
+# support for memory balloon
+config MEMORY_BALLOON
+       boolean
+
 #
 # support for memory balloon compaction
 config BALLOON_COMPACTION
        bool "Allow for balloon memory compaction/migration"
        def_bool y
-       depends on COMPACTION && VIRTIO_BALLOON
+       depends on COMPACTION && MEMORY_BALLOON
        help
          Memory fragmentation introduced by ballooning might reduce
          significantly the number of 2MB contiguous memory blocks that can be
index f8ed7ab417b1552986f5a9b7e1bf311678864533..1f534a7f0a711396bab99d6399f2bc40898ae850 100644 (file)
@@ -16,7 +16,7 @@ obj-y                 := filemap.o mempool.o oom_kill.o \
                           readahead.o swap.o truncate.o vmscan.o shmem.o \
                           util.o mmzone.o vmstat.o backing-dev.o \
                           mm_init.o mmu_context.o percpu.o slab_common.o \
-                          compaction.o balloon_compaction.o vmacache.o \
+                          compaction.o vmacache.o \
                           interval_tree.o list_lru.o workingset.o \
                           iov_iter.o debug.o $(mmu-y)
 
@@ -67,3 +67,4 @@ obj-$(CONFIG_ZBUD)    += zbud.o
 obj-$(CONFIG_ZSMALLOC) += zsmalloc.o
 obj-$(CONFIG_GENERIC_EARLY_IOREMAP) += early_ioremap.o
 obj-$(CONFIG_CMA)      += cma.o
+obj-$(CONFIG_MEMORY_BALLOON) += balloon_compaction.o
index 3afdabdbc0a4668e4c7cbaa5e0cca27a98305059..b3cbe19f71b5fe48ca853b55b8d5c1163bfdea03 100644 (file)
@@ -36,6 +36,7 @@ struct page *balloon_page_enqueue(struct balloon_dev_info *b_dev_info)
        BUG_ON(!trylock_page(page));
        spin_lock_irqsave(&b_dev_info->pages_lock, flags);
        balloon_page_insert(b_dev_info, page);
+       __count_vm_event(BALLOON_INFLATE);
        spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
        unlock_page(page);
        return page;
@@ -74,6 +75,7 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)
                        }
                        spin_lock_irqsave(&b_dev_info->pages_lock, flags);
                        balloon_page_delete(page);
+                       __count_vm_event(BALLOON_DEFLATE);
                        spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
                        unlock_page(page);
                        dequeued_page = true;
index e9ab104b956f127f79598231863bd62b7f559147..cce7c766da7a6f013f0a1f3ab210991f14b51c21 100644 (file)
@@ -735,7 +735,7 @@ static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat,
                                        TEXT_FOR_HIGHMEM(xx) xx "_movable",
 
 const char * const vmstat_text[] = {
-       /* Zoned VM counters */
+       /* enum zone_stat_item countes */
        "nr_free_pages",
        "nr_alloc_batch",
        "nr_inactive_anon",
@@ -778,10 +778,13 @@ const char * const vmstat_text[] = {
        "workingset_nodereclaim",
        "nr_anon_transparent_hugepages",
        "nr_free_cma",
+
+       /* enum writeback_stat_item counters */
        "nr_dirty_threshold",
        "nr_dirty_background_threshold",
 
 #ifdef CONFIG_VM_EVENT_COUNTERS
+       /* enum vm_event_item counters */
        "pgpgin",
        "pgpgout",
        "pswpin",
@@ -860,6 +863,13 @@ const char * const vmstat_text[] = {
        "thp_zero_page_alloc",
        "thp_zero_page_alloc_failed",
 #endif
+#ifdef CONFIG_MEMORY_BALLOON
+       "balloon_inflate",
+       "balloon_deflate",
+#ifdef CONFIG_BALLOON_COMPACTION
+       "balloon_migrate",
+#endif
+#endif /* CONFIG_MEMORY_BALLOON */
 #ifdef CONFIG_DEBUG_TLBFLUSH
 #ifdef CONFIG_SMP
        "nr_tlb_remote_flush",
index c4d6d2e20e0debb8ea3bb8638fb6fb0a757014f8..264fbc297e0b138262647e2426c059a87ff14cfe 100644 (file)
@@ -132,6 +132,7 @@ static const char * const page_flag_names[] = {
        [KPF_NOPAGE]            = "n:nopage",
        [KPF_KSM]               = "x:ksm",
        [KPF_THP]               = "t:thp",
+       [KPF_BALLOON]           = "o:balloon",
 
        [KPF_RESERVED]          = "r:reserved",
        [KPF_MLOCKED]           = "m:mlocked",