Re: [PATCH v2 5/6] mm/balloon_compaction: use common page ballooning
On Sat, 30 Aug 2014 20:41:23 +0400 Konstantin Khlebnikov wrote: > This patch replaces checking AS_BALLOON_MAP in page->mapping->flags > with PageBalloon which is stored directly in the struct page. > All code of balloon_compaction now under CONFIG_MEMORY_BALLOON. argh, now the bogus Kconfig/Makefile changes get removed again. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 5/6] mm/balloon_compaction: use common page ballooning
On Sat, 30 Aug 2014 20:41:23 +0400 Konstantin Khlebnikov koc...@gmail.com wrote: This patch replaces checking AS_BALLOON_MAP in page-mapping-flags with PageBalloon which is stored directly in the struct page. All code of balloon_compaction now under CONFIG_MEMORY_BALLOON. argh, now the bogus Kconfig/Makefile changes get removed again. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 5/6] mm/balloon_compaction: use common page ballooning
On Sat, Aug 30, 2014 at 08:41:23PM +0400, Konstantin Khlebnikov wrote: > From: Konstantin Khlebnikov > > This patch replaces checking AS_BALLOON_MAP in page->mapping->flags > with PageBalloon which is stored directly in the struct page. > All code of balloon_compaction now under CONFIG_MEMORY_BALLOON. > > Signed-off-by: Konstantin Khlebnikov > --- > drivers/virtio/Kconfig |1 > include/linux/balloon_compaction.h | 135 > ++-- > mm/Kconfig |2 - > mm/Makefile|3 + > mm/balloon_compaction.c|7 +- > mm/compaction.c|9 +- > mm/migrate.c |6 +- > mm/vmscan.c|2 - > 8 files changed, 39 insertions(+), 126 deletions(-) > > diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig > index c6683f2..00b2286 100644 > --- a/drivers/virtio/Kconfig > +++ b/drivers/virtio/Kconfig > @@ -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. > diff --git a/include/linux/balloon_compaction.h > b/include/linux/balloon_compaction.h > index 284fc1d..09f8c5a 100644 > --- a/include/linux/balloon_compaction.h > +++ b/include/linux/balloon_compaction.h > @@ -46,6 +46,8 @@ > #include > #include > > +#ifdef CONFIG_MEMORY_BALLOON > + > /* > * Balloon device information descriptor. > * This struct is used to allow the common balloon compaction interface > @@ -93,91 +95,6 @@ static inline void balloon_page_free(struct page *page) > __free_page(page); > } > > -#ifdef CONFIG_BALLOON_COMPACTION > -extern bool balloon_page_isolate(struct page *page); > -extern void balloon_page_putback(struct page *page); > -extern int balloon_page_migrate(struct page *newpage, > - struct page *page, enum migrate_mode mode); > -extern struct address_space > -*balloon_mapping_alloc(struct balloon_dev_info *b_dev_info, > - const struct address_space_operations *a_ops); > - > -static inline void balloon_mapping_free(struct address_space > *balloon_mapping) > -{ > - kfree(balloon_mapping); > -} > - > -/* > - * page_flags_cleared - helper to perform balloon @page ->flags tests. > - * > - * As balloon pages are obtained from buddy and we do not play with > page->flags > - * at driver level (exception made when we get the page lock for compaction), > - * we can safely identify a ballooned page by checking if the > - * PAGE_FLAGS_CHECK_AT_PREP page->flags are all cleared. This approach also > - * helps us skip ballooned pages that are locked for compaction or release, > thus > - * mitigating their racy check at balloon_page_movable() > - */ > -static inline bool page_flags_cleared(struct page *page) > -{ > - return !(page->flags & PAGE_FLAGS_CHECK_AT_PREP); > -} > - > -/* > - * __is_movable_balloon_page - helper to perform @page mapping->flags tests > - */ > -static inline bool __is_movable_balloon_page(struct page *page) > -{ > - struct address_space *mapping = page->mapping; > - return !PageAnon(page) && mapping_balloon(mapping); > -} > - > -/* > - * balloon_page_movable - test page->mapping->flags to identify balloon pages > - * that can be moved by compaction/migration. > - * > - * This function is used at core compaction's page isolation scheme, > therefore > - * most pages exposed to it are not enlisted as balloon pages and so, to > avoid > - * undesired side effects like racing against __free_pages(), we cannot > afford > - * holding the page locked while testing page->mapping->flags here. > - * > - * As we might return false positives in the case of a balloon page being > just > - * released under us, the page->mapping->flags need to be re-tested later, > - * under the proper page lock, at the functions that will be coping with the > - * balloon page case. > - */ > -static inline bool balloon_page_movable(struct page *page) > -{ > - /* > - * Before dereferencing and testing mapping->flags, let's make sure > - * this is not a page that uses ->mapping in a different way > - */ > - if (page_flags_cleared(page) && !page_mapped(page) && > - page_count(page) == 1) > - return __is_movable_balloon_page(page); > - > - return false; > -} > - > -/* > - * isolated_balloon_page - identify an isolated balloon page on private > - * compaction/migration page lists. > - * > - * After a compaction thread isolates a balloon page for migration, it raises > - * the page refcount to prevent concurrent compaction threads from > re-isolating > - * the same page. For that reason putback_movable_pages(), or other routines > - * that need to identify isolated balloon pages on
Re: [PATCH v2 5/6] mm/balloon_compaction: use common page ballooning
On Sat, Aug 30, 2014 at 08:41:23PM +0400, Konstantin Khlebnikov wrote: From: Konstantin Khlebnikov k.khlebni...@samsung.com This patch replaces checking AS_BALLOON_MAP in page-mapping-flags with PageBalloon which is stored directly in the struct page. All code of balloon_compaction now under CONFIG_MEMORY_BALLOON. Signed-off-by: Konstantin Khlebnikov k.khlebni...@samsung.com --- drivers/virtio/Kconfig |1 include/linux/balloon_compaction.h | 135 ++-- mm/Kconfig |2 - mm/Makefile|3 + mm/balloon_compaction.c|7 +- mm/compaction.c|9 +- mm/migrate.c |6 +- mm/vmscan.c|2 - 8 files changed, 39 insertions(+), 126 deletions(-) diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig index c6683f2..00b2286 100644 --- a/drivers/virtio/Kconfig +++ b/drivers/virtio/Kconfig @@ -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. diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h index 284fc1d..09f8c5a 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -46,6 +46,8 @@ #include linux/gfp.h #include linux/err.h +#ifdef CONFIG_MEMORY_BALLOON + /* * Balloon device information descriptor. * This struct is used to allow the common balloon compaction interface @@ -93,91 +95,6 @@ static inline void balloon_page_free(struct page *page) __free_page(page); } -#ifdef CONFIG_BALLOON_COMPACTION -extern bool balloon_page_isolate(struct page *page); -extern void balloon_page_putback(struct page *page); -extern int balloon_page_migrate(struct page *newpage, - struct page *page, enum migrate_mode mode); -extern struct address_space -*balloon_mapping_alloc(struct balloon_dev_info *b_dev_info, - const struct address_space_operations *a_ops); - -static inline void balloon_mapping_free(struct address_space *balloon_mapping) -{ - kfree(balloon_mapping); -} - -/* - * page_flags_cleared - helper to perform balloon @page -flags tests. - * - * As balloon pages are obtained from buddy and we do not play with page-flags - * at driver level (exception made when we get the page lock for compaction), - * we can safely identify a ballooned page by checking if the - * PAGE_FLAGS_CHECK_AT_PREP page-flags are all cleared. This approach also - * helps us skip ballooned pages that are locked for compaction or release, thus - * mitigating their racy check at balloon_page_movable() - */ -static inline bool page_flags_cleared(struct page *page) -{ - return !(page-flags PAGE_FLAGS_CHECK_AT_PREP); -} - -/* - * __is_movable_balloon_page - helper to perform @page mapping-flags tests - */ -static inline bool __is_movable_balloon_page(struct page *page) -{ - struct address_space *mapping = page-mapping; - return !PageAnon(page) mapping_balloon(mapping); -} - -/* - * balloon_page_movable - test page-mapping-flags to identify balloon pages - * that can be moved by compaction/migration. - * - * This function is used at core compaction's page isolation scheme, therefore - * most pages exposed to it are not enlisted as balloon pages and so, to avoid - * undesired side effects like racing against __free_pages(), we cannot afford - * holding the page locked while testing page-mapping-flags here. - * - * As we might return false positives in the case of a balloon page being just - * released under us, the page-mapping-flags need to be re-tested later, - * under the proper page lock, at the functions that will be coping with the - * balloon page case. - */ -static inline bool balloon_page_movable(struct page *page) -{ - /* - * Before dereferencing and testing mapping-flags, let's make sure - * this is not a page that uses -mapping in a different way - */ - if (page_flags_cleared(page) !page_mapped(page) - page_count(page) == 1) - return __is_movable_balloon_page(page); - - return false; -} - -/* - * isolated_balloon_page - identify an isolated balloon page on private - * compaction/migration page lists. - * - * After a compaction thread isolates a balloon page for migration, it raises - * the page refcount to prevent concurrent compaction threads from re-isolating - * the same page. For that reason putback_movable_pages(), or other routines - * that need to identify isolated balloon pages on private pagelists, cannot - * rely on balloon_page_movable() to accomplish the task.
[PATCH v2 5/6] mm/balloon_compaction: use common page ballooning
From: Konstantin Khlebnikov This patch replaces checking AS_BALLOON_MAP in page->mapping->flags with PageBalloon which is stored directly in the struct page. All code of balloon_compaction now under CONFIG_MEMORY_BALLOON. Signed-off-by: Konstantin Khlebnikov --- drivers/virtio/Kconfig |1 include/linux/balloon_compaction.h | 135 ++-- mm/Kconfig |2 - mm/Makefile|3 + mm/balloon_compaction.c|7 +- mm/compaction.c|9 +- mm/migrate.c |6 +- mm/vmscan.c|2 - 8 files changed, 39 insertions(+), 126 deletions(-) diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig index c6683f2..00b2286 100644 --- a/drivers/virtio/Kconfig +++ b/drivers/virtio/Kconfig @@ -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. diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h index 284fc1d..09f8c5a 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -46,6 +46,8 @@ #include #include +#ifdef CONFIG_MEMORY_BALLOON + /* * Balloon device information descriptor. * This struct is used to allow the common balloon compaction interface @@ -93,91 +95,6 @@ static inline void balloon_page_free(struct page *page) __free_page(page); } -#ifdef CONFIG_BALLOON_COMPACTION -extern bool balloon_page_isolate(struct page *page); -extern void balloon_page_putback(struct page *page); -extern int balloon_page_migrate(struct page *newpage, - struct page *page, enum migrate_mode mode); -extern struct address_space -*balloon_mapping_alloc(struct balloon_dev_info *b_dev_info, - const struct address_space_operations *a_ops); - -static inline void balloon_mapping_free(struct address_space *balloon_mapping) -{ - kfree(balloon_mapping); -} - -/* - * page_flags_cleared - helper to perform balloon @page ->flags tests. - * - * As balloon pages are obtained from buddy and we do not play with page->flags - * at driver level (exception made when we get the page lock for compaction), - * we can safely identify a ballooned page by checking if the - * PAGE_FLAGS_CHECK_AT_PREP page->flags are all cleared. This approach also - * helps us skip ballooned pages that are locked for compaction or release, thus - * mitigating their racy check at balloon_page_movable() - */ -static inline bool page_flags_cleared(struct page *page) -{ - return !(page->flags & PAGE_FLAGS_CHECK_AT_PREP); -} - -/* - * __is_movable_balloon_page - helper to perform @page mapping->flags tests - */ -static inline bool __is_movable_balloon_page(struct page *page) -{ - struct address_space *mapping = page->mapping; - return !PageAnon(page) && mapping_balloon(mapping); -} - -/* - * balloon_page_movable - test page->mapping->flags to identify balloon pages - * that can be moved by compaction/migration. - * - * This function is used at core compaction's page isolation scheme, therefore - * most pages exposed to it are not enlisted as balloon pages and so, to avoid - * undesired side effects like racing against __free_pages(), we cannot afford - * holding the page locked while testing page->mapping->flags here. - * - * As we might return false positives in the case of a balloon page being just - * released under us, the page->mapping->flags need to be re-tested later, - * under the proper page lock, at the functions that will be coping with the - * balloon page case. - */ -static inline bool balloon_page_movable(struct page *page) -{ - /* -* Before dereferencing and testing mapping->flags, let's make sure -* this is not a page that uses ->mapping in a different way -*/ - if (page_flags_cleared(page) && !page_mapped(page) && - page_count(page) == 1) - return __is_movable_balloon_page(page); - - return false; -} - -/* - * isolated_balloon_page - identify an isolated balloon page on private - *compaction/migration page lists. - * - * After a compaction thread isolates a balloon page for migration, it raises - * the page refcount to prevent concurrent compaction threads from re-isolating - * the same page. For that reason putback_movable_pages(), or other routines - * that need to identify isolated balloon pages on private pagelists, cannot - * rely on balloon_page_movable() to accomplish the task. - */ -static inline bool isolated_balloon_page(struct page *page) -{ - /* Already isolated balloon pages, by default, have a raised refcount */ - if (page_flags_cleared(page) && !page_mapped(page)
[PATCH v2 5/6] mm/balloon_compaction: use common page ballooning
From: Konstantin Khlebnikov k.khlebni...@samsung.com This patch replaces checking AS_BALLOON_MAP in page-mapping-flags with PageBalloon which is stored directly in the struct page. All code of balloon_compaction now under CONFIG_MEMORY_BALLOON. Signed-off-by: Konstantin Khlebnikov k.khlebni...@samsung.com --- drivers/virtio/Kconfig |1 include/linux/balloon_compaction.h | 135 ++-- mm/Kconfig |2 - mm/Makefile|3 + mm/balloon_compaction.c|7 +- mm/compaction.c|9 +- mm/migrate.c |6 +- mm/vmscan.c|2 - 8 files changed, 39 insertions(+), 126 deletions(-) diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig index c6683f2..00b2286 100644 --- a/drivers/virtio/Kconfig +++ b/drivers/virtio/Kconfig @@ -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. diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h index 284fc1d..09f8c5a 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -46,6 +46,8 @@ #include linux/gfp.h #include linux/err.h +#ifdef CONFIG_MEMORY_BALLOON + /* * Balloon device information descriptor. * This struct is used to allow the common balloon compaction interface @@ -93,91 +95,6 @@ static inline void balloon_page_free(struct page *page) __free_page(page); } -#ifdef CONFIG_BALLOON_COMPACTION -extern bool balloon_page_isolate(struct page *page); -extern void balloon_page_putback(struct page *page); -extern int balloon_page_migrate(struct page *newpage, - struct page *page, enum migrate_mode mode); -extern struct address_space -*balloon_mapping_alloc(struct balloon_dev_info *b_dev_info, - const struct address_space_operations *a_ops); - -static inline void balloon_mapping_free(struct address_space *balloon_mapping) -{ - kfree(balloon_mapping); -} - -/* - * page_flags_cleared - helper to perform balloon @page -flags tests. - * - * As balloon pages are obtained from buddy and we do not play with page-flags - * at driver level (exception made when we get the page lock for compaction), - * we can safely identify a ballooned page by checking if the - * PAGE_FLAGS_CHECK_AT_PREP page-flags are all cleared. This approach also - * helps us skip ballooned pages that are locked for compaction or release, thus - * mitigating their racy check at balloon_page_movable() - */ -static inline bool page_flags_cleared(struct page *page) -{ - return !(page-flags PAGE_FLAGS_CHECK_AT_PREP); -} - -/* - * __is_movable_balloon_page - helper to perform @page mapping-flags tests - */ -static inline bool __is_movable_balloon_page(struct page *page) -{ - struct address_space *mapping = page-mapping; - return !PageAnon(page) mapping_balloon(mapping); -} - -/* - * balloon_page_movable - test page-mapping-flags to identify balloon pages - * that can be moved by compaction/migration. - * - * This function is used at core compaction's page isolation scheme, therefore - * most pages exposed to it are not enlisted as balloon pages and so, to avoid - * undesired side effects like racing against __free_pages(), we cannot afford - * holding the page locked while testing page-mapping-flags here. - * - * As we might return false positives in the case of a balloon page being just - * released under us, the page-mapping-flags need to be re-tested later, - * under the proper page lock, at the functions that will be coping with the - * balloon page case. - */ -static inline bool balloon_page_movable(struct page *page) -{ - /* -* Before dereferencing and testing mapping-flags, let's make sure -* this is not a page that uses -mapping in a different way -*/ - if (page_flags_cleared(page) !page_mapped(page) - page_count(page) == 1) - return __is_movable_balloon_page(page); - - return false; -} - -/* - * isolated_balloon_page - identify an isolated balloon page on private - *compaction/migration page lists. - * - * After a compaction thread isolates a balloon page for migration, it raises - * the page refcount to prevent concurrent compaction threads from re-isolating - * the same page. For that reason putback_movable_pages(), or other routines - * that need to identify isolated balloon pages on private pagelists, cannot - * rely on balloon_page_movable() to accomplish the task. - */ -static inline bool isolated_balloon_page(struct page *page) -{ - /* Already isolated balloon pages, by default, have a raised refcount */ - if