* [PATCHv3] mm/pageblock: throw compiling time error if pageblock_bits can not hold MIGRATE_TYPES
@ 2018-12-11 6:11 Pingfan Liu
2018-12-14 11:22 ` Vlastimil Babka
0 siblings, 1 reply; 2+ messages in thread
From: Pingfan Liu @ 2018-12-11 6:11 UTC (permalink / raw)
To: linux-mm
Cc: Pingfan Liu, Andrew Morton, Michal Hocko, Pavel Tatashin,
Vlastimil Babka, Oscar Salvador, Mike Rapoport, Joonsoo Kim,
Alexander Duyck
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. Hence it requires some way to fix.
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>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pavel Tatashin <pavel.tatashin@microsoft.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
---
v2->v3:
using '>' instead of "==" option since NR_PAGEBLOCK_BITS allows wasted bits
include/linux/pageblock-flags.h | 3 ++-
mm/page_alloc.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
index 9132c5c..06a6632 100644
--- a/include/linux/pageblock-flags.h
+++ b/include/linux/pageblock-flags.h
@@ -25,10 +25,11 @@
#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,
+ PB_migrate_end = PB_migrate + PB_migratetype_bits - 1,
/* 3 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..29ee87e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -426,6 +426,7 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags,
unsigned long old_word, word;
BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 4);
+ BUILD_BUG_ON(MIGRATE_TYPES > (1 << PB_migratetype_bits));
bitmap = get_pageblock_bitmap(page, pfn);
bitidx = pfn_to_bitidx(page, pfn);
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCHv3] mm/pageblock: throw compiling time error if pageblock_bits can not hold MIGRATE_TYPES
2018-12-11 6:11 [PATCHv3] mm/pageblock: throw compiling time error if pageblock_bits can not hold MIGRATE_TYPES Pingfan Liu
@ 2018-12-14 11:22 ` Vlastimil Babka
0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2018-12-14 11:22 UTC (permalink / raw)
To: Pingfan Liu, linux-mm
Cc: Andrew Morton, Michal Hocko, Pavel Tatashin, Oscar Salvador,
Mike Rapoport, Joonsoo Kim, Alexander Duyck
On 12/11/18 7:11 AM, Pingfan Liu wrote:
> 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. Hence it requires some way to fix.
> 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>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-14 11:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-11 6:11 [PATCHv3] mm/pageblock: throw compiling time error if pageblock_bits can not hold MIGRATE_TYPES Pingfan Liu
2018-12-14 11:22 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox