All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: fix extend calculation for move_page_tables()
@ 2020-12-29 17:45 Helge Deller
  2020-12-29 19:04 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Helge Deller @ 2020-12-29 17:45 UTC (permalink / raw)
  To: Kalesh Singh, Kirill A. Shutemov, Andrew Morton, Linus Torvalds,
	linux-mm, linux-kernel
  Cc: linux-parisc, James Bottomley, John David Anglin

On parisc the kernel fails to start the init process because in
shift_arg_pages() in fs/exec.c, move_page_tables() is called to e.g.
move pages from start addr 0xffeff000 to the new start addr 0xf9ccb000
with a length of 0x1000 bytes, but move_page_tables() instead returns
that it apparently moved 0x57000 bytes. Since the number of bytes is
different than the number of bytes which should have been moved,
shift_arg_pages() aborts with -ENOMEM.

Debugging shows that commit c49dd34018026 ("mm: speedup mremap on
1GB or larger regions") is the culprit.
In this commit, the extent calculation was tried to be optimized, but
got it wrong for this case.
The patch below reverts to the previous way to calculate the extent and
thus fixes the boot problem.

Fixes: c49dd34018026 ("mm: speedup mremap on 1GB or larger regions")
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>

---

diff --git a/mm/mremap.c b/mm/mremap.c
index c5590afe7165..f554320281cc 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -358,7 +358,9 @@ static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,

 	next = (old_addr + size) & mask;
 	/* even if next overflowed, extent below will be ok */
-	extent = (next > old_end) ? old_end - old_addr : next - old_addr;
+	extent = next - old_addr;
+	if (extent > old_end - old_addr)
+		extent = old_end - old_addr;
 	next = (new_addr + size) & mask;
 	if (extent > next - new_addr)
 		extent = next - new_addr;

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

* Re: [PATCH] mm: fix extend calculation for move_page_tables()
  2020-12-29 17:45 [PATCH] mm: fix extend calculation for move_page_tables() Helge Deller
@ 2020-12-29 19:04 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2020-12-29 19:04 UTC (permalink / raw)
  To: Helge Deller
  Cc: Kalesh Singh, Kirill A. Shutemov, Linus Torvalds, linux-mm,
	linux-kernel, linux-parisc, James Bottomley, John David Anglin

On Tue, 29 Dec 2020 18:45:29 +0100 Helge Deller <deller@gmx.de> wrote:

> On parisc the kernel fails to start the init process because in
> shift_arg_pages() in fs/exec.c, move_page_tables() is called to e.g.
> move pages from start addr 0xffeff000 to the new start addr 0xf9ccb000
> with a length of 0x1000 bytes, but move_page_tables() instead returns
> that it apparently moved 0x57000 bytes. Since the number of bytes is
> different than the number of bytes which should have been moved,
> shift_arg_pages() aborts with -ENOMEM.
> 
> Debugging shows that commit c49dd34018026 ("mm: speedup mremap on
> 1GB or larger regions") is the culprit.
> In this commit, the extent calculation was tried to be optimized, but
> got it wrong for this case.
> The patch below reverts to the previous way to calculate the extent and
> thus fixes the boot problem.
> 

Thanks.  The same as
https://lkml.kernel.org/r/20201219170433.2418867-1-kaleshsingh@google.com.
I'll get that sent to Linus today.


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

end of thread, other threads:[~2020-12-29 19:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29 17:45 [PATCH] mm: fix extend calculation for move_page_tables() Helge Deller
2020-12-29 19:04 ` Andrew Morton

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.