On Wed, Jan 18, 2017 at 01:45:55PM +0100, Michal Hocko wrote: > On Tue 17-01-17 13:42:35, Tim Chen wrote: > [...] > > Logic wise, We do allow pre-emption as per cpu ptr cache->slots is > > protected by the mutex cache->alloc_lock. We switch the > > inappropriately used this_cpu_ptr to raw_cpu_ptr for per cpu ptr > > access of cache->slots. > > OK, that looks better. I would still appreciate something like the > following folded in > diff --git a/include/linux/swap_slots.h b/include/linux/swap_slots.h > index fb907346c5c6..0afe748453a7 100644 > --- a/include/linux/swap_slots.h > +++ b/include/linux/swap_slots.h > @@ -11,6 +11,7 @@ > > struct swap_slots_cache { > bool lock_initialized; > + /* protects slots, nr, cur */ > struct mutex alloc_lock; > swp_entry_t *slots; > int nr; > I've included here a patch for the comments. Thanks. Tim --->8--- From: Tim Chen Date: Wed, 18 Jan 2017 09:52:28 -0800 Subject: [PATCH] mm/swap: Add comments on locks in swap_slots.h To: Andrew Morton Cc: Ying Huang , dave.hansen@intel.com, ak@linux.intel.com, aaron.lu@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Shaohua Li , Minchan Kim , Rik van Riel , Andrea Arcangeli , Kirill A . Shutemov , Vladimir Davydov , Johannes Weiner , Michal Hocko , Hillf Danton , Christian Borntraeger , Jonathan Corbet Explains what each lock protects in swap_slots_cache structure. Signed-off-by: Tim Chen --- include/linux/swap_slots.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/swap_slots.h b/include/linux/swap_slots.h index fb90734..6ef92d1 100644 --- a/include/linux/swap_slots.h +++ b/include/linux/swap_slots.h @@ -11,11 +11,11 @@ struct swap_slots_cache { bool lock_initialized; - struct mutex alloc_lock; + struct mutex alloc_lock; /* protects slots, nr, cur */ swp_entry_t *slots; int nr; int cur; - spinlock_t free_lock; + spinlock_t free_lock; /* protects slots_ret, n_ret */ swp_entry_t *slots_ret; int n_ret; }; -- 2.5.5