From: Pingfan Liu <kernelfans@gmail.com>
To: linux-mm@kvack.org
Cc: Pingfan Liu <kernelfans@gmail.com>
Subject: [PATCH] mm/pageblock: throw compiling time error if pageblock_bits can not hold MIGRATE_TYPES
Date: Wed, 5 Dec 2018 16:05:55 +0800 [thread overview]
Message-ID: <1543997155-18344-1-git-send-email-kernelfans@gmail.com> (raw)
Currently, NR_PAGEBLOCK_BITS and MIGRATE_TYPES are not associated by code.
If someone adds extra migrate type, then he may forget to enlarge the
NR_PAGEBLOCK_BITS.
NR_PAGEBLOCK_BITS depends on MIGRATE_TYPES, while these macro
spread on two different .h file with reverse dependency, it is a little
hard to refer to MIGRATE_TYPES in pageblock-flag.h. This patch tries to
remind such relation in compiling-time.
Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
---
include/linux/pageblock-flags.h | 5 +++--
mm/page_alloc.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
index 9132c5c..fe0aec4 100644
--- a/include/linux/pageblock-flags.h
+++ b/include/linux/pageblock-flags.h
@@ -25,11 +25,12 @@
#include <linux/types.h>
+#define PB_migratetype_bits 3
/* Bit indices that affect a whole block of pages */
enum pageblock_bits {
PB_migrate,
- PB_migrate_end = PB_migrate + 3 - 1,
- /* 3 bits required for migrate types */
+ PB_migrate_end = PB_migrate + PB_migratetype_bits - 1,
+ /* n bits required for migrate types */
PB_migrate_skip,/* If set the block is skipped by compaction */
/*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2ec9cc4..537020f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -425,7 +425,7 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags,
unsigned long bitidx, word_bitidx;
unsigned long old_word, word;
- BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 4);
+ BUILD_BUG_ON(order_base_2(MIGRATE_TYPES) != PB_migratetype_bits);
bitmap = get_pageblock_bitmap(page, pfn);
bitidx = pfn_to_bitidx(page, pfn);
--
2.7.4
next reply other threads:[~2018-12-05 8:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-05 8:05 Pingfan Liu [this message]
2018-12-06 20:27 ` kbuild test robot
2018-12-07 4:49 ` Pingfan Liu
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=1543997155-18344-1-git-send-email-kernelfans@gmail.com \
--to=kernelfans@gmail.com \
--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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox