All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
@ 2015-09-05 14:09 ` Chen Gang
  0 siblings, 0 replies; 13+ messages in thread
From: Chen Gang @ 2015-09-05 14:09 UTC (permalink / raw)
  To: Andrew Morton, kirill.shutemov, riel, Michal Hocko, oleg,
	sasha.levin, pfeiner, aarcange, vishnu.ps, Linux Memory,
	kernel mailing list


>From a1bf4726f71d6d0394b41309944646fc806a8a0c Mon Sep 17 00:00:00 2001
From: Chen Gang <gang.chen.5i5j@gmail.com>
Date: Sat, 5 Sep 2015 21:51:08 +0800
Subject: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in
get_unmapped_area()

Call the function pointer directly, then let code a bit simpler.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 mm/mmap.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 4db7cf0..39fd727 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2012,10 +2012,8 @@ unsigned long
 get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
 		unsigned long pgoff, unsigned long flags)
 {
-	unsigned long (*get_area)(struct file *, unsigned long,
-				  unsigned long, unsigned long, unsigned long);
-
 	unsigned long error = arch_mmap_check(addr, len, flags);
+
 	if (error)
 		return error;
 
@@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
 	if (len> TASK_SIZE)
 		return -ENOMEM;
 
-	get_area = current->mm->get_unmapped_area;
 	if (file && file->f_op->get_unmapped_area)
-		get_area = file->f_op->get_unmapped_area;
-	addr = get_area(file, addr, len, pgoff, flags);
+		addr = file->f_op->get_unmapped_area(file, addr, len,
+							pgoff, flags);
+	else
+		addr = current->mm->get_unmapped_area(file, addr, len,
+							pgoff, flags);
 	if (IS_ERR_VALUE(addr))
 		return addr;
 
-- 
1.9.3

 		 	   		  

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

* [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
@ 2015-09-05 14:09 ` Chen Gang
  0 siblings, 0 replies; 13+ messages in thread
From: Chen Gang @ 2015-09-05 14:09 UTC (permalink / raw)
  To: Andrew Morton, kirill.shutemov, riel, Michal Hocko, oleg,
	sasha.levin, pfeiner, aarcange, vishnu.ps, Linux Memory,
	kernel mailing list


>From a1bf4726f71d6d0394b41309944646fc806a8a0c Mon Sep 17 00:00:00 2001
From: Chen Gang <gang.chen.5i5j@gmail.com>
Date: Sat, 5 Sep 2015 21:51:08 +0800
Subject: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in
get_unmapped_area()

Call the function pointer directly, then let code a bit simpler.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 mm/mmap.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 4db7cf0..39fd727 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2012,10 +2012,8 @@ unsigned long
 get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
 		unsigned long pgoff, unsigned long flags)
 {
-	unsigned long (*get_area)(struct file *, unsigned long,
-				  unsigned long, unsigned long, unsigned long);
-
 	unsigned long error = arch_mmap_check(addr, len, flags);
+
 	if (error)
 		return error;
 
@@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
 	if (len> TASK_SIZE)
 		return -ENOMEM;
 
-	get_area = current->mm->get_unmapped_area;
 	if (file && file->f_op->get_unmapped_area)
-		get_area = file->f_op->get_unmapped_area;
-	addr = get_area(file, addr, len, pgoff, flags);
+		addr = file->f_op->get_unmapped_area(file, addr, len,
+							pgoff, flags);
+	else
+		addr = current->mm->get_unmapped_area(file, addr, len,
+							pgoff, flags);
 	if (IS_ERR_VALUE(addr))
 		return addr;
 
-- 
1.9.3

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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
  2015-09-05 14:09 ` Chen Gang
@ 2015-09-07 12:41   ` Oleg Nesterov
  -1 siblings, 0 replies; 13+ messages in thread
From: Oleg Nesterov @ 2015-09-07 12:41 UTC (permalink / raw)
  To: Chen Gang
  Cc: Andrew Morton, kirill.shutemov, riel, Michal Hocko, sasha.levin,
	pfeiner, aarcange, vishnu.ps, Linux Memory, kernel mailing list

On 09/05, Chen Gang wrote:
>
> From a1bf4726f71d6d0394b41309944646fc806a8a0c Mon Sep 17 00:00:00 2001
> From: Chen Gang <gang.chen.5i5j@gmail.com>
> Date: Sat, 5 Sep 2015 21:51:08 +0800
> Subject: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in
> get_unmapped_area()
>
> Call the function pointer directly, then let code a bit simpler.
                                               ^^^^^^^^^^^^^^^^^^

This is subjective you know ;)

I guess the author of this code added this variable to make the code
more readable. And to me it becomes less readable after your change.

I leave this to you and maintainers.

> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  mm/mmap.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 4db7cf0..39fd727 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2012,10 +2012,8 @@ unsigned long
>  get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>  		unsigned long pgoff, unsigned long flags)
>  {
> -	unsigned long (*get_area)(struct file *, unsigned long,
> -				  unsigned long, unsigned long, unsigned long);
> -
>  	unsigned long error = arch_mmap_check(addr, len, flags);
> +
>  	if (error)
>  		return error;
>  
> @@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>  	if (len> TASK_SIZE)
>  		return -ENOMEM;
>  
> -	get_area = current->mm->get_unmapped_area;
>  	if (file && file->f_op->get_unmapped_area)
> -		get_area = file->f_op->get_unmapped_area;
> -	addr = get_area(file, addr, len, pgoff, flags);
> +		addr = file->f_op->get_unmapped_area(file, addr, len,
> +							pgoff, flags);
> +	else
> +		addr = current->mm->get_unmapped_area(file, addr, len,
> +							pgoff, flags);
>  	if (IS_ERR_VALUE(addr))
>  		return addr;
>  
> -- 
> 1.9.3
> 
>  		 	   		  


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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
@ 2015-09-07 12:41   ` Oleg Nesterov
  0 siblings, 0 replies; 13+ messages in thread
From: Oleg Nesterov @ 2015-09-07 12:41 UTC (permalink / raw)
  To: Chen Gang
  Cc: Andrew Morton, kirill.shutemov, riel, Michal Hocko, sasha.levin,
	pfeiner, aarcange, vishnu.ps, Linux Memory, kernel mailing list

On 09/05, Chen Gang wrote:
>
> From a1bf4726f71d6d0394b41309944646fc806a8a0c Mon Sep 17 00:00:00 2001
> From: Chen Gang <gang.chen.5i5j@gmail.com>
> Date: Sat, 5 Sep 2015 21:51:08 +0800
> Subject: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in
> get_unmapped_area()
>
> Call the function pointer directly, then let code a bit simpler.
                                               ^^^^^^^^^^^^^^^^^^

This is subjective you know ;)

I guess the author of this code added this variable to make the code
more readable. And to me it becomes less readable after your change.

I leave this to you and maintainers.

> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  mm/mmap.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 4db7cf0..39fd727 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2012,10 +2012,8 @@ unsigned long
>  get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>  		unsigned long pgoff, unsigned long flags)
>  {
> -	unsigned long (*get_area)(struct file *, unsigned long,
> -				  unsigned long, unsigned long, unsigned long);
> -
>  	unsigned long error = arch_mmap_check(addr, len, flags);
> +
>  	if (error)
>  		return error;
>  
> @@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>  	if (len> TASK_SIZE)
>  		return -ENOMEM;
>  
> -	get_area = current->mm->get_unmapped_area;
>  	if (file && file->f_op->get_unmapped_area)
> -		get_area = file->f_op->get_unmapped_area;
> -	addr = get_area(file, addr, len, pgoff, flags);
> +		addr = file->f_op->get_unmapped_area(file, addr, len,
> +							pgoff, flags);
> +	else
> +		addr = current->mm->get_unmapped_area(file, addr, len,
> +							pgoff, flags);
>  	if (IS_ERR_VALUE(addr))
>  		return addr;
>  
> -- 
> 1.9.3
> 
>  		 	   		  

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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
       [not found]   ` <55EEEC18.10101@hotmail.com>
@ 2015-09-08 14:09       ` Chen Gang
  0 siblings, 0 replies; 13+ messages in thread
From: Chen Gang @ 2015-09-08 14:09 UTC (permalink / raw)
  To: oleg
  Cc: Andrew Morton, kirill.shutemov, riel, Michal Hocko, sasha.levin,
	pfeiner, aarcange, vishnu.ps, Linux Memory, kernel mailing list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 2502 bytes --]

On 9/7/15 20:41, Oleg Nesterov wrote:
> On 09/05, Chen Gang wrote:
>>
>> From a1bf4726f71d6d0394b41309944646fc806a8a0c Mon Sep 17 00:00:00 2001
>> From: Chen Gang <gang.chen.5i5j@gmail.com>
>> Date: Sat, 5 Sep 2015 21:51:08 +0800
>> Subject: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in
>> get_unmapped_area()
>>
>> Call the function pointer directly, then let code a bit simpler.
> ^^^^^^^^^^^^^^^^^^
>
> This is subjective you know ;)
>

Oh, sorry. The comments need be improved.

> I guess the author of this code added this variable to make the code
> more readable. And to me it becomes less readable after your change.
>
> I leave this to you and maintainers.
>

OK, I can understand, every members have their own taste (my taste is
if one buffering variable is used within 2 times, I want to remove it).

For optimization, the original code maybe be a little better.

So for me, if more than 20% members still like the original code, we
should keep the original code no touch.


Thanks.

>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>> mm/mmap.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/mm/mmap.c b/mm/mmap.c
>> index 4db7cf0..39fd727 100644
>> --- a/mm/mmap.c
>> +++ b/mm/mmap.c
>> @@ -2012,10 +2012,8 @@ unsigned long
>> get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>> unsigned long pgoff, unsigned long flags)
>> {
>> - unsigned long (*get_area)(struct file *, unsigned long,
>> - unsigned long, unsigned long, unsigned long);
>> -
>> unsigned long error = arch_mmap_check(addr, len, flags);
>> +
>> if (error)
>> return error;
>>
>> @@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>> if (len> TASK_SIZE)
>> return -ENOMEM;
>>
>> - get_area = current->mm->get_unmapped_area;
>> if (file && file->f_op->get_unmapped_area)
>> - get_area = file->f_op->get_unmapped_area;
>> - addr = get_area(file, addr, len, pgoff, flags);
>> + addr = file->f_op->get_unmapped_area(file, addr, len,
>> + pgoff, flags);
>> + else
>> + addr = current->mm->get_unmapped_area(file, addr, len,
>> + pgoff, flags);
>> if (IS_ERR_VALUE(addr))
>> return addr;
>>
>> --
>> 1.9.3
>>
>>
>

--
Chen Gang (³Â¸Õ)

Open, share, and attitude like air, water, and life which God blessed
 		 	   		  ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
@ 2015-09-08 14:09       ` Chen Gang
  0 siblings, 0 replies; 13+ messages in thread
From: Chen Gang @ 2015-09-08 14:09 UTC (permalink / raw)
  To: oleg
  Cc: Andrew Morton, kirill.shutemov, riel, Michal Hocko, sasha.levin,
	pfeiner, aarcange, vishnu.ps, Linux Memory, kernel mailing list

On 9/7/15 20:41, Oleg Nesterov wrote:
> On 09/05, Chen Gang wrote:
>>
>> From a1bf4726f71d6d0394b41309944646fc806a8a0c Mon Sep 17 00:00:00 2001
>> From: Chen Gang <gang.chen.5i5j@gmail.com>
>> Date: Sat, 5 Sep 2015 21:51:08 +0800
>> Subject: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in
>> get_unmapped_area()
>>
>> Call the function pointer directly, then let code a bit simpler.
> ^^^^^^^^^^^^^^^^^^
>
> This is subjective you know ;)
>

Oh, sorry. The comments need be improved.

> I guess the author of this code added this variable to make the code
> more readable. And to me it becomes less readable after your change.
>
> I leave this to you and maintainers.
>

OK, I can understand, every members have their own taste (my taste is
if one buffering variable is used within 2 times, I want to remove it).

For optimization, the original code maybe be a little better.

So for me, if more than 20% members still like the original code, we
should keep the original code no touch.


Thanks.

>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>> mm/mmap.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/mm/mmap.c b/mm/mmap.c
>> index 4db7cf0..39fd727 100644
>> --- a/mm/mmap.c
>> +++ b/mm/mmap.c
>> @@ -2012,10 +2012,8 @@ unsigned long
>> get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>> unsigned long pgoff, unsigned long flags)
>> {
>> - unsigned long (*get_area)(struct file *, unsigned long,
>> - unsigned long, unsigned long, unsigned long);
>> -
>> unsigned long error = arch_mmap_check(addr, len, flags);
>> +
>> if (error)
>> return error;
>>
>> @@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>> if (len> TASK_SIZE)
>> return -ENOMEM;
>>
>> - get_area = current->mm->get_unmapped_area;
>> if (file && file->f_op->get_unmapped_area)
>> - get_area = file->f_op->get_unmapped_area;
>> - addr = get_area(file, addr, len, pgoff, flags);
>> + addr = file->f_op->get_unmapped_area(file, addr, len,
>> + pgoff, flags);
>> + else
>> + addr = current->mm->get_unmapped_area(file, addr, len,
>> + pgoff, flags);
>> if (IS_ERR_VALUE(addr))
>> return addr;
>>
>> --
>> 1.9.3
>>
>>
>

--
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed
 		 	   		  

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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
  2015-09-05 14:09 ` Chen Gang
@ 2015-09-08 23:23   ` David Rientjes
  -1 siblings, 0 replies; 13+ messages in thread
From: David Rientjes @ 2015-09-08 23:23 UTC (permalink / raw)
  To: Chen Gang
  Cc: Andrew Morton, kirill.shutemov, riel, Michal Hocko, oleg,
	sasha.levin, pfeiner, aarcange, vishnu.ps, Linux Memory,
	kernel mailing list

On Sat, 5 Sep 2015, Chen Gang wrote:

> 
> From a1bf4726f71d6d0394b41309944646fc806a8a0c Mon Sep 17 00:00:00 2001
> From: Chen Gang <gang.chen.5i5j@gmail.com>
> Date: Sat, 5 Sep 2015 21:51:08 +0800
> Subject: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in
> get_unmapped_area()
> 
> Call the function pointer directly, then let code a bit simpler.
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>

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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
@ 2015-09-08 23:23   ` David Rientjes
  0 siblings, 0 replies; 13+ messages in thread
From: David Rientjes @ 2015-09-08 23:23 UTC (permalink / raw)
  To: Chen Gang
  Cc: Andrew Morton, kirill.shutemov, riel, Michal Hocko, oleg,
	sasha.levin, pfeiner, aarcange, vishnu.ps, Linux Memory,
	kernel mailing list

On Sat, 5 Sep 2015, Chen Gang wrote:

> 
> From a1bf4726f71d6d0394b41309944646fc806a8a0c Mon Sep 17 00:00:00 2001
> From: Chen Gang <gang.chen.5i5j@gmail.com>
> Date: Sat, 5 Sep 2015 21:51:08 +0800
> Subject: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in
> get_unmapped_area()
> 
> Call the function pointer directly, then let code a bit simpler.
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>

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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
  2015-09-10 22:32   ` Andrew Morton
@ 2015-09-11 23:52     ` Chen Gang
  -1 siblings, 0 replies; 13+ messages in thread
From: Chen Gang @ 2015-09-11 23:52 UTC (permalink / raw)
  To: Andrew Morton, gang.chen.5i5j; +Cc: mhocko, linux-mm, linux-kernel

On 9/11/15 06:32, Andrew Morton wrote:
> On Thu,  3 Sep 2015 12:14:51 +0800 gang.chen.5i5j@gmail.com wrote:
> 
> size(1) says this generates more object code.  And that probably means
> slightly worse code.  I didn't investigate, but probably the compiler
> is now preparing those five args at two different sites.
> 
> Which is pretty dumb of it - the compiler could have stacked the args
> first, then chosen the appropriate function to call.
> 

For get_unmapped_area() under x86_64, all 5 args are in registers, also
file->f_op->get_unmapped_area and current->mm->get_unmapped_area args
are same as get_unmapped_area(), which called directly (no new insns).

For me I am not quite sure which performance is better (So originally,
I said, "if orig code has a bit better performance, also if more than
20% taste orig code simple enough, we can keep it no touch").

 - New size is a little smaller than orig size.

 - But new insns is a little more than orig insns (x86_64 is not fix
   wide insns).

For me, I guess, new code is a bit better than orig code: for normal
sequence insns, 'size' is more important than insns count (at least, it
is more clearer than insns count).

The related dump (build by gcc6):

  [root@localhost mm]# size mmap.new.o
     text	   data	    bss	    dec	    hex	filename
    17597	    266	     40	  17903	   45ef	mmap.new.o
  [root@localhost mm]# size mmap.orig.o
     text	   data	    bss	    dec	    hex	filename
    17613	    266	     40	  17919	   45ff	mmap.orig.o

  objdump for mmap.orig.s:

    00000000000004d0 <get_unmapped_area>:
         4d0:       55                      push   %rbp
         4d1:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         4d8:       00 00 
         4da:       48 89 e5                mov    %rsp,%rbp
         4dd:       41 54                   push   %r12
         4df:       53                      push   %rbx
         4e0:       4c 8b 88 08 c0 ff ff    mov    -0x3ff8(%rax),%r9
         4e7:       48 b8 00 f0 ff ff ff    movabs $0x7ffffffff000,%rax
         4ee:       7f 00 00 
         4f1:       41 f7 c1 00 00 00 20    test   $0x20000000,%r9d
         4f8:       74 1f                   je     519 <get_unmapped_area+0x49>
         4fa:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         501:       00 00 
         503:       f6 80 cb 03 00 00 08    testb  $0x8,0x3cb(%rax)
         50a:       41 b9 00 e0 ff ff       mov    $0xffffe000,%r9d
         510:       b8 00 00 00 c0          mov    $0xc0000000,%eax
         515:       49 0f 44 c1             cmove  %r9,%rax
         519:       48 39 d0                cmp    %rdx,%rax
         51c:       73 0f                   jae    52d <get_unmapped_area+0x5d>
         51e:       48 c7 c3 f4 ff ff ff    mov    $0xfffffffffffffff4,%rbx
         525:       48 89 d8                mov    %rbx,%rax
         528:       5b                      pop    %rbx
         529:       41 5c                   pop    %r12
         52b:       5d                      pop    %rbp
         52c:       c3                      retq
    
    
         52d:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         534:       00 00 
         536:       48 8b 80 68 03 00 00    mov    0x368(%rax),%rax
         53d:       48 85 ff                test   %rdi,%rdi
         540:       4c 8b 48 18             mov    0x18(%rax),%r9
         544:       0f 84 82 00 00 00       je     5cc <get_unmapped_area+0xfc>
         54a:       48 8b 47 28             mov    0x28(%rdi),%rax
         54e:       48 8b 80 98 00 00 00    mov    0x98(%rax),%rax
         555:       48 85 c0                test   %rax,%rax
         558:       49 0f 44 c1             cmove  %r9,%rax
         55c:       49 89 d4                mov    %rdx,%r12
         55f:       ff d0                   callq  *%rax
         561:       48 3d 00 f0 ff ff       cmp    $0xfffffffffffff000,%rax
         567:       48 89 c3                mov    %rax,%rbx
         56a:       77 b9                   ja     525 <get_unmapped_area+0x55>
         56c:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         573:       00 00 
         575:       48 8b 90 08 c0 ff ff    mov    -0x3ff8(%rax),%rdx
         57c:       48 b8 00 f0 ff ff ff    movabs $0x7ffffffff000,%rax
         583:       7f 00 00 
         586:       f7 c2 00 00 00 20       test   $0x20000000,%edx
         58c:       74 1e                   je     5ac <get_unmapped_area+0xdc>
         58e:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         595:       00 00 
         597:       f6 80 cb 03 00 00 08    testb  $0x8,0x3cb(%rax)
         59e:       ba 00 e0 ff ff          mov    $0xffffe000,%edx
         5a3:       b8 00 00 00 c0          mov    $0xc0000000,%eax
         5a8:       48 0f 44 c2             cmove  %rdx,%rax
         5ac:       4c 29 e0                sub    %r12,%rax
         5af:       48 39 c3                cmp    %rax,%rbx
         5b2:       0f 87 66 ff ff ff       ja     51e <get_unmapped_area+0x4e>
         5b8:       f7 c3 ff 0f 00 00       test   $0xfff,%ebx
         5be:       74 11                   je     5d1 <get_unmapped_area+0x101>
         5c0:       48 c7 c3 ea ff ff ff    mov    $0xffffffffffffffea,%rbx
         5c7:       e9 59 ff ff ff          jmpq   525 <get_unmapped_area+0x55>
    
    
         5cc:       4c 89 c8                mov    %r9,%rax
         5cf:       eb 8b                   jmp    55c <get_unmapped_area+0x8c>
         5d1:       48 89 df                mov    %rbx,%rdi
         5d4:       e8 00 00 00 00          callq  5d9 <get_unmapped_area+0x109>
         5d9:       48 98                   cltq
         5db:       48 85 c0                test   %rax,%rax
         5de:       48 0f 45 d8             cmovne %rax,%rbx
         5e2:       e9 3e ff ff ff          jmpq   525 <get_unmapped_area+0x55>


         5e7:       66 0f 1f 84 00 00 00    nopw   0x0(%rax,%rax,1)
         5ee:       00 00                                        


  objdump for mmap.new.s

    00000000000004d0 <get_unmapped_area>:
         4d0:       55                      push   %rbp
         4d1:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         4d8:       00 00 
         4da:       48 89 e5                mov    %rsp,%rbp
         4dd:       41 54                   push   %r12
         4df:       53                      push   %rbx
         4e0:       4c 8b 88 08 c0 ff ff    mov    -0x3ff8(%rax),%r9
         4e7:       48 b8 00 f0 ff ff ff    movabs $0x7ffffffff000,%rax
         4ee:       7f 00 00 
         4f1:       41 f7 c1 00 00 00 20    test   $0x20000000,%r9d
         4f8:       74 1f                   je     519 <get_unmapped_area+0x49>
         4fa:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         501:       00 00 
         503:       f6 80 cb 03 00 00 08    testb  $0x8,0x3cb(%rax)
         50a:       41 b9 00 e0 ff ff       mov    $0xffffe000,%r9d
         510:       b8 00 00 00 c0          mov    $0xc0000000,%eax
         515:       49 0f 44 c1             cmove  %r9,%rax
         519:       48 39 d0                cmp    %rdx,%rax
         51c:       73 0f                   jae    52d <get_unmapped_area+0x5d>
         51e:       48 c7 c3 f4 ff ff ff    mov    $0xfffffffffffffff4,%rbx
    
         525:       48 89 d8                mov    %rbx,%rax
         528:       5b                      pop    %rbx
         529:       41 5c                   pop    %r12
         52b:       5d                      pop    %rbp
         52c:       c3                      retq
    
    
         52d:       48 85 ff                test   %rdi,%rdi
         530:       49 89 d4                mov    %rdx,%r12
         533:       74 7a                   je     5af <get_unmapped_area+0xdf>
         535:       48 8b 47 28             mov    0x28(%rdi),%rax
         539:       48 8b 80 98 00 00 00    mov    0x98(%rax),%rax
         540:       48 85 c0                test   %rax,%rax
         543:       74 6a                   je     5af <get_unmapped_area+0xdf>
         545:       ff d0                   callq  *%rax
         547:       48 89 c3                mov    %rax,%rbx
         54a:       48 81 fb 00 f0 ff ff    cmp    $0xfffffffffffff000,%rbx
         551:       77 d2                   ja     525 <get_unmapped_area+0x55>
         553:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         55a:       00 00 
         55c:       48 8b 90 08 c0 ff ff    mov    -0x3ff8(%rax),%rdx
         563:       48 b8 00 f0 ff ff ff    movabs $0x7ffffffff000,%rax
         56a:       7f 00 00 
         56d:       f7 c2 00 00 00 20       test   $0x20000000,%edx
         573:       74 1e                   je     593 <get_unmapped_area+0xc3>
         575:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         57c:       00 00 
         57e:       f6 80 cb 03 00 00 08    testb  $0x8,0x3cb(%rax)
         585:       ba 00 e0 ff ff          mov    $0xffffe000,%edx
         58a:       b8 00 00 00 c0          mov    $0xc0000000,%eax
         58f:       48 0f 44 c2             cmove  %rdx,%rax
         593:       4c 29 e0                sub    %r12,%rax
         596:       48 39 c3                cmp    %rax,%rbx
         599:       77 83                   ja     51e <get_unmapped_area+0x4e>
         59b:       f7 c3 ff 0f 00 00       test   $0xfff,%ebx
         5a1:       74 27                   je     5ca <get_unmapped_area+0xfa>
         5a3:       48 c7 c3 ea ff ff ff    mov    $0xffffffffffffffea,%rbx
         5aa:       e9 76 ff ff ff          jmpq   525 <get_unmapped_area+0x55>
         5af:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         5b6:       00 00 
         5b8:       48 8b 80 68 03 00 00    mov    0x368(%rax),%rax
         5bf:       4c 89 e2                mov    %r12,%rdx
         5c2:       ff 50 18                callq  *0x18(%rax)
    
    
         5c5:       48 89 c3                mov    %rax,%rbx
         5c8:       eb 80                   jmp    54a <get_unmapped_area+0x7a>
         5ca:       48 89 df                mov    %rbx,%rdi
         5cd:       e8 00 00 00 00          callq  5d2 <get_unmapped_area+0x102>
         5d2:       48 98                   cltq
         5d4:       48 85 c0                test   %rax,%rax
         5d7:       48 0f 45 d8             cmovne %rax,%rbx
         5db:       e9 45 ff ff ff          jmpq   525 <get_unmapped_area+0x55>


Thanks.
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
@ 2015-09-11 23:52     ` Chen Gang
  0 siblings, 0 replies; 13+ messages in thread
From: Chen Gang @ 2015-09-11 23:52 UTC (permalink / raw)
  To: Andrew Morton, gang.chen.5i5j; +Cc: mhocko, linux-mm, linux-kernel

On 9/11/15 06:32, Andrew Morton wrote:
> On Thu,  3 Sep 2015 12:14:51 +0800 gang.chen.5i5j@gmail.com wrote:
> 
> size(1) says this generates more object code.  And that probably means
> slightly worse code.  I didn't investigate, but probably the compiler
> is now preparing those five args at two different sites.
> 
> Which is pretty dumb of it - the compiler could have stacked the args
> first, then chosen the appropriate function to call.
> 

For get_unmapped_area() under x86_64, all 5 args are in registers, also
file->f_op->get_unmapped_area and current->mm->get_unmapped_area args
are same as get_unmapped_area(), which called directly (no new insns).

For me I am not quite sure which performance is better (So originally,
I said, "if orig code has a bit better performance, also if more than
20% taste orig code simple enough, we can keep it no touch").

 - New size is a little smaller than orig size.

 - But new insns is a little more than orig insns (x86_64 is not fix
   wide insns).

For me, I guess, new code is a bit better than orig code: for normal
sequence insns, 'size' is more important than insns count (at least, it
is more clearer than insns count).

The related dump (build by gcc6):

  [root@localhost mm]# size mmap.new.o
     text	   data	    bss	    dec	    hex	filename
    17597	    266	     40	  17903	   45ef	mmap.new.o
  [root@localhost mm]# size mmap.orig.o
     text	   data	    bss	    dec	    hex	filename
    17613	    266	     40	  17919	   45ff	mmap.orig.o

  objdump for mmap.orig.s:

    00000000000004d0 <get_unmapped_area>:
         4d0:       55                      push   %rbp
         4d1:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         4d8:       00 00 
         4da:       48 89 e5                mov    %rsp,%rbp
         4dd:       41 54                   push   %r12
         4df:       53                      push   %rbx
         4e0:       4c 8b 88 08 c0 ff ff    mov    -0x3ff8(%rax),%r9
         4e7:       48 b8 00 f0 ff ff ff    movabs $0x7ffffffff000,%rax
         4ee:       7f 00 00 
         4f1:       41 f7 c1 00 00 00 20    test   $0x20000000,%r9d
         4f8:       74 1f                   je     519 <get_unmapped_area+0x49>
         4fa:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         501:       00 00 
         503:       f6 80 cb 03 00 00 08    testb  $0x8,0x3cb(%rax)
         50a:       41 b9 00 e0 ff ff       mov    $0xffffe000,%r9d
         510:       b8 00 00 00 c0          mov    $0xc0000000,%eax
         515:       49 0f 44 c1             cmove  %r9,%rax
         519:       48 39 d0                cmp    %rdx,%rax
         51c:       73 0f                   jae    52d <get_unmapped_area+0x5d>
         51e:       48 c7 c3 f4 ff ff ff    mov    $0xfffffffffffffff4,%rbx
         525:       48 89 d8                mov    %rbx,%rax
         528:       5b                      pop    %rbx
         529:       41 5c                   pop    %r12
         52b:       5d                      pop    %rbp
         52c:       c3                      retq
    
    
         52d:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         534:       00 00 
         536:       48 8b 80 68 03 00 00    mov    0x368(%rax),%rax
         53d:       48 85 ff                test   %rdi,%rdi
         540:       4c 8b 48 18             mov    0x18(%rax),%r9
         544:       0f 84 82 00 00 00       je     5cc <get_unmapped_area+0xfc>
         54a:       48 8b 47 28             mov    0x28(%rdi),%rax
         54e:       48 8b 80 98 00 00 00    mov    0x98(%rax),%rax
         555:       48 85 c0                test   %rax,%rax
         558:       49 0f 44 c1             cmove  %r9,%rax
         55c:       49 89 d4                mov    %rdx,%r12
         55f:       ff d0                   callq  *%rax
         561:       48 3d 00 f0 ff ff       cmp    $0xfffffffffffff000,%rax
         567:       48 89 c3                mov    %rax,%rbx
         56a:       77 b9                   ja     525 <get_unmapped_area+0x55>
         56c:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         573:       00 00 
         575:       48 8b 90 08 c0 ff ff    mov    -0x3ff8(%rax),%rdx
         57c:       48 b8 00 f0 ff ff ff    movabs $0x7ffffffff000,%rax
         583:       7f 00 00 
         586:       f7 c2 00 00 00 20       test   $0x20000000,%edx
         58c:       74 1e                   je     5ac <get_unmapped_area+0xdc>
         58e:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         595:       00 00 
         597:       f6 80 cb 03 00 00 08    testb  $0x8,0x3cb(%rax)
         59e:       ba 00 e0 ff ff          mov    $0xffffe000,%edx
         5a3:       b8 00 00 00 c0          mov    $0xc0000000,%eax
         5a8:       48 0f 44 c2             cmove  %rdx,%rax
         5ac:       4c 29 e0                sub    %r12,%rax
         5af:       48 39 c3                cmp    %rax,%rbx
         5b2:       0f 87 66 ff ff ff       ja     51e <get_unmapped_area+0x4e>
         5b8:       f7 c3 ff 0f 00 00       test   $0xfff,%ebx
         5be:       74 11                   je     5d1 <get_unmapped_area+0x101>
         5c0:       48 c7 c3 ea ff ff ff    mov    $0xffffffffffffffea,%rbx
         5c7:       e9 59 ff ff ff          jmpq   525 <get_unmapped_area+0x55>
    
    
         5cc:       4c 89 c8                mov    %r9,%rax
         5cf:       eb 8b                   jmp    55c <get_unmapped_area+0x8c>
         5d1:       48 89 df                mov    %rbx,%rdi
         5d4:       e8 00 00 00 00          callq  5d9 <get_unmapped_area+0x109>
         5d9:       48 98                   cltq
         5db:       48 85 c0                test   %rax,%rax
         5de:       48 0f 45 d8             cmovne %rax,%rbx
         5e2:       e9 3e ff ff ff          jmpq   525 <get_unmapped_area+0x55>


         5e7:       66 0f 1f 84 00 00 00    nopw   0x0(%rax,%rax,1)
         5ee:       00 00                                        


  objdump for mmap.new.s

    00000000000004d0 <get_unmapped_area>:
         4d0:       55                      push   %rbp
         4d1:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         4d8:       00 00 
         4da:       48 89 e5                mov    %rsp,%rbp
         4dd:       41 54                   push   %r12
         4df:       53                      push   %rbx
         4e0:       4c 8b 88 08 c0 ff ff    mov    -0x3ff8(%rax),%r9
         4e7:       48 b8 00 f0 ff ff ff    movabs $0x7ffffffff000,%rax
         4ee:       7f 00 00 
         4f1:       41 f7 c1 00 00 00 20    test   $0x20000000,%r9d
         4f8:       74 1f                   je     519 <get_unmapped_area+0x49>
         4fa:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         501:       00 00 
         503:       f6 80 cb 03 00 00 08    testb  $0x8,0x3cb(%rax)
         50a:       41 b9 00 e0 ff ff       mov    $0xffffe000,%r9d
         510:       b8 00 00 00 c0          mov    $0xc0000000,%eax
         515:       49 0f 44 c1             cmove  %r9,%rax
         519:       48 39 d0                cmp    %rdx,%rax
         51c:       73 0f                   jae    52d <get_unmapped_area+0x5d>
         51e:       48 c7 c3 f4 ff ff ff    mov    $0xfffffffffffffff4,%rbx
    
         525:       48 89 d8                mov    %rbx,%rax
         528:       5b                      pop    %rbx
         529:       41 5c                   pop    %r12
         52b:       5d                      pop    %rbp
         52c:       c3                      retq
    
    
         52d:       48 85 ff                test   %rdi,%rdi
         530:       49 89 d4                mov    %rdx,%r12
         533:       74 7a                   je     5af <get_unmapped_area+0xdf>
         535:       48 8b 47 28             mov    0x28(%rdi),%rax
         539:       48 8b 80 98 00 00 00    mov    0x98(%rax),%rax
         540:       48 85 c0                test   %rax,%rax
         543:       74 6a                   je     5af <get_unmapped_area+0xdf>
         545:       ff d0                   callq  *%rax
         547:       48 89 c3                mov    %rax,%rbx
         54a:       48 81 fb 00 f0 ff ff    cmp    $0xfffffffffffff000,%rbx
         551:       77 d2                   ja     525 <get_unmapped_area+0x55>
         553:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         55a:       00 00 
         55c:       48 8b 90 08 c0 ff ff    mov    -0x3ff8(%rax),%rdx
         563:       48 b8 00 f0 ff ff ff    movabs $0x7ffffffff000,%rax
         56a:       7f 00 00 
         56d:       f7 c2 00 00 00 20       test   $0x20000000,%edx
         573:       74 1e                   je     593 <get_unmapped_area+0xc3>
         575:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         57c:       00 00 
         57e:       f6 80 cb 03 00 00 08    testb  $0x8,0x3cb(%rax)
         585:       ba 00 e0 ff ff          mov    $0xffffe000,%edx
         58a:       b8 00 00 00 c0          mov    $0xc0000000,%eax
         58f:       48 0f 44 c2             cmove  %rdx,%rax
         593:       4c 29 e0                sub    %r12,%rax
         596:       48 39 c3                cmp    %rax,%rbx
         599:       77 83                   ja     51e <get_unmapped_area+0x4e>
         59b:       f7 c3 ff 0f 00 00       test   $0xfff,%ebx
         5a1:       74 27                   je     5ca <get_unmapped_area+0xfa>
         5a3:       48 c7 c3 ea ff ff ff    mov    $0xffffffffffffffea,%rbx
         5aa:       e9 76 ff ff ff          jmpq   525 <get_unmapped_area+0x55>
         5af:       65 48 8b 04 25 00 00    mov    %gs:0x0,%rax
         5b6:       00 00 
         5b8:       48 8b 80 68 03 00 00    mov    0x368(%rax),%rax
         5bf:       4c 89 e2                mov    %r12,%rdx
         5c2:       ff 50 18                callq  *0x18(%rax)
    
    
         5c5:       48 89 c3                mov    %rax,%rbx
         5c8:       eb 80                   jmp    54a <get_unmapped_area+0x7a>
         5ca:       48 89 df                mov    %rbx,%rdi
         5cd:       e8 00 00 00 00          callq  5d2 <get_unmapped_area+0x102>
         5d2:       48 98                   cltq
         5d4:       48 85 c0                test   %rax,%rax
         5d7:       48 0f 45 d8             cmovne %rax,%rbx
         5db:       e9 45 ff ff ff          jmpq   525 <get_unmapped_area+0x55>


Thanks.
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
  2015-09-03  4:14 gang.chen.5i5j
@ 2015-09-10 22:32   ` Andrew Morton
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Morton @ 2015-09-10 22:32 UTC (permalink / raw)
  To: gang.chen.5i5j; +Cc: mhocko, linux-mm, linux-kernel, gchen_5i5j

On Thu,  3 Sep 2015 12:14:51 +0800 gang.chen.5i5j@gmail.com wrote:

> From: Chen Gang <gang.chen.5i5j@gmail.com>
> 
> Call the function pointer directly, then let code a bit simpler.
> 
> ...
>
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2012,10 +2012,8 @@ unsigned long
>  get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>  		unsigned long pgoff, unsigned long flags)
>  {
> -	unsigned long (*get_area)(struct file *, unsigned long,
> -				  unsigned long, unsigned long, unsigned long);
> -
>  	unsigned long error = arch_mmap_check(addr, len, flags);
> +
>  	if (error)
>  		return error;
>  
> @@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>  	if (len > TASK_SIZE)
>  		return -ENOMEM;
>  
> -	get_area = current->mm->get_unmapped_area;
>  	if (file && file->f_op->get_unmapped_area)
> -		get_area = file->f_op->get_unmapped_area;
> -	addr = get_area(file, addr, len, pgoff, flags);
> +		addr = file->f_op->get_unmapped_area(file, addr, len,
> +							pgoff, flags);
> +	else
> +		addr = current->mm->get_unmapped_area(file, addr, len,
> +							pgoff, flags);
>  	if (IS_ERR_VALUE(addr))
>  		return addr;

size(1) says this generates more object code.  And that probably means
slightly worse code.  I didn't investigate, but probably the compiler
is now preparing those five args at two different sites.

Which is pretty dumb of it - the compiler could have stacked the args
first, then chosen the appropriate function to call.


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

* Re: [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
@ 2015-09-10 22:32   ` Andrew Morton
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Morton @ 2015-09-10 22:32 UTC (permalink / raw)
  To: gang.chen.5i5j; +Cc: mhocko, linux-mm, linux-kernel, gchen_5i5j

On Thu,  3 Sep 2015 12:14:51 +0800 gang.chen.5i5j@gmail.com wrote:

> From: Chen Gang <gang.chen.5i5j@gmail.com>
> 
> Call the function pointer directly, then let code a bit simpler.
> 
> ...
>
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2012,10 +2012,8 @@ unsigned long
>  get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>  		unsigned long pgoff, unsigned long flags)
>  {
> -	unsigned long (*get_area)(struct file *, unsigned long,
> -				  unsigned long, unsigned long, unsigned long);
> -
>  	unsigned long error = arch_mmap_check(addr, len, flags);
> +
>  	if (error)
>  		return error;
>  
> @@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
>  	if (len > TASK_SIZE)
>  		return -ENOMEM;
>  
> -	get_area = current->mm->get_unmapped_area;
>  	if (file && file->f_op->get_unmapped_area)
> -		get_area = file->f_op->get_unmapped_area;
> -	addr = get_area(file, addr, len, pgoff, flags);
> +		addr = file->f_op->get_unmapped_area(file, addr, len,
> +							pgoff, flags);
> +	else
> +		addr = current->mm->get_unmapped_area(file, addr, len,
> +							pgoff, flags);
>  	if (IS_ERR_VALUE(addr))
>  		return addr;

size(1) says this generates more object code.  And that probably means
slightly worse code.  I didn't investigate, but probably the compiler
is now preparing those five args at two different sites.

Which is pretty dumb of it - the compiler could have stacked the args
first, then chosen the appropriate function to call.

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

* [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area()
@ 2015-09-03  4:14 gang.chen.5i5j
  2015-09-10 22:32   ` Andrew Morton
  0 siblings, 1 reply; 13+ messages in thread
From: gang.chen.5i5j @ 2015-09-03  4:14 UTC (permalink / raw)
  To: akpm, mhocko; +Cc: linux-mm, linux-kernel, gchen_5i5j, Chen Gang

From: Chen Gang <gang.chen.5i5j@gmail.com>

Call the function pointer directly, then let code a bit simpler.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 mm/mmap.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 4db7cf0..39fd727 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2012,10 +2012,8 @@ unsigned long
 get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
 		unsigned long pgoff, unsigned long flags)
 {
-	unsigned long (*get_area)(struct file *, unsigned long,
-				  unsigned long, unsigned long, unsigned long);
-
 	unsigned long error = arch_mmap_check(addr, len, flags);
+
 	if (error)
 		return error;
 
@@ -2023,10 +2021,12 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 
-	get_area = current->mm->get_unmapped_area;
 	if (file && file->f_op->get_unmapped_area)
-		get_area = file->f_op->get_unmapped_area;
-	addr = get_area(file, addr, len, pgoff, flags);
+		addr = file->f_op->get_unmapped_area(file, addr, len,
+							pgoff, flags);
+	else
+		addr = current->mm->get_unmapped_area(file, addr, len,
+							pgoff, flags);
 	if (IS_ERR_VALUE(addr))
 		return addr;
 
-- 
1.9.3

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

end of thread, other threads:[~2015-09-11 23:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-05 14:09 [PATCH] mm/mmap.c: Remove redundent 'get_area' function pointer in get_unmapped_area() Chen Gang
2015-09-05 14:09 ` Chen Gang
2015-09-07 12:41 ` Oleg Nesterov
2015-09-07 12:41   ` Oleg Nesterov
     [not found]   ` <55EEEC18.10101@hotmail.com>
2015-09-08 14:09     ` Chen Gang
2015-09-08 14:09       ` Chen Gang
2015-09-08 23:23 ` David Rientjes
2015-09-08 23:23   ` David Rientjes
  -- strict thread matches above, loose matches on Subject: below --
2015-09-03  4:14 gang.chen.5i5j
2015-09-10 22:32 ` Andrew Morton
2015-09-10 22:32   ` Andrew Morton
2015-09-11 23:52   ` Chen Gang
2015-09-11 23:52     ` Chen Gang

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.