Re: block/blk-merge.c:166:19: note: in expansion of macro 'page_to_phys'

From: Ming Lei
Date: Wed Jan 29 2020 - 06:33:34 EST


On Mon, Jan 27, 2020 at 02:38:58PM +0800, kbuild test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: d5226fa6dbae0569ee43ecfc08bdcd6770fc4755
> commit: 429120f3df2dba2bf3a4a19f4212a53ecefc7102 block: fix splitting segments on boundary masks
> date: 4 weeks ago
> config: riscv-randconfig-a001-20200127 (attached as .config)
> compiler: riscv64-linux-gcc (GCC) 7.5.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout 429120f3df2dba2bf3a4a19f4212a53ecefc7102
> # save the attached .config to linux build tree
> GCC_VERSION=7.5.0 make.cross ARCH=riscv
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@xxxxxxxxx>
>
> All warnings (new ones prefixed by >>):
>
> from include/asm-generic/preempt.h:5,
> from ./arch/riscv/include/generated/asm/preempt.h:1,
> from include/linux/preempt.h:78,
> from include/linux/spinlock.h:51,
> from include/linux/seqlock.h:36,
> from include/linux/time.h:6,
> from include/linux/stat.h:19,
> from include/linux/module.h:13,
> from block/blk-merge.c:6:
> include/linux/scatterlist.h: In function 'sg_phys':
> include/asm-generic/memory_model.h:55:54: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
> #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
> ^
> include/linux/pfn.h:21:36: note: in definition of macro 'PFN_PHYS'
> #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
> ^
> arch/riscv/include/asm/page.h:115:29: note: in expansion of macro 'pfn_to_phys'
> #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
> ^~~~~~~~~~~
> include/asm-generic/memory_model.h:81:21: note: in expansion of macro '__page_to_pfn'
> #define page_to_pfn __page_to_pfn
> ^~~~~~~~~~~~~
> arch/riscv/include/asm/page.h:115:41: note: in expansion of macro 'page_to_pfn'
> #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
> ^~~~~~~~~~~
> include/linux/scatterlist.h:224:9: note: in expansion of macro 'page_to_phys'
> return page_to_phys(sg_page(sg)) + sg->offset;
> ^~~~~~~~~~~~
> In file included from arch/riscv/include/asm/page.h:131:0,
> from arch/riscv/include/asm/thread_info.h:11,
> from include/linux/thread_info.h:38,
> from include/asm-generic/preempt.h:5,
> from ./arch/riscv/include/generated/asm/preempt.h:1,
> from include/linux/preempt.h:78,
> from include/linux/spinlock.h:51,
> from include/linux/seqlock.h:36,
> from include/linux/time.h:6,
> from include/linux/stat.h:19,
> from include/linux/module.h:13,
> from block/blk-merge.c:6:
> include/linux/scatterlist.h: In function 'sg_page_iter_page':
> include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
> #define __pfn_to_page(pfn) (vmemmap + (pfn))
> ^
> include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
> #define pfn_to_page __pfn_to_page
> ^~~~~~~~~~~~~
> include/linux/mm.h:213:26: note: in expansion of macro 'pfn_to_page'
> #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
> ^~~~~~~~~~~
> include/linux/scatterlist.h:384:9: note: in expansion of macro 'nth_page'
> return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
> ^~~~~~~~
> In file included from arch/riscv/include/asm/page.h:12:0,
> from arch/riscv/include/asm/thread_info.h:11,
> from include/linux/thread_info.h:38,
> from include/asm-generic/preempt.h:5,
> from ./arch/riscv/include/generated/asm/preempt.h:1,
> from include/linux/preempt.h:78,
> from include/linux/spinlock.h:51,
> from include/linux/seqlock.h:36,
> from include/linux/time.h:6,
> from include/linux/stat.h:19,
> from include/linux/module.h:13,
> from block/blk-merge.c:6:
> block/blk.h: In function 'biovec_phys_mergeable':
> include/asm-generic/memory_model.h:55:54: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
> #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
> ^
> include/linux/pfn.h:21:36: note: in definition of macro 'PFN_PHYS'
> #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
> ^
> arch/riscv/include/asm/page.h:115:29: note: in expansion of macro 'pfn_to_phys'
> #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
> ^~~~~~~~~~~
> include/asm-generic/memory_model.h:81:21: note: in expansion of macro '__page_to_pfn'
> #define page_to_pfn __page_to_pfn
> ^~~~~~~~~~~~~
> arch/riscv/include/asm/page.h:115:41: note: in expansion of macro 'page_to_pfn'
> #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
> ^~~~~~~~~~~
> block/blk.h:79:22: note: in expansion of macro 'page_to_phys'
> phys_addr_t addr1 = page_to_phys(vec1->bv_page) + vec1->bv_offset;
> ^~~~~~~~~~~~
> block/blk-merge.c: In function 'get_max_segment_size':
> include/asm-generic/memory_model.h:55:54: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
> #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
> ^
> include/linux/pfn.h:21:36: note: in definition of macro 'PFN_PHYS'
> #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
> ^
> arch/riscv/include/asm/page.h:115:29: note: in expansion of macro 'pfn_to_phys'
> #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
> ^~~~~~~~~~~
> include/asm-generic/memory_model.h:81:21: note: in expansion of macro '__page_to_pfn'
> #define page_to_pfn __page_to_pfn
> ^~~~~~~~~~~~~
> arch/riscv/include/asm/page.h:115:41: note: in expansion of macro 'page_to_pfn'
> #define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
> ^~~~~~~~~~~
> >> block/blk-merge.c:166:19: note: in expansion of macro 'page_to_phys'
> offset = mask & (page_to_phys(start_page) + offset);
> ^~~~~~~~~~~~
> In file included from arch/riscv/include/asm/page.h:131:0,
> from arch/riscv/include/asm/thread_info.h:11,
> from include/linux/thread_info.h:38,
> from include/asm-generic/preempt.h:5,
> from ./arch/riscv/include/generated/asm/preempt.h:1,
> from include/linux/preempt.h:78,
> from include/linux/spinlock.h:51,
> from include/linux/seqlock.h:36,
> from include/linux/time.h:6,
> from include/linux/stat.h:19,
> from include/linux/module.h:13,
> from block/blk-merge.c:6:
> block/blk-merge.c: In function 'blk_rq_map_sg':
> include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'vm_mmap'?
> #define __pfn_to_page(pfn) (vmemmap + (pfn))
> ^
> include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
> #define pfn_to_page __pfn_to_page
> ^~~~~~~~~~~~~
> arch/riscv/include/asm/page.h:112:30: note: in expansion of macro 'pfn_to_page'
> #define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
> ^~~~~~~~~~~
> block/blk-merge.c:545:19: note: in expansion of macro 'virt_to_page'
> sg_set_page(sg, virt_to_page(q->dma_drain_buffer),
> ^~~~~~~~~~~~
>
> vim +/page_to_phys +166 block/blk-merge.c
>
> 159
> 160 static inline unsigned get_max_segment_size(const struct request_queue *q,
> 161 struct page *start_page,
> 162 unsigned long offset)
> 163 {
> 164 unsigned long mask = queue_segment_boundary(q);
> 165
> > 166 offset = mask & (page_to_phys(start_page) + offset);
> 167 return min_t(unsigned long, mask - offset + 1,
> 168 queue_max_segment_size(q));
> 169 }
> 170
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx Intel Corporation

Hello,

Thanks for your report!

Could you test the following patch?

diff --git a/block/blk-merge.c b/block/blk-merge.c
index d783bdc4559b..e693d64e2565 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -7,6 +7,7 @@
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <linux/scatterlist.h>
+#include <linux/mm.h>

#include <trace/events/block.h>



Thanks,
Ming