All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang\, Ying" <ying.huang@intel.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Huang Ying <ying.huang@intel.com>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] swapfile: initialize spinlock for swap_cluster_info
Date: Tue, 07 Feb 2017 10:52:57 +0800	[thread overview]
Message-ID: <87vasmg19y.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <1486434945-29753-1-git-send-email-minchan@kernel.org> (Minchan Kim's message of "Tue, 7 Feb 2017 11:35:45 +0900")

Hi, Minchan,

Minchan Kim <minchan@kernel.org> writes:

> We changed swap_cluster_info lock from bit_spin_lock to spinlock
> so we need to initialize the spinlock before the using. Otherwise,
> lockdep is broken.
>
> Cc: Tim Chen <tim.c.chen@linux.intel.com>
> Cc: Huang Ying <ying.huang@intel.com>
> Cc: Hugh Dickins <hughd@google.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>

Good catch!  Thanks a lot for your fixing!

Reviewed-by: "Huang, Ying" <ying.huang@intel.com>

Best Regards,
Huang, Ying

> ---
> Andrew,
> I think it's no worth to add this patch to separate commit.
> If you don't mind, it's okay to fold this patch to mm-swap-add-cluster-lock-v5.
> Thanks.
>
>  mm/swapfile.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 1fc1824140e1..5ac2cb40dbd3 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -2762,6 +2762,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
>  
>  	if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) {
>  		int cpu;
> +		unsigned long ci, nr_cluster;
>  
>  		p->flags |= SWP_SOLIDSTATE;
>  		/*
> @@ -2769,13 +2770,17 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
>  		 * SSD
>  		 */
>  		p->cluster_next = 1 + (prandom_u32() % p->highest_bit);
> +		nr_cluster = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER);
>  
> -		cluster_info = vzalloc(DIV_ROUND_UP(maxpages,
> -			SWAPFILE_CLUSTER) * sizeof(*cluster_info));
> +		cluster_info = vzalloc(nr_cluster * sizeof(*cluster_info));
>  		if (!cluster_info) {
>  			error = -ENOMEM;
>  			goto bad_swap;
>  		}
> +
> +		for (ci = 0; ci < nr_cluster; ci++)
> +			spin_lock_init(&((cluster_info + ci)->lock));
> +
>  		p->percpu_cluster = alloc_percpu(struct percpu_cluster);
>  		if (!p->percpu_cluster) {
>  			error = -ENOMEM;

WARNING: multiple messages have this Message-ID (diff)
From: "Huang\, Ying" <ying.huang@intel.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Huang Ying <ying.huang@intel.com>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] swapfile: initialize spinlock for swap_cluster_info
Date: Tue, 07 Feb 2017 10:52:57 +0800	[thread overview]
Message-ID: <87vasmg19y.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <1486434945-29753-1-git-send-email-minchan@kernel.org> (Minchan Kim's message of "Tue, 7 Feb 2017 11:35:45 +0900")

Hi, Minchan,

Minchan Kim <minchan@kernel.org> writes:

> We changed swap_cluster_info lock from bit_spin_lock to spinlock
> so we need to initialize the spinlock before the using. Otherwise,
> lockdep is broken.
>
> Cc: Tim Chen <tim.c.chen@linux.intel.com>
> Cc: Huang Ying <ying.huang@intel.com>
> Cc: Hugh Dickins <hughd@google.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>

Good catch!  Thanks a lot for your fixing!

Reviewed-by: "Huang, Ying" <ying.huang@intel.com>

Best Regards,
Huang, Ying

> ---
> Andrew,
> I think it's no worth to add this patch to separate commit.
> If you don't mind, it's okay to fold this patch to mm-swap-add-cluster-lock-v5.
> Thanks.
>
>  mm/swapfile.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 1fc1824140e1..5ac2cb40dbd3 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -2762,6 +2762,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
>  
>  	if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) {
>  		int cpu;
> +		unsigned long ci, nr_cluster;
>  
>  		p->flags |= SWP_SOLIDSTATE;
>  		/*
> @@ -2769,13 +2770,17 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
>  		 * SSD
>  		 */
>  		p->cluster_next = 1 + (prandom_u32() % p->highest_bit);
> +		nr_cluster = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER);
>  
> -		cluster_info = vzalloc(DIV_ROUND_UP(maxpages,
> -			SWAPFILE_CLUSTER) * sizeof(*cluster_info));
> +		cluster_info = vzalloc(nr_cluster * sizeof(*cluster_info));
>  		if (!cluster_info) {
>  			error = -ENOMEM;
>  			goto bad_swap;
>  		}
> +
> +		for (ci = 0; ci < nr_cluster; ci++)
> +			spin_lock_init(&((cluster_info + ci)->lock));
> +
>  		p->percpu_cluster = alloc_percpu(struct percpu_cluster);
>  		if (!p->percpu_cluster) {
>  			error = -ENOMEM;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-02-07  2:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07  2:35 [PATCH] swapfile: initialize spinlock for swap_cluster_info Minchan Kim
2017-02-07  2:35 ` Minchan Kim
2017-02-07  2:52 ` Huang, Ying [this message]
2017-02-07  2:52   ` Huang, Ying

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=87vasmg19y.fsf@yhuang-dev.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=tim.c.chen@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.