RE: [Update][PATCH v5 7/9] mm/swap: Add cache for swap slots allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > +	/*
> > +	 * Preemption need to be turned on here, because we may sleep
> > +	 * in refill_swap_slots_cache().  But it is safe, because
> > +	 * accesses to the per-CPU data structure are protected by a
> > +	 * mutex.
> > +	 */
> 
> the comment doesn't really explain why it is safe. THere are other users
> which are not using the lock. E.g. just look at free_swap_slot above.
> How can
> 	cache->slots_ret[cache->n_ret++] = entry; be safe wrt.
> 	pentry = &cache->slots[cache->cur++];
> 	entry = *pentry;
> 
> Both of them might touch the same slot, no? Btw. I would rather prefer this
> would be a follow up fix with the trace and the detailed explanation.
> 

The cache->slots_ret  is protected by cache->free_lock and cache->slots is
protected by cache->free_lock.  They are two separate structures, one for
caching the slots returned and one for caching the slots allocated.  So
they do no touch the same slots.  We'll update the comments so it is clearer.

Sure. We can issue a follow up fix on top of the current patchset.

Thanks.

Tim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]