Re: [PATCH 4/8] mm/swap: Use local_lock for protection
From: Peter Zijlstra
Date: Wed May 20 2020 - 06:54:02 EST
On Tue, May 19, 2020 at 10:19:08PM +0200, Sebastian Andrzej Siewior wrote:
> diff --git a/mm/swap.c b/mm/swap.c
> index bf9a79fed62d7..03c97d15fcd69 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -44,8 +44,14 @@
> /* How many pages do we try to swap or page in/out together? */
> int page_cluster;
>
> -static DEFINE_PER_CPU(struct pagevec, lru_add_pvec);
> +
> +/* Protecting lru_rotate_pvecs */
> +static DEFINE_LOCAL_LOCK(rotate_lock);
> static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs);
> +
> +/* Protecting the following struct pagevec */
> +DEFINE_LOCAL_LOCK(swapvec_lock);
> +static DEFINE_PER_CPU(struct pagevec, lru_add_pvec);
> static DEFINE_PER_CPU(struct pagevec, lru_deactivate_file_pvecs);
> static DEFINE_PER_CPU(struct pagevec, lru_deactivate_pvecs);
> static DEFINE_PER_CPU(struct pagevec, lru_lazyfree_pvecs);
So personally I'd prefer to have this look like:
struct lru_vecs {
struct local_lock lock;
struct pagevec add;
struct pagevec rotate;
struct pagevec deact_file;
struct pagevec deact;
struct pagevec lazyfree;
#ifdef CONFIG_SMP
struct pagevec active;
#endif
};
DEFINE_PER_CPU(struct lru_pvec, lru_pvec);
or something, but I realize that is a lot of churn (although highly
automated), so I'll leave that to the mm folks.