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