[RFC] Invalidate BH LRU during page migration

From: Chris Goldsworthy
Date: Tue Feb 02 2021 - 01:58:13 EST


A page containing buffer_heads can be pinned if any of its constituent
buffer_heads belongs to the BH LRU cache [1]. After going through
several iterations of a patch that attempts to solve this by removing
BH entries inside of the drop_buffers() function, which in
the worst-case could be called for each migrated page, Minchan Kim
suggested that we invalidate the entire BH LRU once, just before we
start migrating pages. Additionally, Matthew Wilcox suggested that
we invalidate the BH LRU inside of lru_add_drain_all(), so as to
benefit functions like other functions that would be impacted by
pinned pages [2].

TODO:
- It should be possible to remove the initial setting of
bh_migration_done = false; in migrate_prep by passing this in as a
parameter to invalidate_bh_lru(), but we'd still need a matching
bh_migration_done = true; call.
- To really benefit other callers of lru_add_drain_all() other than
__alloc_contig_migrate_range() in the CMA allocaiton path, we'd need
to add additional calls of bh_migration_done = false;

[1] https://elixir.bootlin.com/linux/latest/source/fs/buffer.c#L1238
[2] https://lore.kernel.org/linux-fsdevel/cover.1611642038.git.cgoldswo@xxxxxxxxxxxxxx/


Chris Goldsworthy (1):
[RFC] mm: fs: Invalidate BH LRU during page migration

fs/buffer.c | 6 ++++++
include/linux/buffer_head.h | 3 +++
include/linux/migrate.h | 2 ++
mm/migrate.c | 18 ++++++++++++++++++
mm/page_alloc.c | 3 +++
mm/swap.c | 3 +++
6 files changed, 35 insertions(+)

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project