@@ -1923,8 +1923,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
19231923
19241924static int unuse_pte_range (struct vm_area_struct * vma , pmd_t * pmd ,
19251925 unsigned long addr , unsigned long end ,
1926- unsigned int type , bool frontswap ,
1927- unsigned long * fs_pages_to_unuse )
1926+ unsigned int type )
19281927{
19291928 struct page * page ;
19301929 swp_entry_t entry ;
@@ -1945,9 +1944,6 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
19451944 continue ;
19461945
19471946 offset = swp_offset (entry );
1948- if (frontswap && !frontswap_test (si , offset ))
1949- continue ;
1950-
19511947 pte_unmap (pte );
19521948 swap_map = & si -> swap_map [offset ];
19531949 page = lookup_swap_cache (entry , vma , addr );
@@ -1979,11 +1975,6 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
19791975 try_to_free_swap (page );
19801976 unlock_page (page );
19811977 put_page (page );
1982-
1983- if (* fs_pages_to_unuse && !-- (* fs_pages_to_unuse )) {
1984- ret = FRONTSWAP_PAGES_UNUSED ;
1985- goto out ;
1986- }
19871978try_next :
19881979 pte = pte_offset_map (pmd , addr );
19891980 } while (pte ++ , addr += PAGE_SIZE , addr != end );
@@ -1996,8 +1987,7 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
19961987
19971988static inline int unuse_pmd_range (struct vm_area_struct * vma , pud_t * pud ,
19981989 unsigned long addr , unsigned long end ,
1999- unsigned int type , bool frontswap ,
2000- unsigned long * fs_pages_to_unuse )
1990+ unsigned int type )
20011991{
20021992 pmd_t * pmd ;
20031993 unsigned long next ;
@@ -2009,8 +1999,7 @@ static inline int unuse_pmd_range(struct vm_area_struct *vma, pud_t *pud,
20091999 next = pmd_addr_end (addr , end );
20102000 if (pmd_none_or_trans_huge_or_clear_bad (pmd ))
20112001 continue ;
2012- ret = unuse_pte_range (vma , pmd , addr , next , type ,
2013- frontswap , fs_pages_to_unuse );
2002+ ret = unuse_pte_range (vma , pmd , addr , next , type );
20142003 if (ret )
20152004 return ret ;
20162005 } while (pmd ++ , addr = next , addr != end );
@@ -2019,8 +2008,7 @@ static inline int unuse_pmd_range(struct vm_area_struct *vma, pud_t *pud,
20192008
20202009static inline int unuse_pud_range (struct vm_area_struct * vma , p4d_t * p4d ,
20212010 unsigned long addr , unsigned long end ,
2022- unsigned int type , bool frontswap ,
2023- unsigned long * fs_pages_to_unuse )
2011+ unsigned int type )
20242012{
20252013 pud_t * pud ;
20262014 unsigned long next ;
@@ -2031,8 +2019,7 @@ static inline int unuse_pud_range(struct vm_area_struct *vma, p4d_t *p4d,
20312019 next = pud_addr_end (addr , end );
20322020 if (pud_none_or_clear_bad (pud ))
20332021 continue ;
2034- ret = unuse_pmd_range (vma , pud , addr , next , type ,
2035- frontswap , fs_pages_to_unuse );
2022+ ret = unuse_pmd_range (vma , pud , addr , next , type );
20362023 if (ret )
20372024 return ret ;
20382025 } while (pud ++ , addr = next , addr != end );
@@ -2041,8 +2028,7 @@ static inline int unuse_pud_range(struct vm_area_struct *vma, p4d_t *p4d,
20412028
20422029static inline int unuse_p4d_range (struct vm_area_struct * vma , pgd_t * pgd ,
20432030 unsigned long addr , unsigned long end ,
2044- unsigned int type , bool frontswap ,
2045- unsigned long * fs_pages_to_unuse )
2031+ unsigned int type )
20462032{
20472033 p4d_t * p4d ;
20482034 unsigned long next ;
@@ -2053,16 +2039,14 @@ static inline int unuse_p4d_range(struct vm_area_struct *vma, pgd_t *pgd,
20532039 next = p4d_addr_end (addr , end );
20542040 if (p4d_none_or_clear_bad (p4d ))
20552041 continue ;
2056- ret = unuse_pud_range (vma , p4d , addr , next , type ,
2057- frontswap , fs_pages_to_unuse );
2042+ ret = unuse_pud_range (vma , p4d , addr , next , type );
20582043 if (ret )
20592044 return ret ;
20602045 } while (p4d ++ , addr = next , addr != end );
20612046 return 0 ;
20622047}
20632048
2064- static int unuse_vma (struct vm_area_struct * vma , unsigned int type ,
2065- bool frontswap , unsigned long * fs_pages_to_unuse )
2049+ static int unuse_vma (struct vm_area_struct * vma , unsigned int type )
20662050{
20672051 pgd_t * pgd ;
20682052 unsigned long addr , end , next ;
@@ -2076,25 +2060,22 @@ static int unuse_vma(struct vm_area_struct *vma, unsigned int type,
20762060 next = pgd_addr_end (addr , end );
20772061 if (pgd_none_or_clear_bad (pgd ))
20782062 continue ;
2079- ret = unuse_p4d_range (vma , pgd , addr , next , type ,
2080- frontswap , fs_pages_to_unuse );
2063+ ret = unuse_p4d_range (vma , pgd , addr , next , type );
20812064 if (ret )
20822065 return ret ;
20832066 } while (pgd ++ , addr = next , addr != end );
20842067 return 0 ;
20852068}
20862069
2087- static int unuse_mm (struct mm_struct * mm , unsigned int type ,
2088- bool frontswap , unsigned long * fs_pages_to_unuse )
2070+ static int unuse_mm (struct mm_struct * mm , unsigned int type )
20892071{
20902072 struct vm_area_struct * vma ;
20912073 int ret = 0 ;
20922074
20932075 mmap_read_lock (mm );
20942076 for (vma = mm -> mmap ; vma ; vma = vma -> vm_next ) {
20952077 if (vma -> anon_vma ) {
2096- ret = unuse_vma (vma , type , frontswap ,
2097- fs_pages_to_unuse );
2078+ ret = unuse_vma (vma , type );
20982079 if (ret )
20992080 break ;
21002081 }
@@ -2110,7 +2091,7 @@ static int unuse_mm(struct mm_struct *mm, unsigned int type,
21102091 * if there are no inuse entries after prev till end of the map.
21112092 */
21122093static unsigned int find_next_to_unuse (struct swap_info_struct * si ,
2113- unsigned int prev , bool frontswap )
2094+ unsigned int prev )
21142095{
21152096 unsigned int i ;
21162097 unsigned char count ;
@@ -2124,8 +2105,7 @@ static unsigned int find_next_to_unuse(struct swap_info_struct *si,
21242105 for (i = prev + 1 ; i < si -> max ; i ++ ) {
21252106 count = READ_ONCE (si -> swap_map [i ]);
21262107 if (count && swap_count (count ) != SWAP_MAP_BAD )
2127- if (!frontswap || frontswap_test (si , i ))
2128- break ;
2108+ break ;
21292109 if ((i % LATENCY_LIMIT ) == 0 )
21302110 cond_resched ();
21312111 }
@@ -2136,12 +2116,7 @@ static unsigned int find_next_to_unuse(struct swap_info_struct *si,
21362116 return i ;
21372117}
21382118
2139- /*
2140- * If the boolean frontswap is true, only unuse pages_to_unuse pages;
2141- * pages_to_unuse==0 means all pages; ignored if frontswap is false
2142- */
2143- int try_to_unuse (unsigned int type , bool frontswap ,
2144- unsigned long pages_to_unuse )
2119+ static int try_to_unuse (unsigned int type )
21452120{
21462121 struct mm_struct * prev_mm ;
21472122 struct mm_struct * mm ;
@@ -2155,13 +2130,10 @@ int try_to_unuse(unsigned int type, bool frontswap,
21552130 if (!READ_ONCE (si -> inuse_pages ))
21562131 return 0 ;
21572132
2158- if (!frontswap )
2159- pages_to_unuse = 0 ;
2160-
21612133retry :
2162- retval = shmem_unuse (type , frontswap , & pages_to_unuse );
2134+ retval = shmem_unuse (type );
21632135 if (retval )
2164- goto out ;
2136+ return retval ;
21652137
21662138 prev_mm = & init_mm ;
21672139 mmget (prev_mm );
@@ -2178,11 +2150,10 @@ int try_to_unuse(unsigned int type, bool frontswap,
21782150 spin_unlock (& mmlist_lock );
21792151 mmput (prev_mm );
21802152 prev_mm = mm ;
2181- retval = unuse_mm (mm , type , frontswap , & pages_to_unuse );
2182-
2153+ retval = unuse_mm (mm , type );
21832154 if (retval ) {
21842155 mmput (prev_mm );
2185- goto out ;
2156+ return retval ;
21862157 }
21872158
21882159 /*
@@ -2199,7 +2170,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
21992170 i = 0 ;
22002171 while (READ_ONCE (si -> inuse_pages ) &&
22012172 !signal_pending (current ) &&
2202- (i = find_next_to_unuse (si , i , frontswap )) != 0 ) {
2173+ (i = find_next_to_unuse (si , i )) != 0 ) {
22032174
22042175 entry = swp_entry (type , i );
22052176 page = find_get_page (swap_address_space (entry ), i );
@@ -2217,14 +2188,6 @@ int try_to_unuse(unsigned int type, bool frontswap,
22172188 try_to_free_swap (page );
22182189 unlock_page (page );
22192190 put_page (page );
2220-
2221- /*
2222- * For frontswap, we just need to unuse pages_to_unuse, if
2223- * it was specified. Need not check frontswap again here as
2224- * we already zeroed out pages_to_unuse if not frontswap.
2225- */
2226- if (pages_to_unuse && -- pages_to_unuse == 0 )
2227- goto out ;
22282191 }
22292192
22302193 /*
@@ -2242,10 +2205,10 @@ int try_to_unuse(unsigned int type, bool frontswap,
22422205 if (READ_ONCE (si -> inuse_pages )) {
22432206 if (!signal_pending (current ))
22442207 goto retry ;
2245- retval = - EINTR ;
2208+ return - EINTR ;
22462209 }
2247- out :
2248- return ( retval == FRONTSWAP_PAGES_UNUSED ) ? 0 : retval ;
2210+
2211+ return 0 ;
22492212}
22502213
22512214/*
@@ -2577,7 +2540,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
25772540 disable_swap_slots_cache_lock ();
25782541
25792542 set_current_oom_origin ();
2580- err = try_to_unuse (p -> type , false, 0 ); /* force unuse all pages */
2543+ err = try_to_unuse (p -> type );
25812544 clear_current_oom_origin ();
25822545
25832546 if (err ) {
0 commit comments