Commit 5bebe8d
committed
mm/huge_memory: Fix initialization of huge zero folio
The recent fix to properly initialize the tags of the huge zero folio
had an unfortunate not-so-subtle side effect: it caused the actual
*contents* of the huge zero folio to not be initialized at all when the
hardware didn't support the memory tagging.
The reason was the unfortunate semantics of tag_clear_highpage(): on
hardware that didn't do the tagging, it would silently just not do
anything at all. And since this is done only on arm64 with MTE support,
that basically meant most hardware.
It wasn't necessarily immediately obvious since the huge zero page isn't
necessarily very heavily used - or because it might already be zero
because all-zeroes is the most common pattern. But it ends up causing
random odd user space failures when you do hit it.
The unfortunate semantics have been around for a while, but became a
real bug only when we started actively using __GFP_ZEROTAGS in the
generic get_huge_zero_folio() function - before that, it had only ever
been used in code that checked that the hardware supported it.
Fix this by simply changing the semantics of tag_clear_highpage() to
return whether it actually successfully did something or not. While at
it, also make it initialize multiple pages in one go, since that's
actually what the only caller wants it to do and it simplifies the whole
logic.
Fixes: adfb660 ("mm/huge_memory: initialise the tags of the huge zero folio")
Link: https://lore.kernel.org/all/[email protected]/
Reviewed-by: David Hildenbrand (Red Hat) <[email protected]>
Reported-and-tested-by: David Wang <[email protected]>
Reported-and-tested-by: Carlos Llamas <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>1 parent e7c375b commit 5bebe8d
File tree
4 files changed
+19
-21
lines changed- arch/arm64
- include/asm
- mm
- include/linux
- mm
4 files changed
+19
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
967 | 967 | | |
968 | 968 | | |
969 | 969 | | |
970 | | - | |
| 970 | + | |
971 | 971 | | |
972 | 972 | | |
973 | 973 | | |
974 | 974 | | |
975 | | - | |
| 975 | + | |
976 | 976 | | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
| 977 | + | |
| 978 | + | |
981 | 979 | | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
986 | 987 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
| 255 | + | |
255 | 256 | | |
| 257 | + | |
256 | 258 | | |
257 | 259 | | |
258 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1822 | 1822 | | |
1823 | 1823 | | |
1824 | 1824 | | |
1825 | | - | |
1826 | | - | |
1827 | | - | |
1828 | | - | |
| 1825 | + | |
| 1826 | + | |
1829 | 1827 | | |
1830 | | - | |
1831 | | - | |
1832 | | - | |
1833 | 1828 | | |
1834 | 1829 | | |
1835 | 1830 | | |
| |||
0 commit comments