Hi Nhat, I love your patch! Perhaps something to improve: [auto build test WARNING on shuah-kselftest/next] [also build test WARNING on shuah-kselftest/fixes tip/x86/asm akpm-mm/mm-everything linus/master v6.1-rc8 next-20221206] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Nhat-Pham/cachestat-a-new-syscall-for-page-cache-state-of-files/20221206-015308 base: https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next patch link: https://lore.kernel.org/r/20221205175140.1543229-4-nphamcs%40gmail.com patch subject: [PATCH v2 3/4] cachestat: implement cachestat syscall config: i386-randconfig-m021-20221205 compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot smatch warnings: mm/cachestat.c:53 __do_sys_cachestat() warn: unsigned 'len' is never less than zero. mm/cachestat.c:55 __do_sys_cachestat() warn: unsigned 'cstat_size' is never less than zero. mm/cachestat.c:53 __do_sys_cachestat() warn: unsigned 'len' is never less than zero. mm/cachestat.c:55 __do_sys_cachestat() warn: unsigned 'cstat_size' is never less than zero. vim +/len +53 mm/cachestat.c 15 16 /* 17 * The cachestat(4) system call. 18 * 19 * cachestat() returns the page cache status of a file in the 20 * bytes specified by `off` and `len`: number of cached pages, 21 * number of dirty pages, number of pages marked for writeback, 22 * number of (recently) evicted pages. 23 * 24 * `off` and `len` must be non-negative integers. If `len` > 0, 25 * the queried range is [`off`, `off` + `len`]. If `len` == 0, 26 * we will query in the range from `off` to the end of the file. 27 * 28 * `cstat_size` allows users to obtain partial results. The syscall 29 * will copy the first `csstat_size` bytes to the specified userspace 30 * memory. It also makes the cachestat struct extensible - new fields 31 * can be added in the future without breaking existing usage. 32 * `cstat_size` must be a non-negative value that is no larger than 33 * the current size of the cachestat struct. 34 * 35 * Because the status of a page can change after cachestat() checks it 36 * but before it returns to the application, the returned values may 37 * contain stale information. 38 * 39 * return values: 40 * zero - success 41 * -EFAULT - cstat points to an illegal address 42 * -EINVAL - invalid arguments 43 * -EBADF - invalid file descriptor 44 */ 45 SYSCALL_DEFINE5(cachestat, unsigned int, fd, off_t, off, size_t, len, 46 size_t, cstat_size, struct cachestat __user *, cstat) 47 { 48 struct fd f; 49 struct cachestat cs; 50 51 memset(&cs, 0, sizeof(struct cachestat)); 52 > 53 if (off < 0 || len < 0 || 54 cstat_size > sizeof(struct cachestat) || > 55 cstat_size < 0) 56 return -EINVAL; 57 58 if (!access_ok(cstat, sizeof(struct cachestat))) 59 return -EFAULT; 60 61 f = fdget(fd); 62 if (f.file) { 63 struct address_space *mapping = f.file->f_mapping; 64 pgoff_t first_index = off >> PAGE_SHIFT; 65 pgoff_t last_index = 66 len == 0 ? ULONG_MAX : (off + len - 1) >> PAGE_SHIFT; 67 XA_STATE(xas, &mapping->i_pages, first_index); 68 struct folio *folio; 69 70 rcu_read_lock(); 71 xas_for_each(&xas, folio, last_index) { 72 if (xas_retry(&xas, folio) || !folio) 73 continue; 74 75 if (xa_is_value(folio)) { 76 /* page is evicted */ 77 void *shadow = (void *)folio; 78 bool workingset; /* not used */ 79 80 cs.nr_evicted += 1; 81 -- 0-DAY CI Kernel Test Service https://01.org/lkp