+ if (!has_cache) {
+ spin_lock(&si->lock);
I'm no expert on that code, but we might drop the cluster lock the take
the swap_info lock and then retake the cluster lock. I assume there are
no races we are worrying about here, right?
I suppose so. Even the original single-entry code follows the same pattern:
static unsigned char __swap_entry_free(struct swap_info_struct *p,
swp_entry_t entry)
{
struct swap_cluster_info *ci;
unsigned long offset = swp_offset(entry);
unsigned char usage;
ci = lock_cluster_or_swap_info(p, offset);
usage = __swap_entry_free_locked(p, offset, 1);
unlock_cluster_or_swap_info(p, ci);
if (!usage)
free_swap_slot(entry);
return usage;
}
I assume that once we mark them as SWAP_HAS_CACHE, no one else
will touch them except ourselves.
That makes sense, thanks!
--
Cheers,
David / dhildenb