linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Will Deacon <will@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Matthew Wilcox <willy@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org
Subject: Re: [PATCH v2 3/7] mm/swap: Use local_lock for protection
Date: Mon, 25 May 2020 08:44:36 +0200	[thread overview]
Message-ID: <20200525064436.GA329373@gmail.com> (raw)
In-Reply-To: <20200524215739.551568-4-bigeasy@linutronix.de>



* Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> From: Ingo Molnar <mingo@kernel.org>
> 
> The various struct pagevec per CPU variables are protected by disabling
> either preemption or interrupts across the critical sections. Inside
> these sections spinlocks have to be acquired.

> diff --git a/mm/swap.c b/mm/swap.c
> index bf9a79fed62d7..4f965292044ca 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -35,6 +35,7 @@
>  #include <linux/uio.h>
>  #include <linux/hugetlb.h>
>  #include <linux/page_idle.h>
> +#include <linux/locallock.h>
>  
>  #include "internal.h"
>  
> @@ -44,14 +45,29 @@
>  /* 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);
> -static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs);
> -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);
> +/* Protecting lru_rotate_pvecs */
> +struct lru_rotate_pvecs {
> +	struct local_lock lock;
> +	struct pagevec pvec;
> +};
> +static DEFINE_PER_CPU(struct lru_rotate_pvecs, lru_rotate_pvecs) = {
> +	.lock = INIT_LOCAL_LOCK(lock),
> +};
> +
> +/* Protecting the following struct pagevec */
> +struct lru_pvecs {
> +	struct local_lock lock;
> +	struct pagevec lru_add_pvec;
> +	struct pagevec lru_deactivate_file_pvecs;
> +	struct pagevec lru_deactivate_pvecs;
> +	struct pagevec lru_lazyfree_pvecs;

Ack on coalescing these into the 'struct lru_pvecs' helper structure, 
but a minor namespace organization nit: I'd drop the _pvec/_pvecs 
postfix from the field names, i.e. make it something like this:

/* Protecting the following struct pagevec */
struct lru_pvecs {
	struct local_lock lock;
	struct pagevec lru_add;
	struct pagevec lru_deactivate_file;
	struct pagevec lru_deactivate;
	struct pagevec lru_lazyfree;

With that change, usage is a straightforward:

   pvec->lru_deactivate

instead of the double-pvec name:

   pvec->lru_deactivate_pvec

> +		local_lock_irqsave(&lru_rotate_pvecs.lock, flags);


Also:

> +		pvec = this_cpu_ptr(&lru_rotate_pvecs.pvec);

s/lru_rotate_pvecs
 /lru_rotate_pvec

it's a single pagevec, using plural is confusing when reading the 
code.

I'd also suggest adding a comment explaining why the lru_rotate_pvec 
local lock is split away from lru_add/deactivate/deactivate/lazyfree 
pagevec local lock.

Thanks,

	Ingo


  reply	other threads:[~2020-05-25  6:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200524215739.551568-1-bigeasy@linutronix.de>
2020-05-24 21:57 ` Sebastian Andrzej Siewior
2020-05-25  6:44   ` Ingo Molnar [this message]
2020-05-25 17:07     ` Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200525064436.GA329373@gmail.com \
    --to=mingo@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=will@kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox