LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Dan Streetman <ddstreet@ieee.org>
To: alex_y_xu@yahoo.ca
Cc: Linux-MM <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: fix z3fold warnings on CONFIG_SMP=n
Date: Thu, 27 Sep 2018 16:41:21 -0400
Message-ID: <CALZtONA9r6=gnK-5a++tjaReqEnRzrBb3hzYMTFNXZ13z+UOWQ@mail.gmail.com> (raw)
In-Reply-To: <1538079759.qxp8zh3nwh.astroid@alex-archsus.none>

On Thu, Sep 27, 2018 at 4:27 PM Alex Xu (Hello71) <alex_y_xu@yahoo.ca> wrote:
>
> Spinlocks are always lockable on UP systems, even if they were just
> locked.

i think it would be much better to just use either
assert_spin_locked() or just spin_is_locked(), instead of an #ifdef.

>
> Cc: Dan Streetman <ddstreet@ieee.org>
> Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
> ---
>  mm/z3fold.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 4b366d181..4e6ad2de4 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -202,6 +202,13 @@ static inline void z3fold_page_lock(struct z3fold_header *zhdr)
>         spin_lock(&zhdr->page_lock);
>  }
>
> +static inline void z3fold_page_ensure_locked(struct z3fold_header *zhdr)
> +{
> +#ifdef CONFIG_SMP
> +       WARN_ON(z3fold_page_trylock(zhdr));
> +#endif
> +}
> +
>  /* Try to lock a z3fold page */
>  static inline int z3fold_page_trylock(struct z3fold_header *zhdr)
>  {
> @@ -277,7 +284,7 @@ static void release_z3fold_page_locked(struct kref *ref)
>  {
>         struct z3fold_header *zhdr = container_of(ref, struct z3fold_header,
>                                                 refcount);
> -       WARN_ON(z3fold_page_trylock(zhdr));
> +       z3fold_page_ensure_locked(zhdr);
>         __release_z3fold_page(zhdr, true);
>  }
>
> @@ -289,7 +296,7 @@ static void release_z3fold_page_locked_list(struct kref *ref)
>         list_del_init(&zhdr->buddy);
>         spin_unlock(&zhdr->pool->lock);
>
> -       WARN_ON(z3fold_page_trylock(zhdr));
> +       z3fold_page_ensure_locked(zhdr);
>         __release_z3fold_page(zhdr, true);
>  }
>
> @@ -403,7 +410,7 @@ static void do_compact_page(struct z3fold_header *zhdr, bool locked)
>
>         page = virt_to_page(zhdr);
>         if (locked)
> -               WARN_ON(z3fold_page_trylock(zhdr));
> +               z3fold_page_ensure_locked(zhdr);
>         else
>                 z3fold_page_lock(zhdr);
>         if (WARN_ON(!test_and_clear_bit(NEEDS_COMPACTING, &page->private))) {
> --
> 2.19.0
>

  reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27 20:27 Alex Xu (Hello71)
2018-09-27 20:41 ` Dan Streetman [this message]
2018-09-27 21:12   ` Alex Xu
2018-09-27 21:15     ` [PATCH v2] " Alex Xu (Hello71)
2018-09-28 11:31       ` Dan Streetman

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='CALZtONA9r6=gnK-5a++tjaReqEnRzrBb3hzYMTFNXZ13z+UOWQ@mail.gmail.com' \
    --to=ddstreet@ieee.org \
    --cc=alex_y_xu@yahoo.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git