mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-05 05:07:47 -04:00
mm/mincore, swap: consolidate swap cache checking for mincore
Patch series "mm/mincore: minor clean up for swap cache checking". This series cleans up a swap cache helper only used by mincore, move it back into mincore code. Also separate the swap cache related logics out of shmem / page cache logics in mincore. With this series we have less lines of code and better performance. Before this series: mincore on a swaped out 16G anon mmap range: Took 488220 us mincore on 16G shmem mmap range: Took 530272 us. After this series: mincore on a swaped out 16G anon mmap range: Took 446763 us mincore on 16G shmem mmap range: Took 460496 us. About ~10% faster. This patch (of 2): The filemap_get_incore_folio (previously find_get_incore_page) helper was introduced by commit61ef186557("mm: factor find_get_incore_page out of mincore_page") to be used by later commitf5df8635c5("mm: use find_get_incore_page in memcontrol"), so memory cgroup charge move code can be simplified. But commit6b611388b6("memcg-v1: remove charge move code") removed that user completely, it's only used by mincore now. So this commit basically reverts commit61ef186557("mm: factor find_get_incore_page out of mincore_page"). Move it back to mincore side to simplify the code. Link: https://lkml.kernel.org/r/20250811172018.48901-1-ryncsn@gmail.com Link: https://lkml.kernel.org/r/20250811172018.48901-2-ryncsn@gmail.com Signed-off-by: Kairui Song <kasong@tencent.com> Acked-by: Nhat Pham <nphamcs@gmail.com> Cc: Baoquan He <bhe@redhat.com> Cc: Barry Song <baohua@kernel.org> Cc: Chris Li <chrisl@kernel.org> Cc: David Hildenbrand <david@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Jann Horn <jannh@google.com> Cc: Kemeng Shi <shikemeng@huaweicloud.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
7bca1760cd
commit
27763edac9
29
mm/mincore.c
29
mm/mincore.c
@@ -64,8 +64,33 @@ static unsigned char mincore_page(struct address_space *mapping, pgoff_t index)
|
||||
* any other file mapping (ie. marked !present and faulted in with
|
||||
* tmpfs's .fault). So swapped out tmpfs mappings are tested here.
|
||||
*/
|
||||
folio = filemap_get_incore_folio(mapping, index);
|
||||
if (!IS_ERR(folio)) {
|
||||
if (IS_ENABLED(CONFIG_SWAP) && shmem_mapping(mapping)) {
|
||||
folio = filemap_get_entry(mapping, index);
|
||||
/*
|
||||
* shmem/tmpfs may return swap: account for swapcache
|
||||
* page too.
|
||||
*/
|
||||
if (xa_is_value(folio)) {
|
||||
struct swap_info_struct *si;
|
||||
swp_entry_t swp = radix_to_swp_entry(folio);
|
||||
/* There might be swapin error entries in shmem mapping. */
|
||||
if (non_swap_entry(swp))
|
||||
return 0;
|
||||
/* Prevent swap device to being swapoff under us */
|
||||
si = get_swap_device(swp);
|
||||
if (si) {
|
||||
folio = filemap_get_folio(swap_address_space(swp),
|
||||
swap_cache_index(swp));
|
||||
put_swap_device(si);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
folio = filemap_get_folio(mapping, index);
|
||||
}
|
||||
|
||||
if (!IS_ERR_OR_NULL(folio)) {
|
||||
present = folio_test_uptodate(folio);
|
||||
folio_put(folio);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user