From: Minchan Kim <minchan@kernel.org>
To: chengang@emindsoft.com.cn
Cc: akpm@linux-foundation.org, vbabka@suse.cz,
mgorman@techsingularity.net, mhocko@suse.com,
gi-oh.kim@profitbricks.com, iamjoonsoo.kim@lge.com,
hillf.zj@alibaba-inc.com, rientjes@google.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Chen Gang <gang.chen.5i5j@gmail.com>
Subject: Re: [PATCH] mm: migrate: Use bool instead of int for the return value of PageMovable
Date: Mon, 11 Jul 2016 09:26:05 +0900 [thread overview]
Message-ID: <20160711002605.GD31817@bbox> (raw)
In-Reply-To: <1468079704-5477-1-git-send-email-chengang@emindsoft.com.cn>
On Sat, Jul 09, 2016 at 11:55:04PM +0800, chengang@emindsoft.com.cn wrote:
> From: Chen Gang <chengang@emindsoft.com.cn>
>
> For pure bool function's return value, bool is a little better more or
> less than int.
>
> And return boolean result directly, since 'if' statement is also for
> boolean checking, and return boolean result, too.
I just wanted to consistent with other PageXXX flags functions, PageAnon,
PageMappingFlags which returns int rather than bool. Although I agree bool
is natural, I want to be consistent with others rather than breaking at
the moment.
Maybe if you feel it's really helpful, you might be able to handle all
of places I mentioned for better readability and keeping consistency.
But I doubt it's worth.
Thanks.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> include/linux/migrate.h | 4 ++--
> mm/compaction.c | 9 +++------
> 2 files changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> index ae8d475..0e366f8 100644
> --- a/include/linux/migrate.h
> +++ b/include/linux/migrate.h
> @@ -72,11 +72,11 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
> #endif /* CONFIG_MIGRATION */
>
> #ifdef CONFIG_COMPACTION
> -extern int PageMovable(struct page *page);
> +extern bool PageMovable(struct page *page);
> extern void __SetPageMovable(struct page *page, struct address_space *mapping);
> extern void __ClearPageMovable(struct page *page);
> #else
> -static inline int PageMovable(struct page *page) { return 0; };
> +static inline bool PageMovable(struct page *page) { return false; };
> static inline void __SetPageMovable(struct page *page,
> struct address_space *mapping)
> {
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 0bd53fb..cfcfe88 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -95,19 +95,16 @@ static inline bool migrate_async_suitable(int migratetype)
>
> #ifdef CONFIG_COMPACTION
>
> -int PageMovable(struct page *page)
> +bool PageMovable(struct page *page)
> {
> struct address_space *mapping;
>
> VM_BUG_ON_PAGE(!PageLocked(page), page);
> if (!__PageMovable(page))
> - return 0;
> + return false;
>
> mapping = page_mapping(page);
> - if (mapping && mapping->a_ops && mapping->a_ops->isolate_page)
> - return 1;
> -
> - return 0;
> + return mapping && mapping->a_ops && mapping->a_ops->isolate_page;
> }
> EXPORT_SYMBOL(PageMovable);
>
> --
> 1.9.3
>
> --
> 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>
--
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: Minchan Kim <minchan@kernel.org>
To: <chengang@emindsoft.com.cn>
Cc: <akpm@linux-foundation.org>, <vbabka@suse.cz>,
<mgorman@techsingularity.net>, <mhocko@suse.com>,
<gi-oh.kim@profitbricks.com>, <iamjoonsoo.kim@lge.com>,
<hillf.zj@alibaba-inc.com>, <rientjes@google.com>,
<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
Chen Gang <gang.chen.5i5j@gmail.com>
Subject: Re: [PATCH] mm: migrate: Use bool instead of int for the return value of PageMovable
Date: Mon, 11 Jul 2016 09:26:05 +0900 [thread overview]
Message-ID: <20160711002605.GD31817@bbox> (raw)
In-Reply-To: <1468079704-5477-1-git-send-email-chengang@emindsoft.com.cn>
On Sat, Jul 09, 2016 at 11:55:04PM +0800, chengang@emindsoft.com.cn wrote:
> From: Chen Gang <chengang@emindsoft.com.cn>
>
> For pure bool function's return value, bool is a little better more or
> less than int.
>
> And return boolean result directly, since 'if' statement is also for
> boolean checking, and return boolean result, too.
I just wanted to consistent with other PageXXX flags functions, PageAnon,
PageMappingFlags which returns int rather than bool. Although I agree bool
is natural, I want to be consistent with others rather than breaking at
the moment.
Maybe if you feel it's really helpful, you might be able to handle all
of places I mentioned for better readability and keeping consistency.
But I doubt it's worth.
Thanks.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> include/linux/migrate.h | 4 ++--
> mm/compaction.c | 9 +++------
> 2 files changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> index ae8d475..0e366f8 100644
> --- a/include/linux/migrate.h
> +++ b/include/linux/migrate.h
> @@ -72,11 +72,11 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
> #endif /* CONFIG_MIGRATION */
>
> #ifdef CONFIG_COMPACTION
> -extern int PageMovable(struct page *page);
> +extern bool PageMovable(struct page *page);
> extern void __SetPageMovable(struct page *page, struct address_space *mapping);
> extern void __ClearPageMovable(struct page *page);
> #else
> -static inline int PageMovable(struct page *page) { return 0; };
> +static inline bool PageMovable(struct page *page) { return false; };
> static inline void __SetPageMovable(struct page *page,
> struct address_space *mapping)
> {
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 0bd53fb..cfcfe88 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -95,19 +95,16 @@ static inline bool migrate_async_suitable(int migratetype)
>
> #ifdef CONFIG_COMPACTION
>
> -int PageMovable(struct page *page)
> +bool PageMovable(struct page *page)
> {
> struct address_space *mapping;
>
> VM_BUG_ON_PAGE(!PageLocked(page), page);
> if (!__PageMovable(page))
> - return 0;
> + return false;
>
> mapping = page_mapping(page);
> - if (mapping && mapping->a_ops && mapping->a_ops->isolate_page)
> - return 1;
> -
> - return 0;
> + return mapping && mapping->a_ops && mapping->a_ops->isolate_page;
> }
> EXPORT_SYMBOL(PageMovable);
>
> --
> 1.9.3
>
> --
> 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>
next prev parent reply other threads:[~2016-07-11 0:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-09 15:55 [PATCH] mm: migrate: Use bool instead of int for the return value of PageMovable chengang
2016-07-09 15:55 ` chengang
2016-07-11 0:26 ` Minchan Kim [this message]
2016-07-11 0:26 ` Minchan Kim
2016-07-11 19:47 ` Chen Gang
2016-07-11 19:47 ` Chen Gang
2016-07-12 7:15 ` Vlastimil Babka
2016-07-12 7:15 ` Vlastimil Babka
2016-07-12 16:42 ` Chen Gang
2016-07-12 16:42 ` Chen Gang
2016-07-12 7:48 ` Michal Hocko
2016-07-12 7:48 ` Michal Hocko
2016-07-12 16:50 ` Chen Gang
2016-07-12 16:50 ` Chen Gang
2016-07-13 7:53 ` Michal Hocko
2016-07-13 7:53 ` Michal Hocko
2016-07-17 0:51 ` Chen Gang
2016-07-17 0:51 ` Chen Gang
2016-07-13 14:26 ` 回复:[PATCH] " 陈刚
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=20160711002605.GD31817@bbox \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengang@emindsoft.com.cn \
--cc=gang.chen.5i5j@gmail.com \
--cc=gi-oh.kim@profitbricks.com \
--cc=hillf.zj@alibaba-inc.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=rientjes@google.com \
--cc=vbabka@suse.cz \
/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.