Skip to content
  • Linus Torvalds's avatar
    mm: document warning in move_normal_pmd() and make it warn only once · f81fdd0c
    Linus Torvalds authored
    Naresh Kamboju reported that the LTP tests can cause warnings on i386
    going back all the way to v5.0, and bisected it to commit 2c91bd4a
    
    
    ("mm: speed up mremap by 20x on large regions").
    
    The warning in move_normal_pmd() is actually mostly correct, but we have
    a very unusual special case at process creation time, when we may move
    the stack down with an overlapping mode (kind of like a "memmove()"
    except using the page tables).
    
    And when you have just the right condition of "move a large initial
    stack by the right alignment in the end, but with the early part of the
    move being only page-aligned", we'll be in a situation where we're
    trying to move a normal PMD entry on top of an already existing - but
    now empty - PMD entry.
    
    The warning is still worth having, in case it ever triggers other cases,
    and perhaps as a reminder that we could do the stack move case more
    efficiently (although it's clearly rare enough that it probably doesn't
    matter).
    
    But make it do WARN_ON_ONCE(), so that you can't flood the logs with it.
    
    And add a *big* comment above it to explain and remind us what's going
    on, because it took some figuring out to see how this could trigger.
    Kudos to Joel Fernandes for debugging this.
    
    Reported-by: default avatarNaresh Kamboju <naresh.kamboju@linaro.org>
    Debugged-and-acked-by: default avatarJoel Fernandes <joel@joelfernandes.org>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Kirill A. Shutemov <kirill@shutemov.name>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    f81fdd0c