linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <koct9i@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Konstantin Khlebnikov <k.khlebnikov@samsung.com>,
	Rafael Aquini <aquini@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	Sasha Levin <sasha.levin@oracle.com>
Subject: Re: [PATCH v2 4/6] mm: introduce common page state for ballooned memory
Date: Sat, 13 Sep 2014 12:22:23 +0400	[thread overview]
Message-ID: <CALYGNiNg5yLbAvqwG3nPqWZHkqXc1-3p4yqdP2Eo2rNJbRo0rg@mail.gmail.com> (raw)
In-Reply-To: <20140912224221.9ee5888a.akpm@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]

On Sat, Sep 13, 2014 at 9:42 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Sat, 13 Sep 2014 09:26:49 +0400 Konstantin Khlebnikov <koct9i@gmail.com> wrote:
>
>> >
>> > Did we really need to put the BalloonPages count into per-zone vmstat,
>> > global vmstat and /proc/meminfo?  Seems a bit overkillish - why so
>> > important?
>>
>> Balloon grabs random pages, their distribution among numa nodes might
>> be important.
>> But I know nobody who uses numa-aware vm together with ballooning.
>>
>> Probably it's better to drop per-zone vmstat and line from meminfo,
>> global vmstat counter should be enough.
>
> Yes, the less we add the better - we can always add stuff later if
> there is a demonstrated need.

Ok. (I guess incremental patches are more convenient for you)
Here is two fixes which remove redundant per-zone counters and adds
three vmstat counters: "balloon_inflate", "balloon_deflate" and
"balloon_migrate".

This statistic seems more useful than current state snapshot.
Size of balloon is just a difference between "inflate" and "deflate".

>
>> >
>> > Consuming another page flag is a big deal.  We keep on nearly running
>> > out and one day we'll run out for real.  page-flags-layout.h is
>> > incomprehensible.  How many flags do we have left (worst-case) with this
>> > change?  Is there no other way?  Needs extraordinary justification,
>> > please.
>>
>> PageBalloon is not a page flags, it's like PageBuddy -- special state
>> of _mapcount (-256 in this case).
>> The same was in v1 and is written in the comment above.
>
> oop sorry, I got confused about KPF_BALLOON.

[-- Attachment #2: mm-balloon_compaction-use-common-page-ballooning-use-vmstat-counters --]
[-- Type: application/octet-stream, Size: 2701 bytes --]

mm-balloon_compaction-use-common-page-ballooning-use-vmstat-counters

From: Konstantin Khlebnikov <koct9i@gmail.com>

fix for mm-balloon_compaction-use-common-page-ballooning-v2

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
---
 drivers/virtio/virtio_balloon.c    |    1 +
 include/linux/balloon_compaction.h |    2 --
 mm/balloon_compaction.c            |    2 ++
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index c84d6a8..6b3444b 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -395,6 +395,7 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
 	/* balloon's page migration 1st step  -- inflate "newpage" */
 	spin_lock_irqsave(&vb_dev_info->pages_lock, flags);
 	balloon_page_insert(vb_dev_info, newpage);
+	__count_vm_event(BALLOON_MIGRATE);
 	vb_dev_info->isolated_pages--;
 	spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags);
 	vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h
index ad112fcc6..d69f2ae 100644
--- a/include/linux/balloon_compaction.h
+++ b/include/linux/balloon_compaction.h
@@ -87,7 +87,6 @@ static inline void
 balloon_page_insert(struct balloon_dev_info *b_dev_info, struct page *page)
 {
 	__SetPageBalloon(page);
-	inc_zone_page_state(page, NR_BALLOON_PAGES);
 	set_page_private(page, (unsigned long)b_dev_info);
 	list_add(&page->lru, &b_dev_info->pages);
 }
@@ -104,7 +103,6 @@ balloon_page_insert(struct balloon_dev_info *b_dev_info, struct page *page)
 static inline void balloon_page_delete(struct page *page, bool isolated)
 {
 	__ClearPageBalloon(page);
-	dec_zone_page_state(page, NR_BALLOON_PAGES);
 	set_page_private(page, 0);
 	if (!isolated)
 		list_del(&page->lru);
diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index 3c8cb7a..c536350 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -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;
@@ -67,6 +68,7 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)
 		if (trylock_page(page)) {
 			spin_lock_irqsave(&b_dev_info->pages_lock, flags);
 			balloon_page_delete(page, false);
+			__count_vm_event(BALLOON_DEFLATE);
 			spin_unlock_irqrestore(&b_dev_info->pages_lock, flags);
 			unlock_page(page);
 			return page;

[-- Attachment #3: mm-introduce-common-page-state-for-ballooned-memory-vmstat-counters --]
[-- Type: application/octet-stream, Size: 5083 bytes --]

mm-introduce-common-page-state-for-ballooned-memory-vmstat-counters

From: Konstantin Khlebnikov <koct9i@gmail.com>

fix for mm-introduce-common-page-state-for-ballooned-memory-fix-v2

This reverts per-zone balloon counters and removes them from meminfo, zoneinfo.
Instead of that this patch adds three /proc/vmstat counters:
"balloon_inflate", "balloon_deflate" and "balloon_migrate".
Current size of balloon is (balloon_inflate - balloon_deflate) pages.

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
---
 Documentation/filesystems/proc.txt |    2 --
 drivers/base/node.c                |    6 ------
 fs/proc/meminfo.c                  |    6 ------
 include/linux/mmzone.h             |    3 ---
 include/linux/vm_event_item.h      |    7 +++++++
 mm/vmstat.c                        |   10 +++++++---
 6 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 154a345..eb8a10e 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -796,7 +796,6 @@ VmallocTotal:   112216 kB
 VmallocUsed:       428 kB
 VmallocChunk:   111088 kB
 AnonHugePages:   49152 kB
-BalloonPages:        0 kB
 
     MemTotal: Total usable ram (i.e. physical ram minus a few reserved
               bits and the kernel binary code)
@@ -839,7 +838,6 @@ MemAvailable: An estimate of how much memory is available for starting new
    Writeback: Memory which is actively being written back to the disk
    AnonPages: Non-file backed pages mapped into userspace page tables
 AnonHugePages: Non-file backed huge pages mapped into userspace page tables
-BalloonPages: Memory which was ballooned, not included into MemTotal
       Mapped: files which have been mmaped, such as libraries
         Slab: in-kernel data structures cache
 SReclaimable: Part of Slab, that might be reclaimed, such as caches
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 1f8d8b1..f0cdb02 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -120,9 +120,6 @@ static ssize_t node_read_meminfo(struct device *dev,
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 		       "Node %d AnonHugePages:  %8lu kB\n"
 #endif
-#ifdef CONFIG_MEMORY_BALLOON
-		       "Node %d BalloonPages:   %8lu kB\n"
-#endif
 			,
 		       nid, K(node_page_state(nid, NR_FILE_DIRTY)),
 		       nid, K(node_page_state(nid, NR_WRITEBACK)),
@@ -144,9 +141,6 @@ static ssize_t node_read_meminfo(struct device *dev,
 		       ,nid, K(node_page_state(nid,
 				NR_ANON_TRANSPARENT_HUGEPAGES) * HPAGE_PMD_NR)
 #endif
-#ifdef CONFIG_MEMORY_BALLOON
-		       ,nid, K(node_page_state(nid, NR_BALLOON_PAGES))
-#endif
 		       );
 	n += hugetlb_report_node_meminfo(nid, buf + n);
 	return n;
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index f897fbf..aa1eee0 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -138,9 +138,6 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 		"AnonHugePages:  %8lu kB\n"
 #endif
-#ifdef CONFIG_MEMORY_BALLOON
-		"BalloonPages:   %8lu kB\n"
-#endif
 		,
 		K(i.totalram),
 		K(i.freeram),
@@ -196,9 +193,6 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 		,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
 		   HPAGE_PMD_NR)
 #endif
-#ifdef CONFIG_MEMORY_BALLOON
-		,K(global_page_state(NR_BALLOON_PAGES))
-#endif
 		);
 
 	hugetlb_report_meminfo(m);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index fbbff5c..48bf12e 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -157,9 +157,6 @@ enum zone_stat_item {
 	WORKINGSET_NODERECLAIM,
 	NR_ANON_TRANSPARENT_HUGEPAGES,
 	NR_FREE_CMA_PAGES,
-#ifdef CONFIG_MEMORY_BALLOON
-	NR_BALLOON_PAGES,
-#endif
 	NR_VM_ZONE_STAT_ITEMS };
 
 /*
diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index ced9234..730334c 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -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 */
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 87273cd..5da8834 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -794,9 +794,6 @@ const char * const vmstat_text[] = {
 	"workingset_nodereclaim",
 	"nr_anon_transparent_hugepages",
 	"nr_free_cma",
-#ifdef CONFIG_MEMORY_BALLOON
-	"nr_balloon_pages",
-#endif
 
 	/* enum writeback_stat_item counters */
 	"nr_dirty_threshold",
@@ -882,6 +879,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",

  reply	other threads:[~2014-09-13  8:22 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-30 16:41 [PATCH v2 0/6] mm/balloon_compaction: fixes and cleanups Konstantin Khlebnikov
2014-08-30 16:41 ` [PATCH v2 1/6] mm/balloon_compaction: ignore anonymous pages Konstantin Khlebnikov
2014-09-02 12:29   ` Rafael Aquini
2014-08-30 16:41 ` [PATCH v2 2/6] mm/balloon_compaction: keep ballooned pages away from normal migration path Konstantin Khlebnikov
2014-09-02 12:31   ` Rafael Aquini
2014-08-30 16:41 ` [PATCH v2 3/6] mm/balloon_compaction: isolate balloon pages without lru_lock Konstantin Khlebnikov
2014-09-02 12:32   ` Rafael Aquini
2014-08-30 16:41 ` [PATCH v2 4/6] mm: introduce common page state for ballooned memory Konstantin Khlebnikov
2014-09-02 12:53   ` Rafael Aquini
2014-09-12 23:51   ` Andrew Morton
2014-09-13  5:26     ` Konstantin Khlebnikov
2014-09-13  5:42       ` Andrew Morton
2014-09-13  8:22         ` Konstantin Khlebnikov [this message]
2014-09-19 21:35           ` Andrew Morton
2014-09-20  5:25             ` Konstantin Khlebnikov
2014-09-20  6:23               ` Andrew Morton
2014-09-22 18:40                 ` Konstantin Khlebnikov
2014-09-22 19:22                   ` Rafael Aquini
2014-09-22 20:06                     ` Konstantin Khlebnikov
2014-09-22 20:22                       ` Rafael Aquini
2014-09-22 20:46                         ` Konstantin Khlebnikov
2014-09-13 14:03       ` Sasha Levin
2014-08-30 16:41 ` [PATCH v2 5/6] mm/balloon_compaction: use common page ballooning Konstantin Khlebnikov
2014-09-02 12:57   ` Rafael Aquini
2014-09-12 23:57   ` Andrew Morton
2014-08-30 16:41 ` [PATCH v2 6/6] mm/balloon_compaction: general cleanup Konstantin Khlebnikov
2014-09-02 13:09   ` Rafael Aquini
2014-09-13  0:04   ` Andrew Morton
2014-09-13  0:06     ` Andrew Morton
2014-09-13  5:43       ` Konstantin Khlebnikov
2014-09-13  0:09 ` [PATCH v2 0/6] mm/balloon_compaction: fixes and cleanups Andrew Morton
2014-09-13  5:01   ` Konstantin Khlebnikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALYGNiNg5yLbAvqwG3nPqWZHkqXc1-3p4yqdP2Eo2rNJbRo0rg@mail.gmail.com \
    --to=koct9i@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aquini@redhat.com \
    --cc=k.khlebnikov@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryabinin.a.a@gmail.com \
    --cc=sasha.levin@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox