Re: [PATCH v2 2/2] mm, memory_hotplug: optimize memory hotplug

From: kbuild test robot
Date: Thu Feb 01 2018 - 23:50:11 EST


Hi Pavel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mmotm/master]
[also build test WARNING on next-20180201]
[cannot apply to v4.15]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Pavel-Tatashin/mm-uninitialized-struct-page-poisoning-sanity-checking/20180202-105827
base: git://git.cmpxchg.org/linux-mmotm.git master
config: x86_64-randconfig-x019-201804 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All warnings (new ones prefixed by >>):

In file included from include/linux/page_ref.h:7:0,
from include/linux/mm.h:26,
from mm/sparse.c:5:
mm/sparse.c: In function 'sparse_add_one_section':
include/linux/page-flags.h:159:29: warning: overflow in implicit constant conversion [-Woverflow]
#define PAGE_POISON_PATTERN ~0ul
^
>> mm/sparse.c:838:17: note: in expansion of macro 'PAGE_POISON_PATTERN'
memset(memmap, PAGE_POISON_PATTERN,
^~~~~~~~~~~~~~~~~~~
Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64
Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u64
Cyclomatic Complexity 3 include/linux/log2.h:is_power_of_2
Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
Cyclomatic Complexity 3 include/linux/string.h:memset
Cyclomatic Complexity 1 include/linux/spinlock.h:spinlock_check
Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock_irqrestore
Cyclomatic Complexity 1 include/linux/nodemask.h:node_state
Cyclomatic Complexity 1 include/linux/memory_hotplug.h:pgdat_resize_lock
Cyclomatic Complexity 1 include/linux/memory_hotplug.h:pgdat_resize_unlock
Cyclomatic Complexity 1 include/linux/mmzone.h:pfn_to_section_nr
Cyclomatic Complexity 1 include/linux/mmzone.h:section_nr_to_pfn
Cyclomatic Complexity 3 include/linux/mmzone.h:__nr_to_section
Cyclomatic Complexity 1 include/linux/mmzone.h:__section_mem_map_addr
Cyclomatic Complexity 3 include/linux/mmzone.h:present_section
Cyclomatic Complexity 1 include/linux/mmzone.h:present_section_nr
Cyclomatic Complexity 3 include/linux/mmzone.h:valid_section
Cyclomatic Complexity 1 include/linux/mmzone.h:valid_section_nr
Cyclomatic Complexity 1 include/linux/mmzone.h:__pfn_to_section
Cyclomatic Complexity 2 include/linux/mmzone.h:pfn_present
Cyclomatic Complexity 1 arch/x86/include/asm/topology.h:numa_node_id
Cyclomatic Complexity 1 include/linux/topology.h:numa_mem_id
Cyclomatic Complexity 1 include/linux/mm.h:is_vmalloc_addr
Cyclomatic Complexity 1 include/linux/mm.h:page_to_section
Cyclomatic Complexity 28 include/linux/slab.h:kmalloc_index
Cyclomatic Complexity 1 include/linux/slab.h:__kmalloc_node
Cyclomatic Complexity 1 include/linux/slab.h:kmem_cache_alloc_node_trace
Cyclomatic Complexity 68 include/linux/slab.h:kmalloc_large
Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
Cyclomatic Complexity 5 include/linux/slab.h:kmalloc_node
Cyclomatic Complexity 1 include/linux/slab.h:kzalloc_node
Cyclomatic Complexity 1 include/linux/bootmem.h:alloc_remap
Cyclomatic Complexity 1 mm/sparse.c:set_section_nid
Cyclomatic Complexity 1 mm/sparse.c:sparse_encode_early_nid
Cyclomatic Complexity 1 mm/sparse.c:sparse_early_nid
Cyclomatic Complexity 4 mm/sparse.c:next_present_section_nr
Cyclomatic Complexity 1 mm/sparse.c:check_usemap_section_nr
Cyclomatic Complexity 6 mm/sparse.c:alloc_usemap_and_memmap
Cyclomatic Complexity 1 include/linux/bootmem.h:memblock_virt_alloc
Cyclomatic Complexity 1 include/linux/bootmem.h:memblock_virt_alloc_node
Cyclomatic Complexity 2 mm/sparse.c:sparse_index_alloc
Cyclomatic Complexity 3 mm/sparse.c:sparse_index_init
Cyclomatic Complexity 1 include/linux/bootmem.h:memblock_virt_alloc_node_nopanic
Cyclomatic Complexity 1 mm/sparse.c:sparse_early_usemaps_alloc_pgdat_section
Cyclomatic Complexity 2 mm/sparse.c:sparse_encode_mem_map
Cyclomatic Complexity 2 mm/sparse.c:sparse_init_one_section
Cyclomatic Complexity 1 include/linux/bootmem.h:memblock_free_early
Cyclomatic Complexity 1 include/linux/gfp.h:__alloc_pages
Cyclomatic Complexity 2 include/linux/gfp.h:__alloc_pages_node
Cyclomatic Complexity 2 include/linux/gfp.h:alloc_pages_node
Cyclomatic Complexity 70 mm/sparse.c:__kmalloc_section_memmap
Cyclomatic Complexity 1 mm/sparse.c:kmalloc_section_memmap
Cyclomatic Complexity 2 mm/sparse.c:__kfree_section_memmap
Cyclomatic Complexity 3 mm/sparse.c:get_section_nid
Cyclomatic Complexity 5 mm/sparse.c:__section_nr
Cyclomatic Complexity 2 mm/sparse.c:section_mark_present
Cyclomatic Complexity 7 mm/sparse.c:mminit_validate_memmodel_limits
Cyclomatic Complexity 4 mm/sparse.c:node_memmap_size_bytes
Cyclomatic Complexity 4 mm/sparse.c:memory_present
Cyclomatic Complexity 1 mm/sparse.c:sparse_decode_mem_map
Cyclomatic Complexity 1 mm/sparse.c:usemap_size
Cyclomatic Complexity 4 mm/sparse.c:sparse_early_usemaps_alloc_node
Cyclomatic Complexity 1 mm/sparse.c:__kmalloc_section_usemap
Cyclomatic Complexity 2 mm/sparse.c:sparse_mem_map_populate
Cyclomatic Complexity 10 mm/sparse.c:sparse_mem_maps_populate_node
Cyclomatic Complexity 1 mm/sparse.c:sparse_early_mem_maps_alloc_node
Cyclomatic Complexity 1 mm/sparse.c:vmemmap_populate_print_last
Cyclomatic Complexity 6 mm/sparse.c:sparse_init
Cyclomatic Complexity 4 mm/sparse.c:online_mem_sections
Cyclomatic Complexity 6 mm/sparse.c:sparse_add_one_section

vim +/PAGE_POISON_PATTERN +838 mm/sparse.c

793
794 /*
795 * returns the number of sections whose mem_maps were properly
796 * set. If this is <=0, then that means that the passed-in
797 * map was not consumed and must be freed.
798 */
799 int __meminit sparse_add_one_section(struct pglist_data *pgdat,
800 unsigned long start_pfn, struct vmem_altmap *altmap)
801 {
802 unsigned long section_nr = pfn_to_section_nr(start_pfn);
803 struct mem_section *ms;
804 struct page *memmap;
805 unsigned long *usemap;
806 unsigned long flags;
807 int ret;
808
809 /*
810 * no locking for this, because it does its own
811 * plus, it does a kmalloc
812 */
813 ret = sparse_index_init(section_nr, pgdat->node_id);
814 if (ret < 0 && ret != -EEXIST)
815 return ret;
816 memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, altmap);
817 if (!memmap)
818 return -ENOMEM;
819 usemap = __kmalloc_section_usemap();
820 if (!usemap) {
821 __kfree_section_memmap(memmap, altmap);
822 return -ENOMEM;
823 }
824
825 pgdat_resize_lock(pgdat, &flags);
826
827 ms = __pfn_to_section(start_pfn);
828 if (ms->section_mem_map & SECTION_MARKED_PRESENT) {
829 ret = -EEXIST;
830 goto out;
831 }
832
833 #ifdef CONFIG_DEBUG_VM
834 /*
835 * poison uninitialized struct pages in order to catch invalid flags
836 * combinations.
837 */
> 838 memset(memmap, PAGE_POISON_PATTERN,
839 sizeof(struct page) * PAGES_PER_SECTION);
840 #endif
841
842 section_mark_present(ms);
843
844 ret = sparse_init_one_section(ms, section_nr, memmap, usemap);
845
846 out:
847 pgdat_resize_unlock(pgdat, &flags);
848 if (ret <= 0) {
849 kfree(usemap);
850 __kfree_section_memmap(memmap, altmap);
851 } else {
852 set_section_nid(section_nr, pgdat->node_id);
853 }
854 return ret;
855 }
856

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip