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]

 



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.chen@xxxxxxxxxxxxxxx>
Date: Wed, 18 Jan 2017 09:52:28 -0800
Subject: [PATCH] mm/swap: Add comments on locks in swap_slots.h
To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Ying Huang <ying.huang@xxxxxxxxx>, dave.hansen@xxxxxxxxx, ak@xxxxxxxxxxxxxxx, aaron.lu@xxxxxxxxx, linux-mm@xxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Hugh Dickins <hughd@xxxxxxxxxx>, Shaohua Li <shli@xxxxxxxxxx>, Minchan Kim <minchan@xxxxxxxxxx>, Rik van Riel <riel@xxxxxxxxxx>, Andrea Arcangeli <aarcange@xxxxxxxxxx>, Kirill A . Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>, Vladimir Davydov <vdavydov.dev@xxxxxxxxx>, Johannes Weiner <hannes@xxxxxxxxxxx>, Michal Hocko <mhocko@xxxxxxxxxx>, Hillf Danton <hillf.zj@xxxxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxx>, Jonathan Corbet <corbet@xxxxxxx>

Explains what each lock protects in swap_slots_cache structure.

Signed-off-by: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
---
 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


[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]