The patch titled Subject: mm: section numbers use the type "unsigned long" has been added to the -mm tree. Its filename is mm-section-numbers-use-the-type-unsigned-long.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-section-numbers-use-the-type-unsigned-long.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-section-numbers-use-the-type-unsigned-long.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: David Hildenbrand <david@xxxxxxxxxx> Subject: mm: section numbers use the type "unsigned long" Patch series "mm: Further memory block device cleanups", v1. Some further cleanups around memory block devices. Especially, clean up and simplify walk_memory_range(). Including some other minor cleanups. This patch (of 6): We are using a mixture of "int" and "unsigned long". Let's make this consistent by using "unsigned long" everywhere. We'll do the same with memory block ids next. Link: http://lkml.kernel.org/r/20190614100114.311-2-david@xxxxxxxxxx Signed-off-by: David Hildenbrand <david@xxxxxxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Wei Yang <richard.weiyang@xxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Arun KS <arunks@xxxxxxxxxxxxxx> Cc: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> Cc: Oscar Salvador <osalvador@xxxxxxx> Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx> Cc: Baoquan He <bhe@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/base/memory.c | 9 +++++---- include/linux/mmzone.h | 4 ++-- mm/sparse.c | 12 ++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) --- a/drivers/base/memory.c~mm-section-numbers-use-the-type-unsigned-long +++ a/drivers/base/memory.c @@ -34,7 +34,7 @@ static DEFINE_MUTEX(mem_sysfs_mutex); static int sections_per_block; -static inline int base_memory_block_id(int section_nr) +static inline int base_memory_block_id(unsigned long section_nr) { return section_nr / sections_per_block; } @@ -691,10 +691,11 @@ static int init_memory_block(struct memo return ret; } -static int add_memory_block(int base_section_nr) +static int add_memory_block(unsigned long base_section_nr) { + int ret, section_count = 0; struct memory_block *mem; - int i, ret, section_count = 0; + unsigned long i; for (i = base_section_nr; i < base_section_nr + sections_per_block; @@ -822,7 +823,7 @@ static const struct attribute_group *mem */ int __init memory_dev_init(void) { - unsigned int i; + unsigned long i; int ret; int err; unsigned long block_sz; --- a/include/linux/mmzone.h~mm-section-numbers-use-the-type-unsigned-long +++ a/include/linux/mmzone.h @@ -1220,7 +1220,7 @@ static inline struct mem_section *__nr_t return NULL; return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; } -extern int __section_nr(struct mem_section* ms); +extern unsigned long __section_nr(struct mem_section *ms); extern unsigned long usemap_size(void); /* @@ -1292,7 +1292,7 @@ static inline struct mem_section *__pfn_ return __nr_to_section(pfn_to_section_nr(pfn)); } -extern int __highest_present_section_nr; +extern unsigned long __highest_present_section_nr; #ifndef CONFIG_HAVE_ARCH_PFN_VALID static inline int pfn_valid(unsigned long pfn) --- a/mm/sparse.c~mm-section-numbers-use-the-type-unsigned-long +++ a/mm/sparse.c @@ -102,7 +102,7 @@ static inline int sparse_index_init(unsi #endif #ifdef CONFIG_SPARSEMEM_EXTREME -int __section_nr(struct mem_section* ms) +unsigned long __section_nr(struct mem_section *ms) { unsigned long root_nr; struct mem_section *root = NULL; @@ -121,9 +121,9 @@ int __section_nr(struct mem_section* ms) return (root_nr * SECTIONS_PER_ROOT) + (ms - root); } #else -int __section_nr(struct mem_section* ms) +unsigned long __section_nr(struct mem_section *ms) { - return (int)(ms - mem_section[0]); + return (unsigned long)(ms - mem_section[0]); } #endif @@ -178,10 +178,10 @@ void __meminit mminit_validate_memmodel_ * Keeping track of this gives us an easy way to break out of * those loops early. */ -int __highest_present_section_nr; +unsigned long __highest_present_section_nr; static void section_mark_present(struct mem_section *ms) { - int section_nr = __section_nr(ms); + unsigned long section_nr = __section_nr(ms); if (section_nr > __highest_present_section_nr) __highest_present_section_nr = section_nr; @@ -189,7 +189,7 @@ static void section_mark_present(struct ms->section_mem_map |= SECTION_MARKED_PRESENT; } -static inline int next_present_section_nr(int section_nr) +static inline unsigned long next_present_section_nr(unsigned long section_nr) { do { section_nr++; _ Patches currently in -mm which might be from david@xxxxxxxxxx are mm-memory_hotplug-simplify-and-fix-check_hotplug_memory_range.patch s390x-mm-fail-when-an-altmap-is-used-for-arch_add_memory.patch s390x-mm-implement-arch_remove_memory.patch arm64-mm-add-temporary-arch_remove_memory-implementation.patch drivers-base-memory-pass-a-block_id-to-init_memory_block.patch mm-memory_hotplug-allow-arch_remove_pages-without-config_memory_hotremove.patch mm-memory_hotplug-create-memory-block-devices-after-arch_add_memory.patch mm-memory_hotplug-drop-mhp_memblock_api.patch mm-memory_hotplug-remove-memory-block-devices-before-arch_remove_memory.patch mm-memory_hotplug-make-unregister_memory_block_under_nodes-never-fail.patch mm-memory_hotplug-remove-zone-parameter-from-sparse_remove_one_section.patch mm-section-numbers-use-the-type-unsigned-long.patch drivers-base-memory-use-unsigned-long-for-block-ids.patch mm-make-register_mem_sect_under_node-static.patch mm-memory_hotplug-rename-walk_memory_range-and-pass-startsize-instead-of-pfns.patch mm-memory_hotplug-move-and-simplify-walk_memory_blocks.patch drivers-base-memoryc-get-rid-of-find_memory_block_hinted.patch