From: Linus Torvalds <torvalds@linux-foundation.org>
To: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org,
Hugh Dickins <hughd@google.com>, Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH] Don't mlock guardpage if the stack is growing up
Date: Sun, 8 May 2011 14:47:33 -0700 [thread overview]
Message-ID: <BANLkTikEpaRZK3X4YReeQAwgcv3HAGUwSw@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1105082045250.15552@artax.karlin.mff.cuni.cz>
On Sun, May 8, 2011 at 11:55 AM, Mikulas Patocka
<mikulas@artax.karlin.mff.cuni.cz> wrote:
>
> This patch fixes lvm2 on PA-RISC (and possibly other architectures with
> up-growing stack). lvm2 calculates the number of used pages when locking
> and when unlocking and reports an internal error if the numbers mismatch.
This patch won't apply on current kernels (including stable) because
of commit a1fde08c74e9 that changed the test of "pages" to instead
just test "flags & FOLL_MLOCK".
That should be trivial to fix up.
However, I really don't much like this complex test:
> static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
> {
> - return (vma->vm_flags & VM_GROWSDOWN) &&
> + return ((vma->vm_flags & VM_GROWSDOWN) &&
> (vma->vm_start == addr) &&
> - !vma_stack_continue(vma->vm_prev, addr);
> + !vma_stack_continue(vma->vm_prev, addr)) ||
> + ((vma->vm_flags & VM_GROWSUP) &&
> + (vma->vm_end == addr + PAGE_SIZE) &&
> + !vma_stack_growsup_continue(vma->vm_next, addr + PAGE_SIZE));
> }
in that format. It gets really hard to read, and I think you'd be
better off writing it as two helper functions (or macros) for the two
cases, and then have
static inline int stack_guard_page(struct vm_area_struct *vma,
unsigned long addr)
{
return stack_guard_page_growsdown(vma, addr) ||
stack_guard_page_growsup(vma, addr);
}
I'd also like to verify that it doesn't actually generate any extra
code for the common case (iirc VM_GROWSUP is 0 for the architectures
that don't need it, and so the compiler shouldn't generate any extra
code, but I'd like that mentioned and verified explicitly).
Hmm?
Other than that it looks ok to me.
That said, could we please fix LVM to not do that crazy sh*t in the
first place? The STACK_GROWSUP case is never going to have a lot of
testing, this is just sad.
Linus
next prev parent reply other threads:[~2011-05-08 21:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-08 18:55 Mikulas Patocka
2011-05-08 20:12 ` Hugh Dickins
2011-05-09 11:12 ` Mikulas Patocka
2011-05-09 15:57 ` Linus Torvalds
2011-05-09 22:07 ` Linus Torvalds
2011-05-09 22:19 ` James Bottomley
2011-05-09 22:31 ` Linus Torvalds
2011-05-09 22:53 ` Tony Luck
2011-05-09 22:58 ` Linus Torvalds
2011-05-09 23:08 ` Tony Luck
2011-05-09 23:17 ` Linus Torvalds
2011-05-09 23:25 ` Linus Torvalds
2011-05-10 4:12 ` James Bottomley
2011-05-09 22:26 ` Mikulas Patocka
2011-05-15 22:18 ` Mikulas Patocka
2011-05-08 21:47 ` Linus Torvalds [this message]
2011-05-09 11:01 ` Mikulas Patocka
2011-05-09 11:43 ` Zdenek Kabelac
2011-05-09 21:08 ` Alasdair G Kergon
2011-05-09 22:45 ` Matthew Wilcox
2011-05-09 22:56 ` Linus Torvalds
2011-05-10 22:57 ` Alasdair G Kergon
2011-05-11 8:42 ` Milan Broz
2011-05-12 2:12 ` Linus Torvalds
2011-05-12 9:06 ` Zdenek Kabelac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTikEpaRZK3X4YReeQAwgcv3HAGUwSw@mail.gmail.com \
--to=torvalds@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=mikulas@artax.karlin.mff.cuni.cz \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®