aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swap_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swap_state.c')
-rw-r--r--mm/swap_state.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/mm/swap_state.c b/mm/swap_state.c
index a063a902ed03..4f251775ef90 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -143,7 +143,6 @@ void __delete_from_swap_cache(struct page *page)
143int add_to_swap(struct page * page) 143int add_to_swap(struct page * page)
144{ 144{
145 swp_entry_t entry; 145 swp_entry_t entry;
146 int pf_flags;
147 int err; 146 int err;
148 147
149 if (!PageLocked(page)) 148 if (!PageLocked(page))
@@ -154,29 +153,19 @@ int add_to_swap(struct page * page)
154 if (!entry.val) 153 if (!entry.val)
155 return 0; 154 return 0;
156 155
157 /* Radix-tree node allocations are performing 156 /*
158 * GFP_ATOMIC allocations under PF_MEMALLOC. 157 * Radix-tree node allocations from PF_MEMALLOC contexts could
159 * They can completely exhaust the page allocator. 158 * completely exhaust the page allocator. __GFP_NOMEMALLOC
160 * 159 * stops emergency reserves from being allocated.
161 * So PF_MEMALLOC is dropped here. This causes the slab
162 * allocations to fail earlier, so radix-tree nodes will
163 * then be allocated from the mempool reserves.
164 * 160 *
165 * We're still using __GFP_HIGH for radix-tree node 161 * TODO: this could cause a theoretical memory reclaim
166 * allocations, so some of the emergency pools are available, 162 * deadlock in the swap out path.
167 * just not all of them.
168 */ 163 */
169
170 pf_flags = current->flags;
171 current->flags &= ~PF_MEMALLOC;
172
173 /* 164 /*
174 * Add it to the swap cache and mark it dirty 165 * Add it to the swap cache and mark it dirty
175 */ 166 */
176 err = __add_to_swap_cache(page, entry, GFP_ATOMIC|__GFP_NOWARN); 167 err = __add_to_swap_cache(page, entry,
177 168 GFP_ATOMIC|__GFP_NOMEMALLOC|__GFP_NOWARN);
178 if (pf_flags & PF_MEMALLOC)
179 current->flags |= PF_MEMALLOC;
180 169
181 switch (err) { 170 switch (err) {
182 case 0: /* Success */ 171 case 0: /* Success */