Subject: Re: mmotm 2016-02-03-16-36 uploaded

From: Michal Hocko <[email-masked]>
Date: Thu, 4 Feb 2016 17:57:45 +0100

[CCing Minchan]

I am getting many compilation errors if !CONFIG_COMPACTION and
CONFIG_MEMORY_ISOLATION=y. I didn't get to check what has hanged in that
regards because this code is quite old but the previous mmotm seemed ok,
maybe some subtle change in my config?

---
mm/page_alloc.c:6893:6: warning: ‘struct compact_control’ declared inside parameter list [enabled by default]
      unsigned long start, unsigned long end)
      ^
mm/page_alloc.c:6893:6: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
mm/page_alloc.c: In function ‘__alloc_contig_migrate_range’:
mm/page_alloc.c:6903:37: error: dereferencing pointer to incomplete type
  while (pfn < end || !list_empty(&cc->migratepages)) {
                                     ^
mm/page_alloc.c:6909:21: error: dereferencing pointer to incomplete type
   if (list_empty(&cc->migratepages)) {
                     ^
mm/page_alloc.c:6910:6: error: dereferencing pointer to incomplete type
    cc->nr_migratepages = 0;
      ^
mm/page_alloc.c:6911:4: error: implicit declaration of function ‘isolate_migratepages_range’ [-Werror=implicit-function-declaration]
    pfn = isolate_migratepages_range(cc, pfn, end);
    ^
mm/page_alloc.c:6922:50: error: dereferencing pointer to incomplete type
   nr_reclaimed = reclaim_clean_pages_from_list(cc->zone,
                                                  ^
mm/page_alloc.c:6923:11: error: dereferencing pointer to incomplete type
        &cc->migratepages);
           ^
mm/page_alloc.c:6924:5: error: dereferencing pointer to incomplete type
   cc->nr_migratepages -= nr_reclaimed;
     ^
mm/page_alloc.c:6926:26: error: dereferencing pointer to incomplete type
   ret = migrate_pages(&cc->migratepages, alloc_migrate_target,
                          ^
mm/page_alloc.c:6927:20: error: dereferencing pointer to incomplete type
         NULL, 0, cc->mode, MR_CMA);
                    ^
mm/page_alloc.c:6930:28: error: dereferencing pointer to incomplete type
   putback_movable_pages(&cc->migratepages);
                            ^
mm/page_alloc.c: In function ‘alloc_contig_range’:
mm/page_alloc.c:6963:9: error: variable ‘cc’ has initializer but incomplete type
  struct compact_control cc = {
         ^
mm/page_alloc.c:6964:3: error: unknown field ‘nr_migratepages’ specified in initializer
   .nr_migratepages = 0,

---
I have tried to do

diff --git a/mm/internal.h b/mm/internal.h
index 271ad9567e32..f7c0024a013a 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -150,7 +150,7 @@ extern bool is_free_buddy_page(struct page *page);
 #endif
 extern int user_min_free_kbytes;
 
-#if defined CONFIG_COMPACTION || defined CONFIG_CMA
+#if defined CONFIG_COMPACTION || defined CONFIG_CMA || defined MEMORY_ISOLATION
 
 /*
  * in mm/compaction.c

but that failed during linkage:
mm/built-in.o: In function `alloc_contig_range':
/dev/shm/mhocko/mmotm/mm/page_alloc.c:7062: undefined reference to `isolate_freepages_range'
mm/built-in.o: In function `__alloc_contig_migrate_range':
/dev/shm/mhocko/mmotm/mm/page_alloc.c:6911: undefined reference to `isolate_migratepages_range'

So it really seems that CONFIG_MEMORY_ISOLATION depends on unctionality
provided by CONFIG_COMPACTION. The whole MEMORY_ISOLATION came in
ee6f509c3274 ("mm: factor out memory isolate functions") in 3.6 so quite
some time ago. I do not have a good idea how to untangle this. We can
move isolate_freepages_range and isolate_migratepages_range but then it
needs to do ifdef for both MEMORY_ISOLATION and COMPACTION.

Another option would be to make MEMORY_ISOLATION depend on
COMPACTION. Do we ever need this functionality without compaction?
-- 
Michal Hocko
SUSE Labs