Re: [PATCH 3/3] mm: make pfn walker support ZONE_DEVICE

From: kbuild test robot
Date: Sat Nov 09 2019 - 14:14:43 EST


Hi Toshiki,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc6 next-20191108]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Toshiki-Fukasawa/make-pfn-walker-support-ZONE_DEVICE/20191110-000508
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0058b0a506e40d9a2c62015fe92eb64a44d78cd9
config: i386-randconfig-b002-201945 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-14) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

fs/proc/page.c: In function 'kpage_common_read':
>> fs/proc/page.c:46:17: error: implicit declaration of function 'pfn_zone_device'; did you mean 'pgprot_device'? [-Werror=implicit-function-declaration]
if (!ppage && pfn_zone_device(pfn)) {
^~~~~~~~~~~~~~~
pgprot_device
Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
Cyclomatic Complexity 1 include/linux/kasan-checks.h:kasan_check_read
Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:constant_test_bit
Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:variable_test_bit
Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_read
Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_read
Cyclomatic Complexity 1 include/linux/page-flags.h:PageTail
Cyclomatic Complexity 3 include/linux/page-flags.h:PageCompound
Cyclomatic Complexity 1 include/linux/page-flags.h:PageLRU
Cyclomatic Complexity 1 include/linux/page-flags.h:PageSlab
Cyclomatic Complexity 1 include/linux/page-flags.h:PageSwapCache
Cyclomatic Complexity 1 include/linux/page-flags.h:PageAnon
Cyclomatic Complexity 1 include/linux/page-flags.h:PageKsm
Cyclomatic Complexity 1 include/linux/page-flags.h:PageHead
Cyclomatic Complexity 1 include/linux/page-flags.h:PageTransCompound
Cyclomatic Complexity 1 include/linux/page-flags.h:page_has_type
Cyclomatic Complexity 1 include/linux/page-flags.h:PageBuddy
Cyclomatic Complexity 1 include/linux/page-flags.h:PageOffline
Cyclomatic Complexity 1 include/linux/page-flags.h:PageTable
Cyclomatic Complexity 1 include/linux/memremap.h:nr_valid_pages_zone_device
Cyclomatic Complexity 1 include/linux/sched.h:_cond_resched
Cyclomatic Complexity 1 include/asm-generic/pgtable.h:is_zero_pfn
Cyclomatic Complexity 1 include/linux/huge_mm.h:is_huge_zero_page
Cyclomatic Complexity 1 fs/proc/page.c:kpf_copy_bit
Cyclomatic Complexity 2 include/asm-generic/bitops-instrumented.h:test_bit
Cyclomatic Complexity 2 include/linux/page_idle.h:page_is_idle
Cyclomatic Complexity 2 include/linux/page-flags.h:compound_head
Cyclomatic Complexity 1 include/linux/page_ref.h:page_count
Cyclomatic Complexity 1 fs/proc/page.c:proc_page_init
Cyclomatic Complexity 12 fs/proc/page.c:kpage_common_read
Cyclomatic Complexity 1 fs/proc/page.c:kpageflags_read
Cyclomatic Complexity 1 fs/proc/page.c:kpagecount_read
Cyclomatic Complexity 2 include/linux/mm.h:page_mapcount
Cyclomatic Complexity 4 fs/proc/page.c:page_count_data
Cyclomatic Complexity 23 fs/proc/page.c:stable_page_flags
Cyclomatic Complexity 1 fs/proc/page.c:page_flags_data
cc1: some warnings being treated as errors

vim +46 fs/proc/page.c

25
26 /*
27 * This is general function to read various data on pages.
28 */
29 static ssize_t kpage_common_read(struct file *file, char __user *buf,
30 size_t count, loff_t *ppos, read_page_data_fn_t read_fn)
31 {
32 u64 __user *out = (u64 __user *)buf;
33 struct page *ppage;
34 unsigned long src = *ppos;
35 unsigned long pfn;
36 unsigned long valid_pages = 0;
37 ssize_t ret = 0;
38
39 pfn = src / KPMSIZE;
40 count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
41 if (src & KPMMASK || count & KPMMASK)
42 return -EINVAL;
43
44 while (count > 0) {
45 ppage = pfn_to_online_page(pfn);
> 46 if (!ppage && pfn_zone_device(pfn)) {
47 /*
48 * Skip to read first few uninitialized pages on
49 * ZONE_DEVICE. And count valid pages starting
50 * with the pfn so that minimize the number of
51 * calls to nr_valid_pages_zone_device().
52 */
53 if (!valid_pages)
54 valid_pages = nr_valid_pages_zone_device(pfn);
55 if (valid_pages) {
56 ppage = pfn_to_page(pfn);
57 valid_pages--;
58 }
59 } else if (valid_pages) {
60 /* ZONE_DEVICE has been hot removed */
61 valid_pages = 0;
62 }
63
64 if (put_user(read_fn(ppage), out)) {
65 ret = -EFAULT;
66 break;
67 }
68
69 pfn++;
70 out++;
71 count -= KPMSIZE;
72
73 cond_resched();
74 }
75
76 *ppos += (char __user *)out - buf;
77 if (!ret)
78 ret = (char __user *)out - buf;
79 return ret;
80 }
81

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

Attachment: .config.gz
Description: application/gzip