All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC 2/2] mm: additional checks to page flag set/clear
Date: Mon, 30 Dec 2013 14:12:24 +0200	[thread overview]
Message-ID: <20131230121224.GB8117@node.dhcp.inet.fi> (raw)
In-Reply-To: <1388281504-11453-2-git-send-email-sasha.levin@oracle.com>

On Sat, Dec 28, 2013 at 08:45:04PM -0500, Sasha Levin wrote:
> Check if the flag is already set before setting it, and vice versa
> for clearing.
> 
> Obviously setting or clearing a flag twice isn't a problem on it's
> own, but it implies that there's an issue where some piece of code
> assumed an opposite state of the flag.

BUG() is overkill. WARN_ONCE is more then enough.

And I don't think this kind of checks make sense for all flags.

Have you seen any obviously broken case which these checks could catch?

> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  include/linux/page-flags.h | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index d1fe1a7..36b0bef 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -130,6 +130,12 @@ enum pageflags {
>  
>  #ifndef __GENERATING_BOUNDS_H
>  
> +#ifdef CONFIG_DEBUG_VM_PAGE_FLAGS
> +#define VM_ASSERT_FLAG(assert, page) VM_BUG_ON_PAGE(assert, page)
> +#else
> +#define VM_ASSERT_FLAG(assert, page) do { } while (0)
> +#endif
> +
>  /*
>   * Macros to create function definitions for page flags
>   */
> @@ -139,11 +145,13 @@ static inline int Page##uname(const struct page *page)			\
>  
>  #define SETPAGEFLAG(uname, lname)					\
>  static inline void SetPage##uname(struct page *page)			\
> -			{ set_bit(PG_##lname, &page->flags); }
> +			{ VM_ASSERT_FLAG(Page##uname(page), page);	\
> +			set_bit(PG_##lname, &page->flags); }
>  
>  #define CLEARPAGEFLAG(uname, lname)					\
>  static inline void ClearPage##uname(struct page *page)			\
> -			{ clear_bit(PG_##lname, &page->flags); }
> +			{ VM_ASSERT_FLAG(!Page##uname(page), page);	\
> +			clear_bit(PG_##lname, &page->flags); }
>  
>  #define __SETPAGEFLAG(uname, lname)					\
>  static inline void __SetPage##uname(struct page *page)			\
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
 Kirill A. Shutemov

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

WARNING: multiple messages have this Message-ID (diff)
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC 2/2] mm: additional checks to page flag set/clear
Date: Mon, 30 Dec 2013 14:12:24 +0200	[thread overview]
Message-ID: <20131230121224.GB8117@node.dhcp.inet.fi> (raw)
In-Reply-To: <1388281504-11453-2-git-send-email-sasha.levin@oracle.com>

On Sat, Dec 28, 2013 at 08:45:04PM -0500, Sasha Levin wrote:
> Check if the flag is already set before setting it, and vice versa
> for clearing.
> 
> Obviously setting or clearing a flag twice isn't a problem on it's
> own, but it implies that there's an issue where some piece of code
> assumed an opposite state of the flag.

BUG() is overkill. WARN_ONCE is more then enough.

And I don't think this kind of checks make sense for all flags.

Have you seen any obviously broken case which these checks could catch?

> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  include/linux/page-flags.h | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index d1fe1a7..36b0bef 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -130,6 +130,12 @@ enum pageflags {
>  
>  #ifndef __GENERATING_BOUNDS_H
>  
> +#ifdef CONFIG_DEBUG_VM_PAGE_FLAGS
> +#define VM_ASSERT_FLAG(assert, page) VM_BUG_ON_PAGE(assert, page)
> +#else
> +#define VM_ASSERT_FLAG(assert, page) do { } while (0)
> +#endif
> +
>  /*
>   * Macros to create function definitions for page flags
>   */
> @@ -139,11 +145,13 @@ static inline int Page##uname(const struct page *page)			\
>  
>  #define SETPAGEFLAG(uname, lname)					\
>  static inline void SetPage##uname(struct page *page)			\
> -			{ set_bit(PG_##lname, &page->flags); }
> +			{ VM_ASSERT_FLAG(Page##uname(page), page);	\
> +			set_bit(PG_##lname, &page->flags); }
>  
>  #define CLEARPAGEFLAG(uname, lname)					\
>  static inline void ClearPage##uname(struct page *page)			\
> -			{ clear_bit(PG_##lname, &page->flags); }
> +			{ VM_ASSERT_FLAG(!Page##uname(page), page);	\
> +			clear_bit(PG_##lname, &page->flags); }
>  
>  #define __SETPAGEFLAG(uname, lname)					\
>  static inline void __SetPage##uname(struct page *page)			\
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
 Kirill A. Shutemov

  reply	other threads:[~2013-12-30 12:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-29  1:45 [RFC 1/2] mm: additional page lock debugging Sasha Levin
2013-12-29  1:45 ` Sasha Levin
2013-12-29  1:45 ` [RFC 2/2] mm: additional checks to page flag set/clear Sasha Levin
2013-12-29  1:45   ` Sasha Levin
2013-12-30 12:12   ` Kirill A. Shutemov [this message]
2013-12-30 12:12     ` Kirill A. Shutemov
2013-12-30 11:43 ` [RFC 1/2] mm: additional page lock debugging Kirill A. Shutemov
2013-12-30 11:43   ` Kirill A. Shutemov
2013-12-30 16:33   ` Sasha Levin
2013-12-30 16:33     ` Sasha Levin
2013-12-30 22:48     ` Kirill A. Shutemov
2013-12-30 22:48       ` Kirill A. Shutemov
2013-12-31  3:22       ` Sasha Levin
2013-12-31  3:22         ` Sasha Levin
2013-12-31 16:26         ` Peter Zijlstra
2013-12-31 16:26           ` Peter Zijlstra
2013-12-31 16:42           ` Sasha Levin
2013-12-31 16:42             ` Sasha Levin
2014-01-06 10:04             ` Peter Zijlstra
2014-01-06 10:04               ` Peter Zijlstra
2014-02-10 23:19               ` Sasha Levin
2014-02-10 23:19                 ` Sasha Levin

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=20131230121224.GB8117@node.dhcp.inet.fi \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sasha.levin@oracle.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.