Commit 605ca5e
mm/huge_memory.c: reorder operations in __split_huge_page_tail()
THP split makes non-atomic change of tail page flags. This is almost ok
because tail pages are locked and isolated but this breaks recent
changes in page locking: non-atomic operation could clear bit
PG_waiters.
As a result concurrent sequence get_page_unless_zero() -> lock_page()
might block forever. Especially if this page was truncated later.
Fix is trivial: clone flags before unfreezing page reference counter.
This race exists since commit 6290602 ("mm: add PageWaiters
indicating tasks are waiting for a page bit") while unsave unfreeze
itself was added in commit 8df651c ("thp: cleanup
split_huge_page()").
clear_compound_head() also must be called before unfreezing page
reference because after successful get_page_unless_zero() might follow
put_page() which needs correct compound_head().
And replace page_ref_inc()/page_ref_add() with page_ref_unfreeze() which
is made especially for that and has semantic of smp_store_release().
Link: http://lkml.kernel.org/r/151844393341.210639.13162088407980624477.stgit@buzz
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent 03f5d58 commit 605ca5e
1 file changed
+15
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2356 | 2356 | | |
2357 | 2357 | | |
2358 | 2358 | | |
2359 | | - | |
2360 | 2359 | | |
2361 | 2360 | | |
2362 | | - | |
2363 | | - | |
2364 | | - | |
2365 | | - | |
2366 | | - | |
2367 | | - | |
2368 | | - | |
2369 | | - | |
2370 | | - | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
2371 | 2365 | | |
2372 | | - | |
2373 | | - | |
2374 | | - | |
2375 | | - | |
2376 | | - | |
2377 | | - | |
2378 | | - | |
2379 | 2366 | | |
2380 | 2367 | | |
2381 | 2368 | | |
| |||
2388 | 2375 | | |
2389 | 2376 | | |
2390 | 2377 | | |
2391 | | - | |
2392 | | - | |
2393 | | - | |
2394 | | - | |
| 2378 | + | |
2395 | 2379 | | |
2396 | 2380 | | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
2397 | 2387 | | |
2398 | 2388 | | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
2399 | 2393 | | |
2400 | 2394 | | |
2401 | 2395 | | |
| |||
0 commit comments