virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v9 0/5] make balloon pages movable by compaction
@ 2012-08-25  5:24 Rafael Aquini
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael Aquini @ 2012-08-25  5:24 UTC (permalink / raw)
  To: linux-mm
  Cc: Rik van Riel, Rafael Aquini, Konrad Rzeszutek Wilk,
	Michael S. Tsirkin, linux-kernel, virtualization, Minchan Kim,
	Peter Zijlstra, Andi Kleen, Andrew Morton, Paul E. McKenney

Memory fragmentation introduced by ballooning might reduce significantly
the number of 2MB contiguous memory blocks that can be used within a guest,
thus imposing performance penalties associated with the reduced number of
transparent huge pages that could be used by the guest workload.

This patch-set follows the main idea discussed at 2012 LSFMMS session:
"Ballooning for transparent huge pages" -- http://lwn.net/Articles/490114/
to introduce the required changes to the virtio_balloon driver, as well as
the changes to the core compaction & migration bits, in order to make those
subsystems aware of ballooned pages and allow memory balloon pages become
movable within a guest, thus avoiding the aforementioned fragmentation issue

Rafael Aquini (5):
  mm: introduce a common interface for balloon pages mobility
  mm: introduce compaction and migration for ballooned pages
  virtio_balloon: introduce migration primitives to balloon pages
  mm: introduce putback_movable_pages()
  mm: add vm event counters for balloon pages compaction

 drivers/virtio/virtio_balloon.c    | 287 ++++++++++++++++++++++++++++++++++---
 include/linux/balloon_compaction.h | 137 ++++++++++++++++++
 include/linux/migrate.h            |   2 +
 include/linux/pagemap.h            |  18 +++
 include/linux/vm_event_item.h      |   8 +-
 mm/Kconfig                         |  15 ++
 mm/Makefile                        |   2 +-
 mm/balloon_compaction.c            | 174 ++++++++++++++++++++++
 mm/compaction.c                    |  51 ++++---
 mm/migrate.c                       |  57 +++++++-
 mm/page_alloc.c                    |   2 +-
 mm/vmstat.c                        |  10 +-
 12 files changed, 715 insertions(+), 48 deletions(-)
 create mode 100644 include/linux/balloon_compaction.h
 create mode 100644 mm/balloon_compaction.c


Change log:
v9:
 * Adjust rcu_dereference usage to leverage page lock protection  (Paul, Peter);
 * Enhance doc on compaction interface introduced to balloon driver   (Michael);
 * Fix issue with isolated pages breaking leak_balloon() logics       (Michael);
v8:
 * introduce a common MM interface for balloon driver page compaction (Michael);
 * remove the global state preventing multiple balloon device support (Michael);
 * introduce RCU protection/syncrhonization to balloon page->mapping  (Michael);
v7:
 * fix a potential page leak case at 'putback_balloon_page'               (Mel);
 * adjust vm-events-counter patch and remove its drop-on-merge message    (Rik);
 * add 'putback_movable_pages' to avoid hacks on 'putback_lru_pages'  (Minchan);
v6:
 * rename 'is_balloon_page()' to 'movable_balloon_page()' 		  (Rik);
v5:
 * address Andrew Morton's review comments on the patch series;
 * address a couple extra nitpick suggestions on PATCH 01 	      (Minchan);
v4: 
 * address Rusty Russel's review comments on PATCH 02;
 * re-base virtio_balloon patch on 9c378abc5c0c6fc8e3acf5968924d274503819b3;
V3: 
 * address reviewers nitpick suggestions on PATCH 01		 (Mel, Minchan);
V2: 
 * address Mel Gorman's review comments on PATCH 01;


Preliminary test results:
(2 VCPU 2048mB RAM KVM guest running 3.6.0_rc3+ -- after a reboot)

* 64mB balloon:
[root@localhost ~]# awk '/compact/ {print}' /proc/vmstat
compact_blocks_moved 0
compact_pages_moved 0
compact_pagemigrate_failed 0
compact_stall 0
compact_fail 0
compact_success 0
compact_balloon_isolated 0
compact_balloon_migrated 0
compact_balloon_released 0
compact_balloon_returned 0
[root@localhost ~]# 
[root@localhost ~]# for i in $(seq 1 6); do echo 1 > /proc/sys/vm/compact_memory & done &>/dev/null 
[1]   Done                    echo 1 > /proc/sys/vm/compact_memory
[2]   Done                    echo 1 > /proc/sys/vm/compact_memory
[3]   Done                    echo 1 > /proc/sys/vm/compact_memory
[4]   Done                    echo 1 > /proc/sys/vm/compact_memory
[5]-  Done                    echo 1 > /proc/sys/vm/compact_memory
[6]+  Done                    echo 1 > /proc/sys/vm/compact_memory
[root@localhost ~]# 
[root@localhost ~]# awk '/compact/ {print}' /proc/vmstat
compact_blocks_moved 3108
compact_pages_moved 43169
compact_pagemigrate_failed 95
compact_stall 0
compact_fail 0
compact_success 0
compact_balloon_isolated 16384
compact_balloon_migrated 16384
compact_balloon_released 16384
compact_balloon_returned 0


* 128 mB balloon:
[root@localhost ~]# awk '/compact/ {print}' /proc/vmstat
compact_blocks_moved 0
compact_pages_moved 0
compact_pagemigrate_failed 0
compact_stall 0
compact_fail 0
compact_success 0
compact_balloon_isolated 0
compact_balloon_migrated 0
compact_balloon_released 0
compact_balloon_returned 0
[root@localhost ~]# 
[root@localhost ~]# for i in $(seq 1 6); do echo 1 > /proc/sys/vm/compact_memory & done &>/dev/null  
[1]   Done                    echo 1 > /proc/sys/vm/compact_memory
[2]   Done                    echo 1 > /proc/sys/vm/compact_memory
[3]   Done                    echo 1 > /proc/sys/vm/compact_memory
[4]   Done                    echo 1 > /proc/sys/vm/compact_memory
[5]-  Done                    echo 1 > /proc/sys/vm/compact_memory
[6]+  Done                    echo 1 > /proc/sys/vm/compact_memory
[root@localhost ~]# 
[root@localhost ~]# awk '/compact/ {print}' /proc/vmstat
compact_blocks_moved 3062
compact_pages_moved 49774
compact_pagemigrate_failed 129
compact_stall 0
compact_fail 0
compact_success 0
compact_balloon_isolated 26076
compact_balloon_migrated 25957
compact_balloon_released 25957
compact_balloon_returned 119

-- 
1.7.11.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v9 0/5] make balloon pages movable by compaction
       [not found] <cover.1345869378.git.aquini@redhat.com>
@ 2012-08-26  7:58 ` Michael S. Tsirkin
  2012-08-26 14:40   ` Rik van Riel
       [not found]   ` <503A3565.2060004@redhat.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-08-26  7:58 UTC (permalink / raw)
  To: Rafael Aquini
  Cc: Rik van Riel, Konrad Rzeszutek Wilk, linux-kernel, virtualization,
	linux-mm, Peter Zijlstra, Andi Kleen, Minchan Kim, Andrew Morton,
	Paul E. McKenney

On Sat, Aug 25, 2012 at 02:24:55AM -0300, Rafael Aquini wrote:
> Memory fragmentation introduced by ballooning might reduce significantly
> the number of 2MB contiguous memory blocks that can be used within a guest,
> thus imposing performance penalties associated with the reduced number of
> transparent huge pages that could be used by the guest workload.
> 
> This patch-set follows the main idea discussed at 2012 LSFMMS session:
> "Ballooning for transparent huge pages" -- http://lwn.net/Articles/490114/
> to introduce the required changes to the virtio_balloon driver, as well as
> the changes to the core compaction & migration bits, in order to make those
> subsystems aware of ballooned pages and allow memory balloon pages become
> movable within a guest, thus avoiding the aforementioned fragmentation issue

Meta-question: are there any numbers showing gain from this patchset?

The reason I ask, on migration we notify host about each page
individually.  If this is rare maybe the patchset does not help much.
If this is common we would be better off building up a list of multiple
pages and passing them in one go.

> Rafael Aquini (5):
>   mm: introduce a common interface for balloon pages mobility
>   mm: introduce compaction and migration for ballooned pages
>   virtio_balloon: introduce migration primitives to balloon pages
>   mm: introduce putback_movable_pages()
>   mm: add vm event counters for balloon pages compaction
> 
>  drivers/virtio/virtio_balloon.c    | 287 ++++++++++++++++++++++++++++++++++---
>  include/linux/balloon_compaction.h | 137 ++++++++++++++++++
>  include/linux/migrate.h            |   2 +
>  include/linux/pagemap.h            |  18 +++
>  include/linux/vm_event_item.h      |   8 +-
>  mm/Kconfig                         |  15 ++
>  mm/Makefile                        |   2 +-
>  mm/balloon_compaction.c            | 174 ++++++++++++++++++++++
>  mm/compaction.c                    |  51 ++++---
>  mm/migrate.c                       |  57 +++++++-
>  mm/page_alloc.c                    |   2 +-
>  mm/vmstat.c                        |  10 +-
>  12 files changed, 715 insertions(+), 48 deletions(-)
>  create mode 100644 include/linux/balloon_compaction.h
>  create mode 100644 mm/balloon_compaction.c
> 
> 
> Change log:
> v9:
>  * Adjust rcu_dereference usage to leverage page lock protection  (Paul, Peter);
>  * Enhance doc on compaction interface introduced to balloon driver   (Michael);
>  * Fix issue with isolated pages breaking leak_balloon() logics       (Michael);
> v8:
>  * introduce a common MM interface for balloon driver page compaction (Michael);
>  * remove the global state preventing multiple balloon device support (Michael);
>  * introduce RCU protection/syncrhonization to balloon page->mapping  (Michael);
> v7:
>  * fix a potential page leak case at 'putback_balloon_page'               (Mel);
>  * adjust vm-events-counter patch and remove its drop-on-merge message    (Rik);
>  * add 'putback_movable_pages' to avoid hacks on 'putback_lru_pages'  (Minchan);
> v6:
>  * rename 'is_balloon_page()' to 'movable_balloon_page()' 		  (Rik);
> v5:
>  * address Andrew Morton's review comments on the patch series;
>  * address a couple extra nitpick suggestions on PATCH 01 	      (Minchan);
> v4: 
>  * address Rusty Russel's review comments on PATCH 02;
>  * re-base virtio_balloon patch on 9c378abc5c0c6fc8e3acf5968924d274503819b3;
> V3: 
>  * address reviewers nitpick suggestions on PATCH 01		 (Mel, Minchan);
> V2: 
>  * address Mel Gorman's review comments on PATCH 01;
> 
> 
> Preliminary test results:
> (2 VCPU 2048mB RAM KVM guest running 3.6.0_rc3+ -- after a reboot)
> 
> * 64mB balloon:
> [root@localhost ~]# awk '/compact/ {print}' /proc/vmstat
> compact_blocks_moved 0
> compact_pages_moved 0
> compact_pagemigrate_failed 0
> compact_stall 0
> compact_fail 0
> compact_success 0
> compact_balloon_isolated 0
> compact_balloon_migrated 0
> compact_balloon_released 0
> compact_balloon_returned 0
> [root@localhost ~]# 
> [root@localhost ~]# for i in $(seq 1 6); do echo 1 > /proc/sys/vm/compact_memory & done &>/dev/null 
> [1]   Done                    echo 1 > /proc/sys/vm/compact_memory
> [2]   Done                    echo 1 > /proc/sys/vm/compact_memory
> [3]   Done                    echo 1 > /proc/sys/vm/compact_memory
> [4]   Done                    echo 1 > /proc/sys/vm/compact_memory
> [5]-  Done                    echo 1 > /proc/sys/vm/compact_memory
> [6]+  Done                    echo 1 > /proc/sys/vm/compact_memory
> [root@localhost ~]# 
> [root@localhost ~]# awk '/compact/ {print}' /proc/vmstat
> compact_blocks_moved 3108
> compact_pages_moved 43169
> compact_pagemigrate_failed 95
> compact_stall 0
> compact_fail 0
> compact_success 0
> compact_balloon_isolated 16384
> compact_balloon_migrated 16384
> compact_balloon_released 16384
> compact_balloon_returned 0
> 
> 
> * 128 mB balloon:
> [root@localhost ~]# awk '/compact/ {print}' /proc/vmstat
> compact_blocks_moved 0
> compact_pages_moved 0
> compact_pagemigrate_failed 0
> compact_stall 0
> compact_fail 0
> compact_success 0
> compact_balloon_isolated 0
> compact_balloon_migrated 0
> compact_balloon_released 0
> compact_balloon_returned 0
> [root@localhost ~]# 
> [root@localhost ~]# for i in $(seq 1 6); do echo 1 > /proc/sys/vm/compact_memory & done &>/dev/null  
> [1]   Done                    echo 1 > /proc/sys/vm/compact_memory
> [2]   Done                    echo 1 > /proc/sys/vm/compact_memory
> [3]   Done                    echo 1 > /proc/sys/vm/compact_memory
> [4]   Done                    echo 1 > /proc/sys/vm/compact_memory
> [5]-  Done                    echo 1 > /proc/sys/vm/compact_memory
> [6]+  Done                    echo 1 > /proc/sys/vm/compact_memory
> [root@localhost ~]# 
> [root@localhost ~]# awk '/compact/ {print}' /proc/vmstat
> compact_blocks_moved 3062
> compact_pages_moved 49774
> compact_pagemigrate_failed 129
> compact_stall 0
> compact_fail 0
> compact_success 0
> compact_balloon_isolated 26076
> compact_balloon_migrated 25957
> compact_balloon_released 25957
> compact_balloon_returned 119
> 
> -- 
> 1.7.11.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v9 0/5] make balloon pages movable by compaction
  2012-08-26  7:58 ` Michael S. Tsirkin
@ 2012-08-26 14:40   ` Rik van Riel
       [not found]   ` <503A3565.2060004@redhat.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Rik van Riel @ 2012-08-26 14:40 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Rafael Aquini, Konrad Rzeszutek Wilk, linux-kernel,
	virtualization, linux-mm, Peter Zijlstra, Andi Kleen, Minchan Kim,
	Andrew Morton, Paul E. McKenney

On 08/26/2012 03:58 AM, Michael S. Tsirkin wrote:
> On Sat, Aug 25, 2012 at 02:24:55AM -0300, Rafael Aquini wrote:
>> Memory fragmentation introduced by ballooning might reduce significantly
>> the number of 2MB contiguous memory blocks that can be used within a guest,
>> thus imposing performance penalties associated with the reduced number of
>> transparent huge pages that could be used by the guest workload.
>>
>> This patch-set follows the main idea discussed at 2012 LSFMMS session:
>> "Ballooning for transparent huge pages" -- http://lwn.net/Articles/490114/
>> to introduce the required changes to the virtio_balloon driver, as well as
>> the changes to the core compaction & migration bits, in order to make those
>> subsystems aware of ballooned pages and allow memory balloon pages become
>> movable within a guest, thus avoiding the aforementioned fragmentation issue
>
> Meta-question: are there any numbers showing gain from this patchset?
>
> The reason I ask, on migration we notify host about each page
> individually.  If this is rare maybe the patchset does not help much.
> If this is common we would be better off building up a list of multiple
> pages and passing them in one go.

The gain is in getting a better THP allocation rate inside the
guest, allowing applications to run faster.

The rarer it is for this code to run, the better - it means we
are getting the benefits without the overhead :)

-- 
All rights reversed

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v9 0/5] make balloon pages movable by compaction
       [not found]   ` <503A3565.2060004@redhat.com>
@ 2012-08-26 15:44     ` Michael S. Tsirkin
       [not found]     ` <20120826154423.GA15478@redhat.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-08-26 15:44 UTC (permalink / raw)
  To: Rik van Riel
  Cc: Rafael Aquini, Konrad Rzeszutek Wilk, linux-kernel,
	virtualization, linux-mm, Peter Zijlstra, Andi Kleen, Minchan Kim,
	Andrew Morton, Paul E. McKenney

On Sun, Aug 26, 2012 at 10:40:37AM -0400, Rik van Riel wrote:
> On 08/26/2012 03:58 AM, Michael S. Tsirkin wrote:
> >On Sat, Aug 25, 2012 at 02:24:55AM -0300, Rafael Aquini wrote:
> >>Memory fragmentation introduced by ballooning might reduce significantly
> >>the number of 2MB contiguous memory blocks that can be used within a guest,
> >>thus imposing performance penalties associated with the reduced number of
> >>transparent huge pages that could be used by the guest workload.
> >>
> >>This patch-set follows the main idea discussed at 2012 LSFMMS session:
> >>"Ballooning for transparent huge pages" -- http://lwn.net/Articles/490114/
> >>to introduce the required changes to the virtio_balloon driver, as well as
> >>the changes to the core compaction & migration bits, in order to make those
> >>subsystems aware of ballooned pages and allow memory balloon pages become
> >>movable within a guest, thus avoiding the aforementioned fragmentation issue
> >
> >Meta-question: are there any numbers showing gain from this patchset?
> >
> >The reason I ask, on migration we notify host about each page
> >individually.  If this is rare maybe the patchset does not help much.
> >If this is common we would be better off building up a list of multiple
> >pages and passing them in one go.
> 
> The gain is in getting a better THP allocation rate inside the
> guest, allowing applications to run faster.
> 
> The rarer it is for this code to run, the better - it means we
> are getting the benefits without the overhead :)

I am simply asking how was this patchset tested.
It would be nice to have this info in commit log.
Since this is an optimization patch it is strange
to see one with no numbers at all.
For example, you probably run some workload and
played with the balloon, and then saw less huge pages
without the patch and more with?
Please put this info in the cover letter.

> -- 
> All rights reversed

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v9 0/5] make balloon pages movable by compaction
       [not found]     ` <20120826154423.GA15478@redhat.com>
@ 2012-08-27 20:22       ` Rafael Aquini
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael Aquini @ 2012-08-27 20:22 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Rik van Riel, Konrad Rzeszutek Wilk, linux-kernel, virtualization,
	linux-mm, Peter Zijlstra, Andi Kleen, Minchan Kim, Andrew Morton,
	Paul E. McKenney

On Sun, Aug 26, 2012 at 06:44:23PM +0300, Michael S. Tsirkin wrote:
> 
> I am simply asking how was this patchset tested.
> It would be nice to have this info in commit log.
> Since this is an optimization patch it is strange
> to see one with no numbers at all.
> For example, you probably run some workload and
> played with the balloon, and then saw less huge pages
> without the patch and more with?
> Please put this info in the cover letter.

Will do it, for sure. As soon as we get closer to an agreement on how the code
has to behave and looks like. I'll use Mel's mmtests bench suite for that.

Cheers!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-08-27 20:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-25  5:24 [PATCH v9 0/5] make balloon pages movable by compaction Rafael Aquini
     [not found] <cover.1345869378.git.aquini@redhat.com>
2012-08-26  7:58 ` Michael S. Tsirkin
2012-08-26 14:40   ` Rik van Riel
     [not found]   ` <503A3565.2060004@redhat.com>
2012-08-26 15:44     ` Michael S. Tsirkin
     [not found]     ` <20120826154423.GA15478@redhat.com>
2012-08-27 20:22       ` Rafael Aquini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).