Re: [PATCH 4/4] (CMA_AGGRESSIVE) Update page alloc function

2014-11-27 Thread Hui Zhu
On Fri, Oct 24, 2014 at 1:28 PM, Joonsoo Kim  wrote:
> On Thu, Oct 16, 2014 at 11:35:51AM +0800, Hui Zhu wrote:
>> If page alloc function __rmqueue try to get pages from MIGRATE_MOVABLE and
>> conditions (cma_alloc_counter, cma_aggressive_free_min, cma_alloc_counter)
>> allow, MIGRATE_CMA will be allocated as MIGRATE_MOVABLE first.
>>
>> Signed-off-by: Hui Zhu 
>> ---
>>  mm/page_alloc.c | 42 +++---
>>  1 file changed, 31 insertions(+), 11 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 736d8e1..87bc326 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -65,6 +65,10 @@
>>  #include 
>>  #include "internal.h"
>>
>> +#ifdef CONFIG_CMA_AGGRESSIVE
>> +#include 
>> +#endif
>> +
>>  /* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */
>>  static DEFINE_MUTEX(pcp_batch_high_lock);
>>  #define MIN_PERCPU_PAGELIST_FRACTION (8)
>> @@ -1189,20 +1193,36 @@ static struct page *__rmqueue(struct zone *zone, 
>> unsigned int order,
>>  {
>>   struct page *page;
>>
>> -retry_reserve:
>> +#ifdef CONFIG_CMA_AGGRESSIVE
>> + if (cma_aggressive_switch
>> + && migratetype == MIGRATE_MOVABLE
>> + && atomic_read(_alloc_counter) == 0
>> + && global_page_state(NR_FREE_CMA_PAGES) > cma_aggressive_free_min
>> + + (1 << order))
>> + migratetype = MIGRATE_CMA;
>> +#endif
>> +retry:
>
> I don't get it why cma_alloc_counter should be tested.
> When cma alloc is progress, pageblock is isolated so that pages on that
> pageblock cannot be allocated. Why should we prevent aggressive
> allocation in this case?
>

Hi Joonsoo,

Even if the pageblock is isolated in the begin of function
alloc_contig_range, it will unisolate if alloc_contig_range get some
error for example "PFNs busy".  And the cma_alloc will keep call
alloc_contig_range with another address if need.

So it will decrease the contradiction between CMA allocation in
cma_alloc and __rmqueue with  cma_alloc_counter.

Thanks,
Hui

> Thanks.
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majord...@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: mailto:"d...@kvack.org;> em...@kvack.org 
--
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 4/4] (CMA_AGGRESSIVE) Update page alloc function

2014-11-27 Thread Hui Zhu
On Fri, Oct 24, 2014 at 1:28 PM, Joonsoo Kim iamjoonsoo@lge.com wrote:
 On Thu, Oct 16, 2014 at 11:35:51AM +0800, Hui Zhu wrote:
 If page alloc function __rmqueue try to get pages from MIGRATE_MOVABLE and
 conditions (cma_alloc_counter, cma_aggressive_free_min, cma_alloc_counter)
 allow, MIGRATE_CMA will be allocated as MIGRATE_MOVABLE first.

 Signed-off-by: Hui Zhu zhu...@xiaomi.com
 ---
  mm/page_alloc.c | 42 +++---
  1 file changed, 31 insertions(+), 11 deletions(-)

 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
 index 736d8e1..87bc326 100644
 --- a/mm/page_alloc.c
 +++ b/mm/page_alloc.c
 @@ -65,6 +65,10 @@
  #include asm/div64.h
  #include internal.h

 +#ifdef CONFIG_CMA_AGGRESSIVE
 +#include linux/cma.h
 +#endif
 +
  /* prevent 1 _updater_ of zone percpu pageset -high and -batch fields */
  static DEFINE_MUTEX(pcp_batch_high_lock);
  #define MIN_PERCPU_PAGELIST_FRACTION (8)
 @@ -1189,20 +1193,36 @@ static struct page *__rmqueue(struct zone *zone, 
 unsigned int order,
  {
   struct page *page;

 -retry_reserve:
 +#ifdef CONFIG_CMA_AGGRESSIVE
 + if (cma_aggressive_switch
 +  migratetype == MIGRATE_MOVABLE
 +  atomic_read(cma_alloc_counter) == 0
 +  global_page_state(NR_FREE_CMA_PAGES)  cma_aggressive_free_min
 + + (1  order))
 + migratetype = MIGRATE_CMA;
 +#endif
 +retry:

 I don't get it why cma_alloc_counter should be tested.
 When cma alloc is progress, pageblock is isolated so that pages on that
 pageblock cannot be allocated. Why should we prevent aggressive
 allocation in this case?


Hi Joonsoo,

Even if the pageblock is isolated in the begin of function
alloc_contig_range, it will unisolate if alloc_contig_range get some
error for example PFNs busy.  And the cma_alloc will keep call
alloc_contig_range with another address if need.

So it will decrease the contradiction between CMA allocation in
cma_alloc and __rmqueue with  cma_alloc_counter.

Thanks,
Hui

 Thanks.

 --
 To unsubscribe, send a message with 'unsubscribe linux-mm' in
 the body to majord...@kvack.org.  For more info on Linux MM,
 see: http://www.linux-mm.org/ .
 Don't email: a href=mailto:d...@kvack.org; em...@kvack.org /a
--
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 4/4] (CMA_AGGRESSIVE) Update page alloc function

2014-10-23 Thread Joonsoo Kim
On Thu, Oct 16, 2014 at 11:35:51AM +0800, Hui Zhu wrote:
> If page alloc function __rmqueue try to get pages from MIGRATE_MOVABLE and
> conditions (cma_alloc_counter, cma_aggressive_free_min, cma_alloc_counter)
> allow, MIGRATE_CMA will be allocated as MIGRATE_MOVABLE first.
> 
> Signed-off-by: Hui Zhu 
> ---
>  mm/page_alloc.c | 42 +++---
>  1 file changed, 31 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 736d8e1..87bc326 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -65,6 +65,10 @@
>  #include 
>  #include "internal.h"
>  
> +#ifdef CONFIG_CMA_AGGRESSIVE
> +#include 
> +#endif
> +
>  /* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */
>  static DEFINE_MUTEX(pcp_batch_high_lock);
>  #define MIN_PERCPU_PAGELIST_FRACTION (8)
> @@ -1189,20 +1193,36 @@ static struct page *__rmqueue(struct zone *zone, 
> unsigned int order,
>  {
>   struct page *page;
>  
> -retry_reserve:
> +#ifdef CONFIG_CMA_AGGRESSIVE
> + if (cma_aggressive_switch
> + && migratetype == MIGRATE_MOVABLE
> + && atomic_read(_alloc_counter) == 0
> + && global_page_state(NR_FREE_CMA_PAGES) > cma_aggressive_free_min
> + + (1 << order))
> + migratetype = MIGRATE_CMA;
> +#endif
> +retry:

I don't get it why cma_alloc_counter should be tested.
When cma alloc is progress, pageblock is isolated so that pages on that
pageblock cannot be allocated. Why should we prevent aggressive
allocation in this case?

Thanks.
--
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 4/4] (CMA_AGGRESSIVE) Update page alloc function

2014-10-23 Thread Joonsoo Kim
On Thu, Oct 16, 2014 at 11:35:51AM +0800, Hui Zhu wrote:
 If page alloc function __rmqueue try to get pages from MIGRATE_MOVABLE and
 conditions (cma_alloc_counter, cma_aggressive_free_min, cma_alloc_counter)
 allow, MIGRATE_CMA will be allocated as MIGRATE_MOVABLE first.
 
 Signed-off-by: Hui Zhu zhu...@xiaomi.com
 ---
  mm/page_alloc.c | 42 +++---
  1 file changed, 31 insertions(+), 11 deletions(-)
 
 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
 index 736d8e1..87bc326 100644
 --- a/mm/page_alloc.c
 +++ b/mm/page_alloc.c
 @@ -65,6 +65,10 @@
  #include asm/div64.h
  #include internal.h
  
 +#ifdef CONFIG_CMA_AGGRESSIVE
 +#include linux/cma.h
 +#endif
 +
  /* prevent 1 _updater_ of zone percpu pageset -high and -batch fields */
  static DEFINE_MUTEX(pcp_batch_high_lock);
  #define MIN_PERCPU_PAGELIST_FRACTION (8)
 @@ -1189,20 +1193,36 @@ static struct page *__rmqueue(struct zone *zone, 
 unsigned int order,
  {
   struct page *page;
  
 -retry_reserve:
 +#ifdef CONFIG_CMA_AGGRESSIVE
 + if (cma_aggressive_switch
 +  migratetype == MIGRATE_MOVABLE
 +  atomic_read(cma_alloc_counter) == 0
 +  global_page_state(NR_FREE_CMA_PAGES)  cma_aggressive_free_min
 + + (1  order))
 + migratetype = MIGRATE_CMA;
 +#endif
 +retry:

I don't get it why cma_alloc_counter should be tested.
When cma alloc is progress, pageblock is isolated so that pages on that
pageblock cannot be allocated. Why should we prevent aggressive
allocation in this case?

Thanks.
--
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/


[PATCH 4/4] (CMA_AGGRESSIVE) Update page alloc function

2014-10-15 Thread Hui Zhu
If page alloc function __rmqueue try to get pages from MIGRATE_MOVABLE and
conditions (cma_alloc_counter, cma_aggressive_free_min, cma_alloc_counter)
allow, MIGRATE_CMA will be allocated as MIGRATE_MOVABLE first.

Signed-off-by: Hui Zhu 
---
 mm/page_alloc.c | 42 +++---
 1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 736d8e1..87bc326 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -65,6 +65,10 @@
 #include 
 #include "internal.h"
 
+#ifdef CONFIG_CMA_AGGRESSIVE
+#include 
+#endif
+
 /* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */
 static DEFINE_MUTEX(pcp_batch_high_lock);
 #define MIN_PERCPU_PAGELIST_FRACTION   (8)
@@ -1189,20 +1193,36 @@ static struct page *__rmqueue(struct zone *zone, 
unsigned int order,
 {
struct page *page;
 
-retry_reserve:
+#ifdef CONFIG_CMA_AGGRESSIVE
+   if (cma_aggressive_switch
+   && migratetype == MIGRATE_MOVABLE
+   && atomic_read(_alloc_counter) == 0
+   && global_page_state(NR_FREE_CMA_PAGES) > cma_aggressive_free_min
+   + (1 << order))
+   migratetype = MIGRATE_CMA;
+#endif
+retry:
page = __rmqueue_smallest(zone, order, migratetype);
 
-   if (unlikely(!page) && migratetype != MIGRATE_RESERVE) {
-   page = __rmqueue_fallback(zone, order, migratetype);
+   if (unlikely(!page)) {
+#ifdef CONFIG_CMA_AGGRESSIVE
+   if (migratetype == MIGRATE_CMA) {
+   migratetype = MIGRATE_MOVABLE;
+   goto retry;
+   }
+#endif
+   if (migratetype != MIGRATE_RESERVE) {
+   page = __rmqueue_fallback(zone, order, migratetype);
 
-   /*
-* Use MIGRATE_RESERVE rather than fail an allocation. goto
-* is used because __rmqueue_smallest is an inline function
-* and we want just one call site
-*/
-   if (!page) {
-   migratetype = MIGRATE_RESERVE;
-   goto retry_reserve;
+   /*
+   * Use MIGRATE_RESERVE rather than fail an allocation.
+   * goto is used because __rmqueue_smallest is an inline
+   * function and we want just one call site
+   */
+   if (!page) {
+   migratetype = MIGRATE_RESERVE;
+   goto retry;
+   }
}
}
 
-- 
1.9.1

--
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/


[PATCH 4/4] (CMA_AGGRESSIVE) Update page alloc function

2014-10-15 Thread Hui Zhu
If page alloc function __rmqueue try to get pages from MIGRATE_MOVABLE and
conditions (cma_alloc_counter, cma_aggressive_free_min, cma_alloc_counter)
allow, MIGRATE_CMA will be allocated as MIGRATE_MOVABLE first.

Signed-off-by: Hui Zhu zhu...@xiaomi.com
---
 mm/page_alloc.c | 42 +++---
 1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 736d8e1..87bc326 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -65,6 +65,10 @@
 #include asm/div64.h
 #include internal.h
 
+#ifdef CONFIG_CMA_AGGRESSIVE
+#include linux/cma.h
+#endif
+
 /* prevent 1 _updater_ of zone percpu pageset -high and -batch fields */
 static DEFINE_MUTEX(pcp_batch_high_lock);
 #define MIN_PERCPU_PAGELIST_FRACTION   (8)
@@ -1189,20 +1193,36 @@ static struct page *__rmqueue(struct zone *zone, 
unsigned int order,
 {
struct page *page;
 
-retry_reserve:
+#ifdef CONFIG_CMA_AGGRESSIVE
+   if (cma_aggressive_switch
+migratetype == MIGRATE_MOVABLE
+atomic_read(cma_alloc_counter) == 0
+global_page_state(NR_FREE_CMA_PAGES)  cma_aggressive_free_min
+   + (1  order))
+   migratetype = MIGRATE_CMA;
+#endif
+retry:
page = __rmqueue_smallest(zone, order, migratetype);
 
-   if (unlikely(!page)  migratetype != MIGRATE_RESERVE) {
-   page = __rmqueue_fallback(zone, order, migratetype);
+   if (unlikely(!page)) {
+#ifdef CONFIG_CMA_AGGRESSIVE
+   if (migratetype == MIGRATE_CMA) {
+   migratetype = MIGRATE_MOVABLE;
+   goto retry;
+   }
+#endif
+   if (migratetype != MIGRATE_RESERVE) {
+   page = __rmqueue_fallback(zone, order, migratetype);
 
-   /*
-* Use MIGRATE_RESERVE rather than fail an allocation. goto
-* is used because __rmqueue_smallest is an inline function
-* and we want just one call site
-*/
-   if (!page) {
-   migratetype = MIGRATE_RESERVE;
-   goto retry_reserve;
+   /*
+   * Use MIGRATE_RESERVE rather than fail an allocation.
+   * goto is used because __rmqueue_smallest is an inline
+   * function and we want just one call site
+   */
+   if (!page) {
+   migratetype = MIGRATE_RESERVE;
+   goto retry;
+   }
}
}
 
-- 
1.9.1

--
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/