Re: [patch] mm, thp: avoid unlikely branches for split_huge_pmd

From: Andrew Morton
Date: Tue Oct 18 2016 - 19:11:12 EST


On Tue, 18 Oct 2016 16:04:06 -0700 (PDT) David Rientjes <rientjes@xxxxxxxxxx> wrote:

> While doing MADV_DONTNEED on a large area of thp memory, I noticed we
> encountered many unlikely() branches in profiles for each backing
> hugepage. This is because zap_pmd_range() would call split_huge_pmd(),
> which rechecked the conditions that were already validated, but as part of
> an unlikely() branch.
>
> Avoid the unlikely() branch when in a context where pmd is known to be
> good for __split_huge_pmd() directly.

Before:

text data bss dec hex filename
38442 75 48 38565 96a5 mm/memory.o
21755 2369 18464 42588 a65c mm/mempolicy.o
4557 1816 0 6373 18e5 mm/mprotect.o

After:

38362 75 48 38485 9655 mm/memory.o
21714 2369 18464 42547 a633 mm/mempolicy.o
4541 1816 0 6357 18d5 mm/mprotect.o


So there's a size improvment too. gcc-4.4.4.