diff options
author | Minchan Kim <minchan@kernel.org> | 2018-04-05 19:23:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-06 00:36:25 -0400 |
commit | eaf649ebc3acfbb235ce31cebd06e4876d05758e (patch) | |
tree | 68225a29f76c5f4d78c628c405af7ba37ad75f31 /mm/memory.c | |
parent | e830c63a621e20894a663351b968706bd0efbbd0 (diff) |
mm: swap: clean up swap readahead
When I see recent change of swap readahead, I am very unhappy about
current code structure which diverges two swap readahead algorithm in
do_swap_page. This patch is to clean it up.
Main motivation is that fault handler doesn't need to be aware of
readahead algorithms but just should call swapin_readahead.
As first step, this patch cleans up a little bit but not perfect (I just
separate for review easier) so next patch will make the goal complete.
[minchan@kernel.org: do not check readahead flag with THP anon]
Link: http://lkml.kernel.org/r/874lm83zho.fsf@yhuang-dev.intel.com
Link: http://lkml.kernel.org/r/20180227232611.169883-1-minchan@kernel.org
Link: http://lkml.kernel.org/r/1509520520-32367-2-git-send-email-minchan@kernel.org
Link: http://lkml.kernel.org/r/20180220085249.151400-2-minchan@kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Huang Ying <ying.huang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memory.c')
-rw-r--r-- | mm/memory.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/mm/memory.c b/mm/memory.c index aed37325d94e..bc1ccff79538 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -2883,26 +2883,16 @@ EXPORT_SYMBOL(unmap_mapping_range); | |||
2883 | int do_swap_page(struct vm_fault *vmf) | 2883 | int do_swap_page(struct vm_fault *vmf) |
2884 | { | 2884 | { |
2885 | struct vm_area_struct *vma = vmf->vma; | 2885 | struct vm_area_struct *vma = vmf->vma; |
2886 | struct page *page = NULL, *swapcache = NULL; | 2886 | struct page *page = NULL, *swapcache; |
2887 | struct mem_cgroup *memcg; | 2887 | struct mem_cgroup *memcg; |
2888 | struct vma_swap_readahead swap_ra; | ||
2889 | swp_entry_t entry; | 2888 | swp_entry_t entry; |
2890 | pte_t pte; | 2889 | pte_t pte; |
2891 | int locked; | 2890 | int locked; |
2892 | int exclusive = 0; | 2891 | int exclusive = 0; |
2893 | int ret = 0; | 2892 | int ret = 0; |
2894 | bool vma_readahead = swap_use_vma_readahead(); | ||
2895 | 2893 | ||
2896 | if (vma_readahead) { | 2894 | if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) |
2897 | page = swap_readahead_detect(vmf, &swap_ra); | ||
2898 | swapcache = page; | ||
2899 | } | ||
2900 | |||
2901 | if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) { | ||
2902 | if (page) | ||
2903 | put_page(page); | ||
2904 | goto out; | 2895 | goto out; |
2905 | } | ||
2906 | 2896 | ||
2907 | entry = pte_to_swp_entry(vmf->orig_pte); | 2897 | entry = pte_to_swp_entry(vmf->orig_pte); |
2908 | if (unlikely(non_swap_entry(entry))) { | 2898 | if (unlikely(non_swap_entry(entry))) { |
@@ -2928,11 +2918,8 @@ int do_swap_page(struct vm_fault *vmf) | |||
2928 | 2918 | ||
2929 | 2919 | ||
2930 | delayacct_set_flag(DELAYACCT_PF_SWAPIN); | 2920 | delayacct_set_flag(DELAYACCT_PF_SWAPIN); |
2931 | if (!page) { | 2921 | page = lookup_swap_cache(entry, vma, vmf->address); |
2932 | page = lookup_swap_cache(entry, vma_readahead ? vma : NULL, | 2922 | swapcache = page; |
2933 | vmf->address); | ||
2934 | swapcache = page; | ||
2935 | } | ||
2936 | 2923 | ||
2937 | if (!page) { | 2924 | if (!page) { |
2938 | struct swap_info_struct *si = swp_swap_info(entry); | 2925 | struct swap_info_struct *si = swp_swap_info(entry); |
@@ -2949,9 +2936,9 @@ int do_swap_page(struct vm_fault *vmf) | |||
2949 | swap_readpage(page, true); | 2936 | swap_readpage(page, true); |
2950 | } | 2937 | } |
2951 | } else { | 2938 | } else { |
2952 | if (vma_readahead) | 2939 | if (swap_use_vma_readahead()) |
2953 | page = do_swap_page_readahead(entry, | 2940 | page = do_swap_page_readahead(entry, |
2954 | GFP_HIGHUSER_MOVABLE, vmf, &swap_ra); | 2941 | GFP_HIGHUSER_MOVABLE, vmf); |
2955 | else | 2942 | else |
2956 | page = swapin_readahead(entry, | 2943 | page = swapin_readahead(entry, |
2957 | GFP_HIGHUSER_MOVABLE, vma, vmf->address); | 2944 | GFP_HIGHUSER_MOVABLE, vma, vmf->address); |
@@ -2982,7 +2969,6 @@ int do_swap_page(struct vm_fault *vmf) | |||
2982 | */ | 2969 | */ |
2983 | ret = VM_FAULT_HWPOISON; | 2970 | ret = VM_FAULT_HWPOISON; |
2984 | delayacct_clear_flag(DELAYACCT_PF_SWAPIN); | 2971 | delayacct_clear_flag(DELAYACCT_PF_SWAPIN); |
2985 | swapcache = page; | ||
2986 | goto out_release; | 2972 | goto out_release; |
2987 | } | 2973 | } |
2988 | 2974 | ||