From: Wei Yang <richard.weiyang@linux.alibaba.com> Date: Fri, 7 Aug 2020 06:25:44 +0000 (-0700) Subject: mm/page_alloc.c: extract the common part in pfn_to_bitidx() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=399b795b7a80bf703aae56fa0b66fd1949ca1fd9;p=linux.git mm/page_alloc.c: extract the common part in pfn_to_bitidx() The return value calculation is the same both for SPARSEMEM or not. Just take it out. Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Mel Gorman <mgorman@suse.de> Link: http://lkml.kernel.org/r/20200623124201.8199-2-richard.weiyang@linux.alibaba.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ba09a3aeb76b0..6c524fb76b317 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -459,11 +459,10 @@ static inline int pfn_to_bitidx(struct page *page, unsigned long pfn) { #ifdef CONFIG_SPARSEMEM pfn &= (PAGES_PER_SECTION-1); - return (pfn >> pageblock_order) * NR_PAGEBLOCK_BITS; #else pfn = pfn - round_down(page_zone(page)->zone_start_pfn, pageblock_nr_pages); - return (pfn >> pageblock_order) * NR_PAGEBLOCK_BITS; #endif /* CONFIG_SPARSEMEM */ + return (pfn >> pageblock_order) * NR_PAGEBLOCK_BITS; } /**