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 <tim.c.c...@linux.intel.com>
Date: Wed, 18 Jan 2017 09:52:28 -0800
Subject: [PATCH] mm/swap: Add comments on locks in swap_slots.h
To: Andrew Morton <a...@linux-foundation.org>
Cc: Ying Huang <ying.hu...@intel.com>, dave.han...@intel.com, 
a...@linux.intel.com, aaron...@intel.com, linux...@kvack.org, 
linux-kernel@vger.kernel.org, Hugh Dickins <hu...@google.com>, Shaohua Li 
<s...@kernel.org>, Minchan Kim <minc...@kernel.org>, Rik van Riel 
<r...@redhat.com>, Andrea Arcangeli <aarca...@redhat.com>, Kirill A . Shutemov 
<kirill.shute...@linux.intel.com>, Vladimir Davydov <vdavydov....@gmail.com>, 
Johannes Weiner <han...@cmpxchg.org>, Michal Hocko <mho...@kernel.org>, Hillf 
Danton <hillf...@alibaba-inc.com>, Christian Borntraeger 
<borntrae...@de.ibm.com>, Jonathan Corbet <cor...@lwn.net>

Explains what each lock protects in swap_slots_cache structure.

Signed-off-by: Tim Chen <tim.c.c...@linux.intel.com>
---
 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

Attachment: signature.asc
Description: PGP signature

Reply via email to