@@ -1923,8 +1923,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
1923
1923
1924
1924
static int unuse_pte_range (struct vm_area_struct * vma , pmd_t * pmd ,
1925
1925
unsigned long addr , unsigned long end ,
1926
- unsigned int type , bool frontswap ,
1927
- unsigned long * fs_pages_to_unuse )
1926
+ unsigned int type )
1928
1927
{
1929
1928
struct page * page ;
1930
1929
swp_entry_t entry ;
@@ -1945,9 +1944,6 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
1945
1944
continue ;
1946
1945
1947
1946
offset = swp_offset (entry );
1948
- if (frontswap && !frontswap_test (si , offset ))
1949
- continue ;
1950
-
1951
1947
pte_unmap (pte );
1952
1948
swap_map = & si -> swap_map [offset ];
1953
1949
page = lookup_swap_cache (entry , vma , addr );
@@ -1979,11 +1975,6 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
1979
1975
try_to_free_swap (page );
1980
1976
unlock_page (page );
1981
1977
put_page (page );
1982
-
1983
- if (* fs_pages_to_unuse && !-- (* fs_pages_to_unuse )) {
1984
- ret = FRONTSWAP_PAGES_UNUSED ;
1985
- goto out ;
1986
- }
1987
1978
try_next :
1988
1979
pte = pte_offset_map (pmd , addr );
1989
1980
} while (pte ++ , addr += PAGE_SIZE , addr != end );
@@ -1996,8 +1987,7 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
1996
1987
1997
1988
static inline int unuse_pmd_range (struct vm_area_struct * vma , pud_t * pud ,
1998
1989
unsigned long addr , unsigned long end ,
1999
- unsigned int type , bool frontswap ,
2000
- unsigned long * fs_pages_to_unuse )
1990
+ unsigned int type )
2001
1991
{
2002
1992
pmd_t * pmd ;
2003
1993
unsigned long next ;
@@ -2009,8 +1999,7 @@ static inline int unuse_pmd_range(struct vm_area_struct *vma, pud_t *pud,
2009
1999
next = pmd_addr_end (addr , end );
2010
2000
if (pmd_none_or_trans_huge_or_clear_bad (pmd ))
2011
2001
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 );
2014
2003
if (ret )
2015
2004
return ret ;
2016
2005
} while (pmd ++ , addr = next , addr != end );
@@ -2019,8 +2008,7 @@ static inline int unuse_pmd_range(struct vm_area_struct *vma, pud_t *pud,
2019
2008
2020
2009
static inline int unuse_pud_range (struct vm_area_struct * vma , p4d_t * p4d ,
2021
2010
unsigned long addr , unsigned long end ,
2022
- unsigned int type , bool frontswap ,
2023
- unsigned long * fs_pages_to_unuse )
2011
+ unsigned int type )
2024
2012
{
2025
2013
pud_t * pud ;
2026
2014
unsigned long next ;
@@ -2031,8 +2019,7 @@ static inline int unuse_pud_range(struct vm_area_struct *vma, p4d_t *p4d,
2031
2019
next = pud_addr_end (addr , end );
2032
2020
if (pud_none_or_clear_bad (pud ))
2033
2021
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 );
2036
2023
if (ret )
2037
2024
return ret ;
2038
2025
} while (pud ++ , addr = next , addr != end );
@@ -2041,8 +2028,7 @@ static inline int unuse_pud_range(struct vm_area_struct *vma, p4d_t *p4d,
2041
2028
2042
2029
static inline int unuse_p4d_range (struct vm_area_struct * vma , pgd_t * pgd ,
2043
2030
unsigned long addr , unsigned long end ,
2044
- unsigned int type , bool frontswap ,
2045
- unsigned long * fs_pages_to_unuse )
2031
+ unsigned int type )
2046
2032
{
2047
2033
p4d_t * p4d ;
2048
2034
unsigned long next ;
@@ -2053,16 +2039,14 @@ static inline int unuse_p4d_range(struct vm_area_struct *vma, pgd_t *pgd,
2053
2039
next = p4d_addr_end (addr , end );
2054
2040
if (p4d_none_or_clear_bad (p4d ))
2055
2041
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 );
2058
2043
if (ret )
2059
2044
return ret ;
2060
2045
} while (p4d ++ , addr = next , addr != end );
2061
2046
return 0 ;
2062
2047
}
2063
2048
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 )
2066
2050
{
2067
2051
pgd_t * pgd ;
2068
2052
unsigned long addr , end , next ;
@@ -2076,25 +2060,22 @@ static int unuse_vma(struct vm_area_struct *vma, unsigned int type,
2076
2060
next = pgd_addr_end (addr , end );
2077
2061
if (pgd_none_or_clear_bad (pgd ))
2078
2062
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 );
2081
2064
if (ret )
2082
2065
return ret ;
2083
2066
} while (pgd ++ , addr = next , addr != end );
2084
2067
return 0 ;
2085
2068
}
2086
2069
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 )
2089
2071
{
2090
2072
struct vm_area_struct * vma ;
2091
2073
int ret = 0 ;
2092
2074
2093
2075
mmap_read_lock (mm );
2094
2076
for (vma = mm -> mmap ; vma ; vma = vma -> vm_next ) {
2095
2077
if (vma -> anon_vma ) {
2096
- ret = unuse_vma (vma , type , frontswap ,
2097
- fs_pages_to_unuse );
2078
+ ret = unuse_vma (vma , type );
2098
2079
if (ret )
2099
2080
break ;
2100
2081
}
@@ -2110,7 +2091,7 @@ static int unuse_mm(struct mm_struct *mm, unsigned int type,
2110
2091
* if there are no inuse entries after prev till end of the map.
2111
2092
*/
2112
2093
static unsigned int find_next_to_unuse (struct swap_info_struct * si ,
2113
- unsigned int prev , bool frontswap )
2094
+ unsigned int prev )
2114
2095
{
2115
2096
unsigned int i ;
2116
2097
unsigned char count ;
@@ -2124,8 +2105,7 @@ static unsigned int find_next_to_unuse(struct swap_info_struct *si,
2124
2105
for (i = prev + 1 ; i < si -> max ; i ++ ) {
2125
2106
count = READ_ONCE (si -> swap_map [i ]);
2126
2107
if (count && swap_count (count ) != SWAP_MAP_BAD )
2127
- if (!frontswap || frontswap_test (si , i ))
2128
- break ;
2108
+ break ;
2129
2109
if ((i % LATENCY_LIMIT ) == 0 )
2130
2110
cond_resched ();
2131
2111
}
@@ -2136,12 +2116,7 @@ static unsigned int find_next_to_unuse(struct swap_info_struct *si,
2136
2116
return i ;
2137
2117
}
2138
2118
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 )
2145
2120
{
2146
2121
struct mm_struct * prev_mm ;
2147
2122
struct mm_struct * mm ;
@@ -2155,13 +2130,10 @@ int try_to_unuse(unsigned int type, bool frontswap,
2155
2130
if (!READ_ONCE (si -> inuse_pages ))
2156
2131
return 0 ;
2157
2132
2158
- if (!frontswap )
2159
- pages_to_unuse = 0 ;
2160
-
2161
2133
retry :
2162
- retval = shmem_unuse (type , frontswap , & pages_to_unuse );
2134
+ retval = shmem_unuse (type );
2163
2135
if (retval )
2164
- goto out ;
2136
+ return retval ;
2165
2137
2166
2138
prev_mm = & init_mm ;
2167
2139
mmget (prev_mm );
@@ -2178,11 +2150,10 @@ int try_to_unuse(unsigned int type, bool frontswap,
2178
2150
spin_unlock (& mmlist_lock );
2179
2151
mmput (prev_mm );
2180
2152
prev_mm = mm ;
2181
- retval = unuse_mm (mm , type , frontswap , & pages_to_unuse );
2182
-
2153
+ retval = unuse_mm (mm , type );
2183
2154
if (retval ) {
2184
2155
mmput (prev_mm );
2185
- goto out ;
2156
+ return retval ;
2186
2157
}
2187
2158
2188
2159
/*
@@ -2199,7 +2170,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
2199
2170
i = 0 ;
2200
2171
while (READ_ONCE (si -> inuse_pages ) &&
2201
2172
!signal_pending (current ) &&
2202
- (i = find_next_to_unuse (si , i , frontswap )) != 0 ) {
2173
+ (i = find_next_to_unuse (si , i )) != 0 ) {
2203
2174
2204
2175
entry = swp_entry (type , i );
2205
2176
page = find_get_page (swap_address_space (entry ), i );
@@ -2217,14 +2188,6 @@ int try_to_unuse(unsigned int type, bool frontswap,
2217
2188
try_to_free_swap (page );
2218
2189
unlock_page (page );
2219
2190
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 ;
2228
2191
}
2229
2192
2230
2193
/*
@@ -2242,10 +2205,10 @@ int try_to_unuse(unsigned int type, bool frontswap,
2242
2205
if (READ_ONCE (si -> inuse_pages )) {
2243
2206
if (!signal_pending (current ))
2244
2207
goto retry ;
2245
- retval = - EINTR ;
2208
+ return - EINTR ;
2246
2209
}
2247
- out :
2248
- return ( retval == FRONTSWAP_PAGES_UNUSED ) ? 0 : retval ;
2210
+
2211
+ return 0 ;
2249
2212
}
2250
2213
2251
2214
/*
@@ -2577,7 +2540,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
2577
2540
disable_swap_slots_cache_lock ();
2578
2541
2579
2542
set_current_oom_origin ();
2580
- err = try_to_unuse (p -> type , false, 0 ); /* force unuse all pages */
2543
+ err = try_to_unuse (p -> type );
2581
2544
clear_current_oom_origin ();
2582
2545
2583
2546
if (err ) {
0 commit comments