All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: code improvement of check_stack_guard_page
       [not found] <AANLkTinfgXOzbqgrRY4oCGXFtKtEyJO_rvQeeEEeEZz7@mail.gmail.com>
@ 2010-08-15  5:15 ` jovi zhang
  2010-08-15 17:58   ` Linus Torvalds
  2010-08-18  6:10   ` Balbir Singh
  2010-08-18  2:02   ` KAMEZAWA Hiroyuki
  1 sibling, 2 replies; 6+ messages in thread
From: jovi zhang @ 2010-08-15  5:15 UTC (permalink / raw)
  To: linux-kernel

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

little code improvement of check_stack_guard_page function.
this commit is on top of commit "mm: keep a guard page below a
grow-down stack segment" of linus.

diff --git a/mm/memory.c b/mm/memory.c
index 9b3b73f..643b112 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2768,13 +2768,15 @@ out_release:
  */
 static inline int check_stack_guard_page(struct vm_area_struct *vma,
unsigned long address)
 {
-       address &= PAGE_MASK;
-       if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
-               address -= PAGE_SIZE;
-               if (find_vma(vma->vm_mm, address) != vma)
-                       return -ENOMEM;
-
-               expand_stack(vma, address);
+       if (vma->vm_flags & VM_GROWSDOWN) {
+               address &= PAGE_MASK;
+               if(address == vma->vm_start) {
+                       address -= PAGE_SIZE;
+                       if (unlikely(find_vma(vma->vm_mm, address) != vma))
+                               return -ENOMEM;
+
+                       expand_stack(vma, address);
+               }
        }
        return 0;
 }
ÿôèº{.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 related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: code improvement of check_stack_guard_page
  2010-08-15  5:15 ` [PATCH] mm: code improvement of check_stack_guard_page jovi zhang
@ 2010-08-15 17:58   ` Linus Torvalds
  2010-08-16  1:32     ` jovi zhang
  2010-08-18  6:10   ` Balbir Singh
  1 sibling, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2010-08-15 17:58 UTC (permalink / raw)
  To: jovi zhang; +Cc: linux-kernel

On Sat, Aug 14, 2010 at 10:15 PM, jovi zhang <bookjovi@gmail.com> wrote:
>
> little code improvement of check_stack_guard_page function.
> this commit is on top of commit "mm: keep a guard page below a
> grow-down stack segment" of linus.

I don't think your patch is in any way wrong, but I just checked, and
it makes absolutely zero difference to the code generation at least
for my version of gcc. The resulting assembly is identical except for
the line numbers that changed (BUG_ON() line/file information and
debug information).

So I think I prefer the shallower indentation.

                       Linus

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

* Re: [PATCH] mm: code improvement of check_stack_guard_page
  2010-08-15 17:58   ` Linus Torvalds
@ 2010-08-16  1:32     ` jovi zhang
  0 siblings, 0 replies; 6+ messages in thread
From: jovi zhang @ 2010-08-16  1:32 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

On Mon, Aug 16, 2010 at 1:58 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> On Sat, Aug 14, 2010 at 10:15 PM, jovi zhang <bookjovi@gmail.com> wrote:
>>
>> little code improvement of check_stack_guard_page function.
>> this commit is on top of commit "mm: keep a guard page below a
>> grow-down stack segment" of linus.
>
> I don't think your patch is in any way wrong, but I just checked, and
> it makes absolutely zero difference to the code generation at least
> for my version of gcc. The resulting assembly is identical except for
> the line numbers that changed (BUG_ON() line/file information and
> debug information).
>
> So I think I prefer the shallower indentation.
>
>                       Linus
>

That's fine. I havn't consider gcc optimization.

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

* Re: [PATCH] mm: code improvement of check_stack_guard_page
       [not found] <AANLkTinfgXOzbqgrRY4oCGXFtKtEyJO_rvQeeEEeEZz7@mail.gmail.com>
@ 2010-08-18  2:02   ` KAMEZAWA Hiroyuki
  2010-08-18  2:02   ` KAMEZAWA Hiroyuki
  1 sibling, 0 replies; 6+ messages in thread
From: KAMEZAWA Hiroyuki @ 2010-08-18  2:02 UTC (permalink / raw)
  To: jovi zhang
  Cc: torvalds, akpm, hughd, riel, minchan.kim, linux-mm, linux-kernel

On Sun, 15 Aug 2010 13:07:56 +0800
jovi zhang <bookjovi@gmail.com> wrote:

> little code improvement of check_stack_guard_page function.
> this commit is on top of commit "mm: keep a guard page below a grow-down
> stack segment" of linus.
> 

Hmm. difference in binary code finally ?

-Kame

> diff --git a/mm/memory.c b/mm/memory.c
> index 9b3b73f..643b112 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2768,13 +2768,15 @@ out_release:
>   */
>  static inline int check_stack_guard_page(struct vm_area_struct *vma,
> unsigned long address)
>  {
> -       address &= PAGE_MASK;
> -       if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
> -               address -= PAGE_SIZE;
> -               if (find_vma(vma->vm_mm, address) != vma)
> -                       return -ENOMEM;
> -
> -               expand_stack(vma, address);
> +       if (vma->vm_flags & VM_GROWSDOWN) {
> +               address &= PAGE_MASK;
> +               if(address == vma->vm_start) {
> +                       address -= PAGE_SIZE;
> +                       if (unlikely(find_vma(vma->vm_mm, address) != vma))
> +                               return -ENOMEM;
> +
> +                       expand_stack(vma, address);
> +               }
>         }
>         return 0;
>  }


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

* Re: [PATCH] mm: code improvement of check_stack_guard_page
@ 2010-08-18  2:02   ` KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 6+ messages in thread
From: KAMEZAWA Hiroyuki @ 2010-08-18  2:02 UTC (permalink / raw)
  To: jovi zhang
  Cc: torvalds, akpm, hughd, riel, minchan.kim, linux-mm, linux-kernel

On Sun, 15 Aug 2010 13:07:56 +0800
jovi zhang <bookjovi@gmail.com> wrote:

> little code improvement of check_stack_guard_page function.
> this commit is on top of commit "mm: keep a guard page below a grow-down
> stack segment" of linus.
> 

Hmm. difference in binary code finally ?

-Kame

> diff --git a/mm/memory.c b/mm/memory.c
> index 9b3b73f..643b112 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2768,13 +2768,15 @@ out_release:
>   */
>  static inline int check_stack_guard_page(struct vm_area_struct *vma,
> unsigned long address)
>  {
> -       address &= PAGE_MASK;
> -       if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
> -               address -= PAGE_SIZE;
> -               if (find_vma(vma->vm_mm, address) != vma)
> -                       return -ENOMEM;
> -
> -               expand_stack(vma, address);
> +       if (vma->vm_flags & VM_GROWSDOWN) {
> +               address &= PAGE_MASK;
> +               if(address == vma->vm_start) {
> +                       address -= PAGE_SIZE;
> +                       if (unlikely(find_vma(vma->vm_mm, address) != vma))
> +                               return -ENOMEM;
> +
> +                       expand_stack(vma, address);
> +               }
>         }
>         return 0;
>  }

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

* Re: [PATCH] mm: code improvement of check_stack_guard_page
  2010-08-15  5:15 ` [PATCH] mm: code improvement of check_stack_guard_page jovi zhang
  2010-08-15 17:58   ` Linus Torvalds
@ 2010-08-18  6:10   ` Balbir Singh
  1 sibling, 0 replies; 6+ messages in thread
From: Balbir Singh @ 2010-08-18  6:10 UTC (permalink / raw)
  To: jovi zhang; +Cc: linux-kernel

On Sun, Aug 15, 2010 at 10:45 AM, jovi zhang <bookjovi@gmail.com> wrote:
> little code improvement of check_stack_guard_page function.
> this commit is on top of commit "mm: keep a guard page below a
> grow-down stack segment" of linus.
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 9b3b73f..643b112 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2768,13 +2768,15 @@ out_release:
>   */
>  static inline int check_stack_guard_page(struct vm_area_struct *vma,
> unsigned long address)
>  {
> -       address &= PAGE_MASK;
> -       if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
> -               address -= PAGE_SIZE;
> -               if (find_vma(vma->vm_mm, address) != vma)
> -                       return -ENOMEM;
> -
> -               expand_stack(vma, address);
> +       if (vma->vm_flags & VM_GROWSDOWN) {
> +               address &= PAGE_MASK;
> +               if(address == vma->vm_start) {
                    ^^^ coding style is broken, did u run it through
scripts/checkpatch.pl?

> +                       address -= PAGE_SIZE;
> +                       if (unlikely(find_vma(vma->vm_mm, address) != vma))
> +                               return -ENOMEM;
> +
> +                       expand_stack(vma, address);
> +               }
>         }
>         return 0;
>  }
>

The main benefit I see is the new branch hint being passed to
find_vma, is my understanding correct?

Balbir

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

end of thread, other threads:[~2010-08-18  6:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AANLkTinfgXOzbqgrRY4oCGXFtKtEyJO_rvQeeEEeEZz7@mail.gmail.com>
2010-08-15  5:15 ` [PATCH] mm: code improvement of check_stack_guard_page jovi zhang
2010-08-15 17:58   ` Linus Torvalds
2010-08-16  1:32     ` jovi zhang
2010-08-18  6:10   ` Balbir Singh
2010-08-18  2:02 ` KAMEZAWA Hiroyuki
2010-08-18  2:02   ` KAMEZAWA Hiroyuki

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.