函数源码 |
Source File:mm\kasan\quarantine.c |
Create Date:2022-07-27 17:28:47 |
首页 | Copyright©Brick |
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | void quarantine_put( struct kasan_free_meta *info, struct kmem_cache *cache) { unsigned long flags; struct qlist_head *q; struct qlist_head temp = QLIST_INIT; /* * Note: irq must be disabled until after we move the batch to the * global quarantine. Otherwise quarantine_remove_cache() can miss * some objects belonging to the cache if they are in our local temp * list. quarantine_remove_cache() executes on_each_cpu() at the * beginning which ensures that it either sees the objects in per-cpu * lists or in the global quarantine. */ local_irq_save(flags); q = this_cpu_ptr(&cpu_quarantine); qlist_put(q, &info->quarantine_link, cache->size); if (unlikely(q->bytes > QUARANTINE_PERCPU_SIZE)) { qlist_move_all(q, &temp); raw_spin_lock(&quarantine_lock); WRITE_ONCE(quarantine_size, quarantine_size + temp.bytes); qlist_move_all(&temp, &global_quarantine[quarantine_tail]); if (global_quarantine[quarantine_tail].bytes >= READ_ONCE(quarantine_batch_size)) { int new_tail; new_tail = quarantine_tail + 1; if (new_tail == QUARANTINE_BATCHES) new_tail = 0; if (new_tail != quarantine_head) quarantine_tail = new_tail; } raw_spin_unlock(&quarantine_lock); } local_irq_restore(flags); } |