From: Mel Gorman <mgorman@suse.de>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH] compaction: fix build error in CMA && !COMPACTION
Date: Thu, 20 Dec 2012 10:47:07 +0000 [thread overview]
Message-ID: <20121220104707.GB10819@suse.de> (raw)
In-Reply-To: <1355981130-2382-1-git-send-email-minchan@kernel.org>
On Thu, Dec 20, 2012 at 02:25:30PM +0900, Minchan Kim wrote:
> isolate_freepages_block and isolate_migratepages_range is used for CMA
> as well as compaction so it breaks build for CONFIG_CMA &&
> !CONFIG_COMPACTION.
>
> This patch fixes it.
>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>
> ---
> mm/compaction.c | 26 ++++++++++++++++++++------
> 1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 5ad7f4f..70f4443 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -17,6 +17,21 @@
> #include <linux/balloon_compaction.h>
> #include "internal.h"
>
> +#ifdef CONFIG_COMPACTION
> +static inline void count_compact_event(enum vm_event_item item)
> +{
> + count_vm_event(item);
> +}
> +
> +static inline void count_compact_events(enum vm_event_item item, long delta)
> +{
> + count_vm_events(item, delta);
> +}
> +#else
> +#define count_compact_event(item)
> +#define count_compact_events(item, delta)
> +#endif
> +
That should be
do {} while (0)
otherwise a block like this
if (foo)
count_compact_event(COMPACTFREE_SCANNED)
bar;
will get parsed as
if (foo)
bar;
which is wrong.
Now that I look at the do {} while (0) thing it is also strictly speaking
wrong for count_vm_numa_events() too because it would do the wrong thing for
count_compact_events(COMPACTFREE_SCANNED, foo++);
There happens to be no examples where we depend on such side-effects but
I've taken a TODO item to fix it up in the New Year.
--
Mel Gorman
SUSE Labs
--
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: Mel Gorman <mgorman@suse.de>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH] compaction: fix build error in CMA && !COMPACTION
Date: Thu, 20 Dec 2012 10:47:07 +0000 [thread overview]
Message-ID: <20121220104707.GB10819@suse.de> (raw)
In-Reply-To: <1355981130-2382-1-git-send-email-minchan@kernel.org>
On Thu, Dec 20, 2012 at 02:25:30PM +0900, Minchan Kim wrote:
> isolate_freepages_block and isolate_migratepages_range is used for CMA
> as well as compaction so it breaks build for CONFIG_CMA &&
> !CONFIG_COMPACTION.
>
> This patch fixes it.
>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>
> ---
> mm/compaction.c | 26 ++++++++++++++++++++------
> 1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 5ad7f4f..70f4443 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -17,6 +17,21 @@
> #include <linux/balloon_compaction.h>
> #include "internal.h"
>
> +#ifdef CONFIG_COMPACTION
> +static inline void count_compact_event(enum vm_event_item item)
> +{
> + count_vm_event(item);
> +}
> +
> +static inline void count_compact_events(enum vm_event_item item, long delta)
> +{
> + count_vm_events(item, delta);
> +}
> +#else
> +#define count_compact_event(item)
> +#define count_compact_events(item, delta)
> +#endif
> +
That should be
do {} while (0)
otherwise a block like this
if (foo)
count_compact_event(COMPACTFREE_SCANNED)
bar;
will get parsed as
if (foo)
bar;
which is wrong.
Now that I look at the do {} while (0) thing it is also strictly speaking
wrong for count_vm_numa_events() too because it would do the wrong thing for
count_compact_events(COMPACTFREE_SCANNED, foo++);
There happens to be no examples where we depend on such side-effects but
I've taken a TODO item to fix it up in the New Year.
--
Mel Gorman
SUSE Labs
next prev parent reply other threads:[~2012-12-20 10:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-20 5:25 [PATCH] compaction: fix build error in CMA && !COMPACTION Minchan Kim
2012-12-20 5:25 ` Minchan Kim
2012-12-20 10:47 ` Mel Gorman [this message]
2012-12-20 10:47 ` Mel Gorman
2012-12-21 0:49 ` Minchan Kim
2012-12-21 0:49 ` Minchan Kim
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=20121220104707.GB10819@suse.de \
--to=mgorman@suse.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.szyprowski@samsung.com \
--cc=minchan@kernel.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 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.