Skip to content

Commit ba6851b

Browse files
MiaoheLinakpm00
authored andcommitted
mm: filter out swapin error entry in shmem mapping
There might be swapin error entries in shmem mapping. Filter them out to avoid "Bad swap file entry" complaint. Link: https://lkml.kernel.org/r/20220519125030.21486-6-linmiaohe@huawei.com Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Reviewed-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Cc: Alistair Popple <apopple@nvidia.com> Cc: David Hildenbrand <david@redhat.com> Cc: David Howells <dhowells@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: NeilBrown <neilb@suse.de> Cc: Peter Xu <peterx@redhat.com> Cc: Ralph Campbell <rcampbell@nvidia.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 6cec2b9 commit ba6851b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

mm/madvise.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,13 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma,
248248

249249
if (!xa_is_value(page))
250250
continue;
251+
swap = radix_to_swp_entry(page);
252+
/* There might be swapin error entries in shmem mapping. */
253+
if (non_swap_entry(swap))
254+
continue;
251255
xas_pause(&xas);
252256
rcu_read_unlock();
253257

254-
swap = radix_to_swp_entry(page);
255258
page = read_swap_cache_async(swap, GFP_HIGHUSER_MOVABLE,
256259
NULL, 0, false, &splug);
257260
if (page)

mm/swap_state.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
410410
return NULL;
411411

412412
swp = radix_to_swp_entry(page);
413+
/* There might be swapin error entries in shmem mapping. */
414+
if (non_swap_entry(swp))
415+
return NULL;
413416
/* Prevent swapoff from happening to us */
414417
si = get_swap_device(swp);
415418
if (!si)

0 commit comments

Comments
 (0)