linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* page migration: Only migrate pages if allocation in the highest zone is possible
@ 2007-04-30  6:17 Christoph Lameter
  2007-04-30 11:58 ` Hugh Dickins
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Lameter @ 2007-04-30  6:17 UTC (permalink / raw)
  To: akpm; +Cc: Hugh Dickins, linux-mm

Address spaces contain an allocation flag that specifies restriction on
the zone for pages placed in the mapping. I.e. some device may require pages
to be allocated from a DMA zone. Block devices may not be able to use pages
from HIGHMEM.

Memory policies and the common use of page migration works only on the
highest zone. If the address space does not allow allocation from the
highest zone then the pages in the address space are not migratable simply
because we can only allocate memory for a specified node if we allow
allocation for the highest zone on each node.

Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>

---
 include/linux/migrate.h |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6.21-rc7-mm2/include/linux/migrate.h
===================================================================
--- linux-2.6.21-rc7-mm2.orig/include/linux/migrate.h	2007-04-15 16:50:57.000000000 -0700
+++ linux-2.6.21-rc7-mm2/include/linux/migrate.h	2007-04-27 23:14:49.000000000 -0700
@@ -2,6 +2,7 @@
 #define _LINUX_MIGRATE_H
 
 #include <linux/mm.h>
+#include <linux/mempolicy.h>
 
 typedef struct page *new_page_t(struct page *, unsigned long private, int **);
 
@@ -10,6 +11,14 @@ static inline int vma_migratable(struct 
 {
 	if (vma->vm_flags & (VM_IO|VM_HUGETLB|VM_PFNMAP|VM_RESERVED))
 		return 0;
+	/*
+	 * Migration allocates pages in the highest zone. If we cannot
+	 * do so then migration (at least from node to node) is not
+	 * possible.
+	 */
+	if (vma->vm_file && vma->vm_file->f_mapping &&
+		gfp_zone(vma->vm_file->f_mapping->flags) < policy_zone)
+			return 0;
 	return 1;
 }
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: page migration: Only migrate pages if allocation in the highest zone is possible
  2007-04-30  6:17 page migration: Only migrate pages if allocation in the highest zone is possible Christoph Lameter
@ 2007-04-30 11:58 ` Hugh Dickins
  2007-04-30 19:20   ` Christoph Lameter
  0 siblings, 1 reply; 4+ messages in thread
From: Hugh Dickins @ 2007-04-30 11:58 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm

On Sun, 29 Apr 2007, Christoph Lameter wrote:

> Address spaces contain an allocation flag that specifies restriction on
> the zone for pages placed in the mapping. I.e. some device may require pages
> to be allocated from a DMA zone. Block devices may not be able to use pages
> from HIGHMEM.
> 
> Memory policies and the common use of page migration works only on the
> highest zone. If the address space does not allow allocation from the
> highest zone then the pages in the address space are not migratable simply
> because we can only allocate memory for a specified node if we allow
> allocation for the highest zone on each node.
> 
> Cc: Hugh Dickins <hugh@veritas.com>
> Signed-off-by: Christoph Lameter <clameter@sgi.com>

That looks about right to me: from the previous discussion it appeared
that a test in vma_migratable() is currently more appropriate than
refining the page allocation routines (and yours is nicer than mine).
Though that will change when page migration is used beyond CONFIG_NUMA.

There is still another argument against doing it in vma_migratable():
this way a private mapping of a blockdev filled with anon COWed
pages, perfectly migratable in itself, is ruled out as if all
its pages were shared.  But IIRC all the mempolicy stuff is really
geared towards shared mappings anyway, and I expect blockdev
mappings are usually shared too: I doubt it's a serious issue.

I would feel more comfortable if you #included linux/pagemap.h
and used the mapping_gfp_mask macro, just for documentation of
what's going on - that's how that field is accessed elsewhere;
though I agree that it looks like gfp_zone() will happen to
work on the raw flags field.

Conversely (why do I suggest safety on one line and unsafety
on another? incorribly inconsistent or what?) I contend that
testing vma->vm_file->f_mapping there is unnecessary, and I'd
rather we don't propagate unnecessary such tests (each one
sows another seed of doubt for the next): sys_fsync looks
like one syscall which would crash if f_mapping ever NULL.

Hugh

> 
> ---
>  include/linux/migrate.h |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> Index: linux-2.6.21-rc7-mm2/include/linux/migrate.h
> ===================================================================
> --- linux-2.6.21-rc7-mm2.orig/include/linux/migrate.h	2007-04-15 16:50:57.000000000 -0700
> +++ linux-2.6.21-rc7-mm2/include/linux/migrate.h	2007-04-27 23:14:49.000000000 -0700
> @@ -2,6 +2,7 @@
>  #define _LINUX_MIGRATE_H
>  
>  #include <linux/mm.h>
> +#include <linux/mempolicy.h>
>  
>  typedef struct page *new_page_t(struct page *, unsigned long private, int **);
>  
> @@ -10,6 +11,14 @@ static inline int vma_migratable(struct 
>  {
>  	if (vma->vm_flags & (VM_IO|VM_HUGETLB|VM_PFNMAP|VM_RESERVED))
>  		return 0;
> +	/*
> +	 * Migration allocates pages in the highest zone. If we cannot
> +	 * do so then migration (at least from node to node) is not
> +	 * possible.
> +	 */
> +	if (vma->vm_file && vma->vm_file->f_mapping &&
> +		gfp_zone(vma->vm_file->f_mapping->flags) < policy_zone)
> +			return 0;
>  	return 1;
>  }
>  

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: page migration: Only migrate pages if allocation in the highest zone is possible
  2007-04-30 11:58 ` Hugh Dickins
@ 2007-04-30 19:20   ` Christoph Lameter
  2007-05-01 13:07     ` Hugh Dickins
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Lameter @ 2007-04-30 19:20 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: akpm, linux-mm

On Mon, 30 Apr 2007, Hugh Dickins wrote:

> That looks about right to me: from the previous discussion it appeared
> that a test in vma_migratable() is currently more appropriate than
> refining the page allocation routines (and yours is nicer than mine).
> Though that will change when page migration is used beyond CONFIG_NUMA.

One can pass a function to page migration functions. If that function
is not doing highest zone allocations based on nodes (for example to move 
pages around in a zone) then we would be fine. Thats why I said the 
"common use of page migration".

> I would feel more comfortable if you #included linux/pagemap.h
> and used the mapping_gfp_mask macro, just for documentation of
> what's going on - that's how that field is accessed elsewhere;
> though I agree that it looks like gfp_zone() will happen to
> work on the raw flags field.

Ok.

> Conversely (why do I suggest safety on one line and unsafety
> on another? incorribly inconsistent or what?) I contend that
> testing vma->vm_file->f_mapping there is unnecessary, and I'd
> rather we don't propagate unnecessary such tests (each one
> sows another seed of doubt for the next): sys_fsync looks
> like one syscall which would crash if f_mapping ever NULL.

I pawned the check off vma_wants_writenotify(). So I am already 
propagating bad habits. sigh.




page migration: Only migrate pages if allocation in the highest zone is possible

Address spaces contain an allocation flag that specifies restriction on
the zone for pages placed in the mapping. I.e. some device may require pages
to be allocated from a DMA zone. Block devices may not be able to use pages
from HIGHMEM.

Memory policies and the common use of page migration works only on the
highest zone. If the address space does not allow allocation from the
highest zone then the pages in the address space are not migratable simply
because we can only allocate memory for a specified node if we allow
allocation for the highest zone on each node.

Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>

---
 include/linux/migrate.h |   11 +++++++++++
 1 file changed, 11 insertions(+)

Index: linux-2.6.21-rc7-mm2/include/linux/migrate.h
===================================================================
--- linux-2.6.21-rc7-mm2.orig/include/linux/migrate.h	2007-04-29 23:58:47.000000000 -0700
+++ linux-2.6.21-rc7-mm2/include/linux/migrate.h	2007-04-30 12:18:41.000000000 -0700
@@ -2,6 +2,8 @@
 #define _LINUX_MIGRATE_H
 
 #include <linux/mm.h>
+#include <linux/mempolicy.h>
+#include <linux/pagemap.h>
 
 typedef struct page *new_page_t(struct page *, unsigned long private, int **);
 
@@ -10,6 +12,15 @@ static inline int vma_migratable(struct 
 {
 	if (vma->vm_flags & (VM_IO|VM_HUGETLB|VM_PFNMAP|VM_RESERVED))
 		return 0;
+	/*
+	 * Migration allocates pages in the highest zone. If we cannot
+	 * do so then migration (at least from node to node) is not
+	 * possible.
+	 */
+	if (vma->vm_file &&
+		gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
+								< policy_zone)
+			return 0;
 	return 1;
 }
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: page migration: Only migrate pages if allocation in the highest zone is possible
  2007-04-30 19:20   ` Christoph Lameter
@ 2007-05-01 13:07     ` Hugh Dickins
  0 siblings, 0 replies; 4+ messages in thread
From: Hugh Dickins @ 2007-05-01 13:07 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm

On Mon, 30 Apr 2007, Christoph Lameter wrote:
> 
> page migration: Only migrate pages if allocation in the highest zone is possible
> 
> Address spaces contain an allocation flag that specifies restriction on
> the zone for pages placed in the mapping. I.e. some device may require pages
> to be allocated from a DMA zone. Block devices may not be able to use pages
> from HIGHMEM.
> 
> Memory policies and the common use of page migration works only on the
> highest zone. If the address space does not allow allocation from the
> highest zone then the pages in the address space are not migratable simply
> because we can only allocate memory for a specified node if we allow
> allocation for the highest zone on each node.
> 
> Cc: Hugh Dickins <hugh@veritas.com>
> Signed-off-by: Christoph Lameter <clameter@sgi.com>

Thanks, Christoph:
Acked-by: Hugh Dickins <hugh@veritas.com>

> 
> ---
>  include/linux/migrate.h |   11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> Index: linux-2.6.21-rc7-mm2/include/linux/migrate.h
> ===================================================================
> --- linux-2.6.21-rc7-mm2.orig/include/linux/migrate.h	2007-04-29 23:58:47.000000000 -0700
> +++ linux-2.6.21-rc7-mm2/include/linux/migrate.h	2007-04-30 12:18:41.000000000 -0700
> @@ -2,6 +2,8 @@
>  #define _LINUX_MIGRATE_H
>  
>  #include <linux/mm.h>
> +#include <linux/mempolicy.h>
> +#include <linux/pagemap.h>
>  
>  typedef struct page *new_page_t(struct page *, unsigned long private, int **);
>  
> @@ -10,6 +12,15 @@ static inline int vma_migratable(struct 
>  {
>  	if (vma->vm_flags & (VM_IO|VM_HUGETLB|VM_PFNMAP|VM_RESERVED))
>  		return 0;
> +	/*
> +	 * Migration allocates pages in the highest zone. If we cannot
> +	 * do so then migration (at least from node to node) is not
> +	 * possible.
> +	 */
> +	if (vma->vm_file &&
> +		gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
> +								< policy_zone)
> +			return 0;
>  	return 1;
>  }
>  

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2007-05-01 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-30  6:17 page migration: Only migrate pages if allocation in the highest zone is possible Christoph Lameter
2007-04-30 11:58 ` Hugh Dickins
2007-04-30 19:20   ` Christoph Lameter
2007-05-01 13:07     ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox