Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1735656
| From | Artem Savkov <asavkov@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | MADV_FREE is broken |
| Date | 2017-09-20 11:10 +0200 |
| Message-ID | <urJb4-Y3-35@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Hi All, We recently started noticing madvise09[1] test from ltp failing strangely. The test does the following: maps 32 pages, sets MADV_FREE for the range it got, dirties 2 of the pages, creates memory pressure and check that nondirty pages are free. The test hanged while accessing the last 4 pages(29-32) of madvised range at line 121 [2]. Any other process (gdb/cat) accessing those pages would also hang as would rebooting the machine. It doesn't trigger any debug warnings or kasan. The issue bisected to "802a3a92ad7a mm: reclaim MADV_FREE pages" (so 4.12 and up are affected). I did some poking around and found out that the "bad" pages had SwapBacked flag set in shrink_page_list() which confused it a lot. It looks like mark_page_lazyfree() only calls lru_lazyfree_fn() when the pagevec is full (that is in batches of 14) and never drains the rest (so last four in madvise09 case). The patch below greatly reduces the failure rate, but doesn't fix it completely, it still shows up with the same symptoms (hanging trying to access last 4 pages) after a bunch of retries. [1] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise09.c [2] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise09.c#L121 diff --git a/mm/madvise.c b/mm/madvise.c index 21261ff0466f..a0b868e8b7d2 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -453,6 +453,7 @@ static void madvise_free_page_range(struct mmu_gather *tlb, tlb_start_vma(tlb, vma); walk_page_range(addr, end, &free_walk); + lru_add_drain(); tlb_end_vma(tlb, vma); } -- Regards, Artem
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
MADV_FREE is broken Artem Savkov <asavkov@redhat.com> - 2017-09-20 11:10 +0200
Re: MADV_FREE is broken Shaohua Li <shli@kernel.org> - 2017-09-21 00:40 +0200
Re: MADV_FREE is broken Artem Savkov <asavkov@redhat.com> - 2017-09-21 11:50 +0200
csiph-web