All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact
@ 2016-06-15  9:34 ` Ganesh Mahendran
  0 siblings, 0 replies; 8+ messages in thread
From: Ganesh Mahendran @ 2016-06-15  9:34 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: akpm, vbabka, iamjoonsoo.kim, mhocko, mina86, minchan, khandual,
	Ganesh Mahendran

In the callee try_to_compact_pages(), the (order == 0) is checked,
so remove check in __alloc_pages_direct_compact.

Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
---
v2:
  remove the check in __alloc_pages_direct_compact - Anshuman Khandual
---
 mm/page_alloc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b9ea618..2f5a82a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
 	struct page *page;
 	int contended_compaction;
 
-	if (!order)
-		return NULL;
-
 	current->flags |= PF_MEMALLOC;
 	*compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
 						mode, &contended_compaction);
-- 
1.9.1

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

* [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact
@ 2016-06-15  9:34 ` Ganesh Mahendran
  0 siblings, 0 replies; 8+ messages in thread
From: Ganesh Mahendran @ 2016-06-15  9:34 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: akpm, vbabka, iamjoonsoo.kim, mhocko, mina86, minchan, khandual,
	Ganesh Mahendran

In the callee try_to_compact_pages(), the (order == 0) is checked,
so remove check in __alloc_pages_direct_compact.

Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
---
v2:
  remove the check in __alloc_pages_direct_compact - Anshuman Khandual
---
 mm/page_alloc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b9ea618..2f5a82a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
 	struct page *page;
 	int contended_compaction;
 
-	if (!order)
-		return NULL;
-
 	current->flags |= PF_MEMALLOC;
 	*compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
 						mode, &contended_compaction);
-- 
1.9.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 related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact
  2016-06-15  9:34 ` Ganesh Mahendran
@ 2016-06-15  9:40   ` Balbir Singh
  -1 siblings, 0 replies; 8+ messages in thread
From: Balbir Singh @ 2016-06-15  9:40 UTC (permalink / raw)
  To: Ganesh Mahendran
  Cc: linux-mm, linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Vlastimil Babka, Joonsoo Kim, mhocko, mina86, Minchan Kim,
	Anshuman Khandual

On Wed, Jun 15, 2016 at 7:34 PM, Ganesh Mahendran
<opensource.ganesh@gmail.com> wrote:
> In the callee try_to_compact_pages(), the (order == 0) is checked,
> so remove check in __alloc_pages_direct_compact.
>
> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
> ---
> v2:
>   remove the check in __alloc_pages_direct_compact - Anshuman Khandual
> ---
>  mm/page_alloc.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index b9ea618..2f5a82a 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
>         struct page *page;
>         int contended_compaction;
>
> -       if (!order)
> -               return NULL;
> -
>         current->flags |= PF_MEMALLOC;
>         *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
>                                                 mode, &contended_compaction);

What is the benefit of this. Is an if check more expensive than
calling the function and returning from it? I don't feel strongly
about such changes, but its good to audit the overall code for reading
and performance.

Balbir Singh

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

* Re: [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact
@ 2016-06-15  9:40   ` Balbir Singh
  0 siblings, 0 replies; 8+ messages in thread
From: Balbir Singh @ 2016-06-15  9:40 UTC (permalink / raw)
  To: Ganesh Mahendran
  Cc: linux-mm, linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Vlastimil Babka, Joonsoo Kim, mhocko, mina86, Minchan Kim,
	Anshuman Khandual

On Wed, Jun 15, 2016 at 7:34 PM, Ganesh Mahendran
<opensource.ganesh@gmail.com> wrote:
> In the callee try_to_compact_pages(), the (order == 0) is checked,
> so remove check in __alloc_pages_direct_compact.
>
> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
> ---
> v2:
>   remove the check in __alloc_pages_direct_compact - Anshuman Khandual
> ---
>  mm/page_alloc.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index b9ea618..2f5a82a 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
>         struct page *page;
>         int contended_compaction;
>
> -       if (!order)
> -               return NULL;
> -
>         current->flags |= PF_MEMALLOC;
>         *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
>                                                 mode, &contended_compaction);

What is the benefit of this. Is an if check more expensive than
calling the function and returning from it? I don't feel strongly
about such changes, but its good to audit the overall code for reading
and performance.

Balbir Singh

--
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] 8+ messages in thread

* Re: [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact
  2016-06-15  9:40   ` Balbir Singh
@ 2016-06-15  9:52     ` Vlastimil Babka
  -1 siblings, 0 replies; 8+ messages in thread
From: Vlastimil Babka @ 2016-06-15  9:52 UTC (permalink / raw)
  To: Balbir Singh, Ganesh Mahendran
  Cc: linux-mm, linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Joonsoo Kim, mhocko, mina86, Minchan Kim, Anshuman Khandual

On 06/15/2016 11:40 AM, Balbir Singh wrote:
> On Wed, Jun 15, 2016 at 7:34 PM, Ganesh Mahendran
> <opensource.ganesh@gmail.com> wrote:
>> In the callee try_to_compact_pages(), the (order == 0) is checked,
>> so remove check in __alloc_pages_direct_compact.
>>
>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>> ---
>> v2:
>>   remove the check in __alloc_pages_direct_compact - Anshuman Khandual
>> ---
>>  mm/page_alloc.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index b9ea618..2f5a82a 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
>>         struct page *page;
>>         int contended_compaction;
>>
>> -       if (!order)
>> -               return NULL;
>> -
>>         current->flags |= PF_MEMALLOC;
>>         *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
>>                                                 mode, &contended_compaction);
>
> What is the benefit of this. Is an if check more expensive than
> calling the function and returning from it? I don't feel strongly
> about such changes, but its good to audit the overall code for reading
> and performance.

Agree. The majority of calls should be for order == 0 where the check 
avoids us from modifying current->flags and calling into compaction.c 
just to return and modify the flags back. I would argue that we should 
even check order before calling __alloc_pages_direct_compact() to avoid 
another potential call, but the compiler might be doing the right thing 
already.

So v1 was better in this aspect. But it wouldn't gain us any measurable 
performance benefit anyway, so we might as well leave it.

> Balbir Singh
>

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

* Re: [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact
@ 2016-06-15  9:52     ` Vlastimil Babka
  0 siblings, 0 replies; 8+ messages in thread
From: Vlastimil Babka @ 2016-06-15  9:52 UTC (permalink / raw)
  To: Balbir Singh, Ganesh Mahendran
  Cc: linux-mm, linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Joonsoo Kim, mhocko, mina86, Minchan Kim, Anshuman Khandual

On 06/15/2016 11:40 AM, Balbir Singh wrote:
> On Wed, Jun 15, 2016 at 7:34 PM, Ganesh Mahendran
> <opensource.ganesh@gmail.com> wrote:
>> In the callee try_to_compact_pages(), the (order == 0) is checked,
>> so remove check in __alloc_pages_direct_compact.
>>
>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>> ---
>> v2:
>>   remove the check in __alloc_pages_direct_compact - Anshuman Khandual
>> ---
>>  mm/page_alloc.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index b9ea618..2f5a82a 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
>>         struct page *page;
>>         int contended_compaction;
>>
>> -       if (!order)
>> -               return NULL;
>> -
>>         current->flags |= PF_MEMALLOC;
>>         *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
>>                                                 mode, &contended_compaction);
>
> What is the benefit of this. Is an if check more expensive than
> calling the function and returning from it? I don't feel strongly
> about such changes, but its good to audit the overall code for reading
> and performance.

Agree. The majority of calls should be for order == 0 where the check 
avoids us from modifying current->flags and calling into compaction.c 
just to return and modify the flags back. I would argue that we should 
even check order before calling __alloc_pages_direct_compact() to avoid 
another potential call, but the compiler might be doing the right thing 
already.

So v1 was better in this aspect. But it wouldn't gain us any measurable 
performance benefit anyway, so we might as well leave it.

> Balbir Singh
>

--
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] 8+ messages in thread

* Re: [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact
  2016-06-15  9:40   ` Balbir Singh
@ 2016-06-15 16:41     ` Michal Nazarewicz
  -1 siblings, 0 replies; 8+ messages in thread
From: Michal Nazarewicz @ 2016-06-15 16:41 UTC (permalink / raw)
  To: Balbir Singh, Ganesh Mahendran
  Cc: linux-mm, linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Vlastimil Babka, Joonsoo Kim, mhocko, Minchan Kim,
	Anshuman Khandual

On Wed, Jun 15 2016, Balbir Singh wrote:
> On Wed, Jun 15, 2016 at 7:34 PM, Ganesh Mahendran
> <opensource.ganesh@gmail.com> wrote:
>> In the callee try_to_compact_pages(), the (order == 0) is checked,
>> so remove check in __alloc_pages_direct_compact.
>>
>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>> ---
>> v2:
>>   remove the check in __alloc_pages_direct_compact - Anshuman Khandual
>> ---
>>  mm/page_alloc.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index b9ea618..2f5a82a 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
>>         struct page *page;
>>         int contended_compaction;
>>
>> -       if (!order)
>> -               return NULL;
>> -
>>         current->flags |= PF_MEMALLOC;
>>         *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
>>                                                 mode, &contended_compaction);
>
> What is the benefit of this. Is an if check more expensive than
> calling the function and returning from it? I don't feel strongly
> about such changes, but its good to audit the overall code for reading
> and performance.

It’s a slow path so it probably doesn’t matter much.  But I also don’t
see whether this improves readability of the code.

For performance, I would rather wait for gcc to compile kernel as one
translation unit which will allow it to inline try_to_compact_pages and
notice redundant order==0 check.

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»

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

* Re: [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact
@ 2016-06-15 16:41     ` Michal Nazarewicz
  0 siblings, 0 replies; 8+ messages in thread
From: Michal Nazarewicz @ 2016-06-15 16:41 UTC (permalink / raw)
  To: Balbir Singh, Ganesh Mahendran
  Cc: linux-mm, linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Vlastimil Babka, Joonsoo Kim, mhocko, Minchan Kim,
	Anshuman Khandual

On Wed, Jun 15 2016, Balbir Singh wrote:
> On Wed, Jun 15, 2016 at 7:34 PM, Ganesh Mahendran
> <opensource.ganesh@gmail.com> wrote:
>> In the callee try_to_compact_pages(), the (order == 0) is checked,
>> so remove check in __alloc_pages_direct_compact.
>>
>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>> ---
>> v2:
>>   remove the check in __alloc_pages_direct_compact - Anshuman Khandual
>> ---
>>  mm/page_alloc.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index b9ea618..2f5a82a 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -3173,9 +3173,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
>>         struct page *page;
>>         int contended_compaction;
>>
>> -       if (!order)
>> -               return NULL;
>> -
>>         current->flags |= PF_MEMALLOC;
>>         *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac,
>>                                                 mode, &contended_compaction);
>
> What is the benefit of this. Is an if check more expensive than
> calling the function and returning from it? I don't feel strongly
> about such changes, but its good to audit the overall code for reading
> and performance.

It’s a slow path so it probably doesn’t matter much.  But I also don’t
see whether this improves readability of the code.

For performance, I would rather wait for gcc to compile kernel as one
translation unit which will allow it to inline try_to_compact_pages and
notice redundant order==0 check.

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»

--
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] 8+ messages in thread

end of thread, other threads:[~2016-06-15 16:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-15  9:34 [PATCH v2] mm/page_alloc: remove unnecessary order check in __alloc_pages_direct_compact Ganesh Mahendran
2016-06-15  9:34 ` Ganesh Mahendran
2016-06-15  9:40 ` Balbir Singh
2016-06-15  9:40   ` Balbir Singh
2016-06-15  9:52   ` Vlastimil Babka
2016-06-15  9:52     ` Vlastimil Babka
2016-06-15 16:41   ` Michal Nazarewicz
2016-06-15 16:41     ` Michal Nazarewicz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.