Re: [PATCH 04/11] mm: compaction: export some of the functions

2011-12-12 Thread Michal Nazarewicz

On Mon, 12 Dec 2011 15:29:07 +0100, Mel Gorman m...@csn.ul.ie wrote:


On Fri, Nov 18, 2011 at 05:43:11PM +0100, Marek Szyprowski wrote:

From: Michal Nazarewicz min...@mina86.com

This commit exports some of the functions from compaction.c file
outside of it adding their declaration into internal.h header
file so that other mm related code can use them.

This forced compaction.c to always be compiled (as opposed to being
compiled only if CONFIG_COMPACTION is defined) but as to avoid
introducing code that user did not ask for, part of the compaction.c
is now wrapped in on #ifdef.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 mm/Makefile |3 +-
 mm/compaction.c |  112 +++
 mm/internal.h   |   35 +
 3 files changed, 83 insertions(+), 67 deletions(-)

diff --git a/mm/Makefile b/mm/Makefile
index 50ec00e..24ed801 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -13,7 +13,7 @@ obj-y := filemap.o mempool.o oom_kill.o 
fadvise.o \
   readahead.o swap.o truncate.o vmscan.o shmem.o \
   prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
   page_isolation.o mm_init.o mmu_context.o percpu.o \
-  $(mmu-y)
+  $(mmu-y) compaction.o


That should be

compaction.o $(mmu-y)

for consistency.

Overall, this patch implies that CMA is always compiled in.


Not really.  But yes, it produces some bloat when neither CMA nor
compaction are compiled.  I assume that linker will be able to deal
with that (since the functions are not EXPORT_SYMBOL'ed).

Note also that the was majority of compaction.c is #ifdef'd though
so only a handful of functions are compiled.


Why not just make CMA depend on COMPACTION to keep things simplier?


I could imagine that someone would want to have CMA but not compaction,
hence I decided to give that choice.


For example, if you enable CMA and do not enable COMPACTION, you
lose things like the vmstat counters that can aid debugging. In
fact, as parts of compaction.c are using defines like COMPACTBLOCKS,
I'm not even sure compaction.c can compile without CONFIG_COMPACTION
because of the vmstat stuff.


--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/11] mm: compaction: export some of the functions

2011-12-12 Thread Mel Gorman
On Mon, Dec 12, 2011 at 03:41:04PM +0100, Michal Nazarewicz wrote:
 On Mon, 12 Dec 2011 15:29:07 +0100, Mel Gorman m...@csn.ul.ie wrote:
 
 On Fri, Nov 18, 2011 at 05:43:11PM +0100, Marek Szyprowski wrote:
 From: Michal Nazarewicz min...@mina86.com
 
 This commit exports some of the functions from compaction.c file
 outside of it adding their declaration into internal.h header
 file so that other mm related code can use them.
 
 This forced compaction.c to always be compiled (as opposed to being
 compiled only if CONFIG_COMPACTION is defined) but as to avoid
 introducing code that user did not ask for, part of the compaction.c
 is now wrapped in on #ifdef.
 
 Signed-off-by: Michal Nazarewicz min...@mina86.com
 Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
 ---
  mm/Makefile |3 +-
  mm/compaction.c |  112 
  +++
  mm/internal.h   |   35 +
  3 files changed, 83 insertions(+), 67 deletions(-)
 
 diff --git a/mm/Makefile b/mm/Makefile
 index 50ec00e..24ed801 100644
 --- a/mm/Makefile
 +++ b/mm/Makefile
 @@ -13,7 +13,7 @@ obj-y := filemap.o mempool.o 
 oom_kill.o fadvise.o \
readahead.o swap.o truncate.o vmscan.o shmem.o \
prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
page_isolation.o mm_init.o mmu_context.o percpu.o \
 -  $(mmu-y)
 +  $(mmu-y) compaction.o
 
 That should be
 
 compaction.o $(mmu-y)
 
 for consistency.
 
 Overall, this patch implies that CMA is always compiled in.
 
 Not really.  But yes, it produces some bloat when neither CMA nor
 compaction are compiled.  I assume that linker will be able to deal
 with that (since the functions are not EXPORT_SYMBOL'ed).
 

The bloat exists either way. I don't believe the linker strips it out so
overall it would make more sense to depend on compaction to keep the
vmstat counters for debugging reasons if nothing else. It's not
something I feel very strongly about though.

-- 
Mel Gorman
SUSE Labs
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/11] mm: compaction: export some of the functions

2011-12-12 Thread Michal Nazarewicz

On Mon, 12 Dec 2011 15:29:07 +0100, Mel Gorman m...@csn.ul.ie wrote:

Overall, this patch implies that CMA is always compiled in.



On Mon, Dec 12, 2011 at 03:41:04PM +0100, Michal Nazarewicz wrote:

Not really.  But yes, it produces some bloat when neither CMA nor
compaction are compiled.  I assume that linker will be able to deal
with that (since the functions are not EXPORT_SYMBOL'ed).


On Mon, 12 Dec 2011 16:40:15 +0100, Mel Gorman m...@csn.ul.ie wrote:

The bloat exists either way. I don't believe the linker strips it out so
overall it would make more sense to depend on compaction to keep the
vmstat counters for debugging reasons if nothing else. It's not
something I feel very strongly about though.


KK, I'll do that then.

--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/11] mm: compaction: export some of the functions

2011-12-12 Thread Arnd Bergmann
On Monday 12 December 2011, Mel Gorman wrote:
 The bloat exists either way. I don't believe the linker strips it out so
 overall it would make more sense to depend on compaction to keep the
 vmstat counters for debugging reasons if nothing else. It's not
 something I feel very strongly about though.

There were some previous attempts to use -fgc-sections to strip out
unused functions from the kernel, but I think they were never merged
because of regressions.

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/11] mm: compaction: export some of the functions

2011-11-18 Thread Marek Szyprowski
From: Michal Nazarewicz min...@mina86.com

This commit exports some of the functions from compaction.c file
outside of it adding their declaration into internal.h header
file so that other mm related code can use them.

This forced compaction.c to always be compiled (as opposed to being
compiled only if CONFIG_COMPACTION is defined) but as to avoid
introducing code that user did not ask for, part of the compaction.c
is now wrapped in on #ifdef.

Signed-off-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 mm/Makefile |3 +-
 mm/compaction.c |  112 +++
 mm/internal.h   |   35 +
 3 files changed, 83 insertions(+), 67 deletions(-)

diff --git a/mm/Makefile b/mm/Makefile
index 50ec00e..24ed801 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -13,7 +13,7 @@ obj-y := filemap.o mempool.o oom_kill.o 
fadvise.o \
   readahead.o swap.o truncate.o vmscan.o shmem.o \
   prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
   page_isolation.o mm_init.o mmu_context.o percpu.o \
-  $(mmu-y)
+  $(mmu-y) compaction.o
 obj-y += init-mm.o
 
 ifdef CONFIG_NO_BOOTMEM
@@ -32,7 +32,6 @@ obj-$(CONFIG_NUMA)+= mempolicy.o
 obj-$(CONFIG_SPARSEMEM)+= sparse.o
 obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o
 obj-$(CONFIG_SLOB) += slob.o
-obj-$(CONFIG_COMPACTION) += compaction.o
 obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
 obj-$(CONFIG_KSM) += ksm.o
 obj-$(CONFIG_PAGE_POISONING) += debug-pagealloc.o
diff --git a/mm/compaction.c b/mm/compaction.c
index 09c9702..e71ceaf 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -19,28 +19,7 @@
 #define CREATE_TRACE_POINTS
 #include trace/events/compaction.h
 
-/*
- * compact_control is used to track pages being migrated and the free pages
- * they are being migrated to during memory compaction. The free_pfn starts
- * at the end of a zone and migrate_pfn begins at the start. Movable pages
- * are moved to the end of a zone during a compaction run and the run
- * completes when free_pfn = migrate_pfn
- */
-struct compact_control {
-   struct list_head freepages; /* List of free pages to migrate to */
-   struct list_head migratepages;  /* List of pages being migrated */
-   unsigned long nr_freepages; /* Number of isolated free pages */
-   unsigned long nr_migratepages;  /* Number of pages to migrate */
-   unsigned long free_pfn; /* isolate_freepages search base */
-   unsigned long migrate_pfn;  /* isolate_migratepages search base */
-   bool sync;  /* Synchronous migration */
-
-   unsigned int order; /* order a direct compactor needs */
-   int migratetype;/* MOVABLE, RECLAIMABLE etc */
-   struct zone *zone;
-};
-
-static unsigned long release_freepages(struct list_head *freelist)
+unsigned long release_freepages(struct list_head *freelist)
 {
struct page *page, *next;
unsigned long count = 0;
@@ -71,7 +50,7 @@ static unsigned long release_freepages(struct list_head 
*freelist)
  * Returns number of isolated pages.  This may be more then end-start
  * if end fell in a middle of a free page.
  */
-static unsigned long
+unsigned long
 isolate_freepages_range(struct zone *zone,
unsigned long start, unsigned long end,
struct list_head *freelist)
@@ -263,13 +242,6 @@ static bool too_many_isolated(struct zone *zone)
return isolated  (inactive + active) / 2;
 }
 
-/* possible outcome of isolate_migratepages */
-typedef enum {
-   ISOLATE_ABORT,  /* Abort compaction now */
-   ISOLATE_NONE,   /* No pages isolated, continue scanning */
-   ISOLATE_SUCCESS,/* Pages isolated, migrate */
-} isolate_migrate_t;
-
 /**
  * isolate_migratepages_range() - isolate all migrate-able pages in range.
  * @zone:  Zone pages are in.
@@ -289,7 +261,7 @@ typedef enum {
  * does not modify any cc's fields, ie. it does not modify (or read
  * for that matter) cc-migrate_pfn.
  */
-static unsigned long
+unsigned long
 isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
   unsigned long low_pfn, unsigned long end_pfn)
 {
@@ -404,43 +376,11 @@ isolate_migratepages_range(struct zone *zone, struct 
compact_control *cc,
 }
 
 /*
- * Isolate all pages that can be migrated from the block pointed to by
- * the migrate scanner within compact_control.
- */
-static isolate_migrate_t isolate_migratepages(struct zone *zone,
-   struct compact_control *cc)
-{
-   unsigned long low_pfn, end_pfn;
-
-   /* Do not scan outside zone boundaries */
-   low_pfn = max(cc-migrate_pfn, zone-zone_start_pfn);
-
-   /* Only scan within a pageblock boundary