diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index a2e8a6df7baa..4563cf0626a1 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -75,7 +75,11 @@ extern const char * const migratetype_names[MIGRATE_TYPES]; #ifdef CONFIG_CMA # define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA) -# define is_migrate_cma_page(_page) (get_pageblock_migratetype(_page) == MIGRATE_CMA) +# define is_migrate_cma_page(_page) ({ \ + int mt = get_pageblock_migratetype(_page); \ + bool ret = (mt == MIGRATE_ISOLATE || mt == MIGRATE_CMA) ? true : false; \ + ret; \ +}) # define get_cma_migrate_type() MIGRATE_CMA #else # define is_migrate_cma(migratetype) false diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 644cf26c38aa..0a9bc8437aa7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -480,8 +480,12 @@ unsigned long __get_pfnblock_flags_mask(const struct page *page, bitidx = pfn_to_bitidx(page, pfn); word_bitidx = bitidx / BITS_PER_LONG; bitidx &= (BITS_PER_LONG-1); - - word = bitmap[word_bitidx]; + /* + * This races, without locks, with set_pfnblock_flags_mask(). Ensure + * a consistent read of the memory array, so that results, even though + * racy, are not corrupted. + */ + word = READ_ONCE(bitmap[word_bitidx]); return (word >> bitidx) & mask; }