Lines Matching +full:hot +full:- +full:plug
1 // SPDX-License-Identifier: GPL-2.0
65 /* Must not be called with cpu hot plug lock */
124 return -ENOMEM; in alloc_swap_slot_cache()
128 if (cache->slots) { in alloc_swap_slot_cache()
137 if (!cache->lock_initialized) { in alloc_swap_slot_cache()
138 mutex_init(&cache->alloc_lock); in alloc_swap_slot_cache()
139 cache->lock_initialized = true; in alloc_swap_slot_cache()
141 cache->nr = 0; in alloc_swap_slot_cache()
142 cache->cur = 0; in alloc_swap_slot_cache()
143 cache->n_ret = 0; in alloc_swap_slot_cache()
146 * !cache->slots or !cache->slots_ret to know if it is safe to acquire in alloc_swap_slot_cache()
151 cache->slots = slots; in alloc_swap_slot_cache()
161 if (cache->slots) { in drain_slots_cache_cpu()
162 mutex_lock(&cache->alloc_lock); in drain_slots_cache_cpu()
163 swapcache_free_entries(cache->slots + cache->cur, cache->nr); in drain_slots_cache_cpu()
164 cache->cur = 0; in drain_slots_cache_cpu()
165 cache->nr = 0; in drain_slots_cache_cpu()
166 if (free_slots && cache->slots) { in drain_slots_cache_cpu()
167 kvfree(cache->slots); in drain_slots_cache_cpu()
168 cache->slots = NULL; in drain_slots_cache_cpu()
170 mutex_unlock(&cache->alloc_lock); in drain_slots_cache_cpu()
187 * We cannot acquire cpu hot plug lock here as in __drain_swap_slots_cache()
189 * hot plug path: in __drain_swap_slots_cache()
190 * cpu_up -> lock cpu_hotplug -> cpu hotplug state callback in __drain_swap_slots_cache()
191 * -> memory allocation -> direct reclaim -> folio_alloc_swap in __drain_swap_slots_cache()
192 * -> drain_swap_slots_cache in __drain_swap_slots_cache()
239 cache->cur = 0; in refill_swap_slots_cache()
241 cache->nr = get_swap_pages(SWAP_SLOTS_CACHE_SIZE, in refill_swap_slots_cache()
242 cache->slots, 0); in refill_swap_slots_cache()
244 return cache->nr; in refill_swap_slots_cache()
263 * accesses to the per-CPU data structure are protected by the in folio_alloc_swap()
264 * mutex cache->alloc_lock. in folio_alloc_swap()
266 * The alloc path here does not touch cache->slots_ret in folio_alloc_swap()
267 * so cache->free_lock is not taken. in folio_alloc_swap()
271 if (likely(check_cache_active() && cache->slots)) { in folio_alloc_swap()
272 mutex_lock(&cache->alloc_lock); in folio_alloc_swap()
273 if (cache->slots) { in folio_alloc_swap()
275 if (cache->nr) { in folio_alloc_swap()
276 entry = cache->slots[cache->cur]; in folio_alloc_swap()
277 cache->slots[cache->cur++].val = 0; in folio_alloc_swap()
278 cache->nr--; in folio_alloc_swap()
283 mutex_unlock(&cache->alloc_lock); in folio_alloc_swap()