CC: llvm(a)lists.linux.dev CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Yangtao Li CC: Jaegeuk Kim CC: Shuosheng Huang CC: Chao Yu , Chao Yu tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 1a6436f375129a96adcc492013a466b934fcad79 commit: db48965264110dd74d1436fc21dac328d04385d2 f2fs: Remove unnecessary unlikely() date: 9 months ago :::::: branch date: 7 hours ago :::::: commit date: 9 months ago config: mips-randconfig-c004-20210824 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d26000e4cc2bc65e207a84fa26cb6e374d60aa12) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install mips cross compiling tool for clang build # apt-get install binutils-mips-linux-gnu # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=db48965264110dd74d1436fc21dac328d04385d2 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout db48965264110dd74d1436fc21dac328d04385d2 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot clang-analyzer warnings: (new ones prefixed by >>) fs/f2fs/compress.c:1000:8: note: Calling 'f2fs_init_compress_ctx' ret = f2fs_init_compress_ctx(cc); ^~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:160:10: note: Field 'rpages' is null if (cc->rpages) ^ fs/f2fs/compress.c:160:2: note: Taking false branch if (cc->rpages) ^ fs/f2fs/compress.c:163:15: note: Calling 'page_array_alloc' cc->rpages = page_array_alloc(cc->inode, cc->cluster_size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:28:13: note: Assuming 'size' is > field 'page_array_slab_size' if (likely(size <= sbi->page_array_slab_size)) ^ include/linux/compiler.h:77:40: note: expanded from macro 'likely' # define likely(x) __builtin_expect(!!(x), 1) ^ fs/f2fs/compress.c:28:2: note: Taking false branch if (likely(size <= sbi->page_array_slab_size)) ^ fs/f2fs/compress.c:30:9: note: Calling 'f2fs_kzalloc' return f2fs_kzalloc(sbi, size, GFP_NOFS); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/f2fs.h:2969:9: note: Calling 'f2fs_kmalloc' return f2fs_kmalloc(sbi, size, flags | __GFP_ZERO); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/f2fs.h:2958:2: note: Taking false branch if (time_to_inject(sbi, FAULT_KMALLOC)) { ^ fs/f2fs/f2fs.h:2963:9: note: Storing uninitialized value return kmalloc(size, flags); ^~~~~~~~~~~~~~~~~~~~ fs/f2fs/f2fs.h:2969:9: note: Returning from 'f2fs_kmalloc' return f2fs_kmalloc(sbi, size, flags | __GFP_ZERO); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:30:9: note: Returning from 'f2fs_kzalloc' return f2fs_kzalloc(sbi, size, GFP_NOFS); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:163:15: note: Returning from 'page_array_alloc' cc->rpages = page_array_alloc(cc->inode, cc->cluster_size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:164:9: note: Assuming field 'rpages' is non-null return cc->rpages ? 0 : -ENOMEM; ^~~~~~~~~~ fs/f2fs/compress.c:164:9: note: '?' condition is true fs/f2fs/compress.c:1000:8: note: Returning from 'f2fs_init_compress_ctx' ret = f2fs_init_compress_ctx(cc); ^~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:1001:6: note: 'ret' is 0 if (ret) ^~~ fs/f2fs/compress.c:1001:2: note: Taking false branch if (ret) ^ fs/f2fs/compress.c:1005:14: note: Assuming 'i' is < field 'cluster_size' for (i = 0; i < cc->cluster_size; i++) { ^~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:1005:2: note: Loop condition is true. Entering loop body for (i = 0; i < cc->cluster_size; i++) { ^ fs/f2fs/compress.c:1008:7: note: Assuming 'page' is non-null if (!page) { ^~~~~ fs/f2fs/compress.c:1008:3: note: Taking false branch if (!page) { ^ fs/f2fs/compress.c:1013:3: note: Taking true branch if (PageUptodate(page)) ^ fs/f2fs/compress.c:1005:14: note: Assuming 'i' is < field 'cluster_size' for (i = 0; i < cc->cluster_size; i++) { ^~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:1005:2: note: Loop condition is true. Entering loop body for (i = 0; i < cc->cluster_size; i++) { ^ fs/f2fs/compress.c:1008:7: note: Assuming 'page' is null if (!page) { ^~~~~ fs/f2fs/compress.c:1008:3: note: Taking true branch if (!page) { ^ fs/f2fs/compress.c:1010:4: note: Control jumps to line 1081 goto unlock_pages; ^ fs/f2fs/compress.c:1081:2: note: Calling 'f2fs_unlock_rpages' f2fs_unlock_rpages(cc, i); ^~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:123:2: note: Calling 'f2fs_drop_rpages' f2fs_drop_rpages(cc, len, true); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:106:7: note: The value 0 is assigned to 'i' for (i = 0; i < len; i++) { ^~~~~ fs/f2fs/compress.c:106:2: note: Loop condition is true. Entering loop body for (i = 0; i < len; i++) { ^ fs/f2fs/compress.c:107:7: note: Branch condition evaluates to a garbage value if (!cc->rpages[i]) ^~~~~~~~~~~~~~ >> fs/f2fs/compress.c:1036:3: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] f2fs_bug_on(sbi, cc->rpages[i]); ^ fs/f2fs/f2fs.h:36:7: note: expanded from macro 'f2fs_bug_on' if (WARN_ON(condition)) \ ^ include/asm-generic/bug.h:119:2: note: expanded from macro 'WARN_ON' int __ret_warn_on = !!(condition); \ ^ fs/f2fs/compress.c:1134:6: note: 'err' is >= 0 if (err < 0) ^~~ fs/f2fs/compress.c:1134:2: note: Taking false branch if (err < 0) ^ fs/f2fs/compress.c:1138:7: note: 'err' is 1 if (!err) ^~~ fs/f2fs/compress.c:1138:2: note: Taking false branch if (!err) ^ fs/f2fs/compress.c:1142:8: note: Calling 'f2fs_prepare_compress_overwrite' err = f2fs_prepare_compress_overwrite(inode, &pagep, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:1100:9: note: Calling 'prepare_compress_overwrite' return prepare_compress_overwrite(&cc, pagep, index, fsdata); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:988:22: note: Calling 'start_idx_of_cluster' pgoff_t start_idx = start_idx_of_cluster(cc); ^~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:68:2: note: Returning without writing to 'cc->rpages', which participates in a condition later return cc->cluster_idx << cc->log_cluster_size; ^ fs/f2fs/compress.c:988:22: note: Returning from 'start_idx_of_cluster' pgoff_t start_idx = start_idx_of_cluster(cc); ^~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:993:8: note: Calling 'f2fs_cluster_blocks' ret = f2fs_cluster_blocks(cc); ^~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:930:9: note: Calling '__f2fs_cluster_blocks' return __f2fs_cluster_blocks(cc, false); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:890:36: note: Calling 'start_idx_of_cluster' ret = f2fs_get_dnode_of_data(&dn, start_idx_of_cluster(cc), ^~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:68:2: note: Returning without writing to 'cc->rpages', which participates in a condition later return cc->cluster_idx << cc->log_cluster_size; ^ fs/f2fs/compress.c:890:36: note: Returning from 'start_idx_of_cluster' ret = f2fs_get_dnode_of_data(&dn, start_idx_of_cluster(cc), ^~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:892:6: note: Assuming 'ret' is not equal to 0 if (ret) { ^~~ fs/f2fs/compress.c:892:2: note: Taking true branch if (ret) { ^ fs/f2fs/compress.c:893:7: note: Assuming the condition is false if (ret == -ENOENT) ^~~~~~~~~~~~~~ fs/f2fs/compress.c:893:3: note: Taking false branch if (ret == -ENOENT) ^ fs/f2fs/compress.c:895:3: note: Control jumps to line 917 goto fail; ^ fs/f2fs/compress.c:918:2: note: Returning without writing to 'cc->rpages', which participates in a condition later return ret; ^ fs/f2fs/compress.c:930:9: note: Returning from '__f2fs_cluster_blocks' return __f2fs_cluster_blocks(cc, false); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:930:2: note: Returning without writing to 'cc->rpages', which participates in a condition later return __f2fs_cluster_blocks(cc, false); ^ fs/f2fs/compress.c:993:8: note: Returning from 'f2fs_cluster_blocks' ret = f2fs_cluster_blocks(cc); ^~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:994:6: note: Assuming 'ret' is > 0 if (ret <= 0) ^~~~~~~~ fs/f2fs/compress.c:994:2: note: Taking false branch if (ret <= 0) ^ fs/f2fs/compress.c:998:14: note: Assuming 'ret' is >= field 'cluster_size' prealloc = (ret < cc->cluster_size); ^~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:1000:8: note: Calling 'f2fs_init_compress_ctx' ret = f2fs_init_compress_ctx(cc); ^~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:160:10: note: Field 'rpages' is null if (cc->rpages) ^ fs/f2fs/compress.c:160:2: note: Taking false branch if (cc->rpages) ^ fs/f2fs/compress.c:163:15: note: Calling 'page_array_alloc' cc->rpages = page_array_alloc(cc->inode, cc->cluster_size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/f2fs/compress.c:28:13: note: Assuming 'size' is > field 'page_array_slab_size' if (likely(size <= sbi->page_array_slab_size)) vim +1036 fs/f2fs/compress.c 4c8ff7095bef64 Chao Yu 2019-11-01 978 4c8ff7095bef64 Chao Yu 2019-11-01 979 static int prepare_compress_overwrite(struct compress_ctx *cc, 4c8ff7095bef64 Chao Yu 2019-11-01 980 struct page **pagep, pgoff_t index, void **fsdata) 4c8ff7095bef64 Chao Yu 2019-11-01 981 { 4c8ff7095bef64 Chao Yu 2019-11-01 982 struct f2fs_sb_info *sbi = F2FS_I_SB(cc->inode); 4c8ff7095bef64 Chao Yu 2019-11-01 983 struct address_space *mapping = cc->inode->i_mapping; 4c8ff7095bef64 Chao Yu 2019-11-01 984 struct page *page; 4c8ff7095bef64 Chao Yu 2019-11-01 985 struct dnode_of_data dn; 4c8ff7095bef64 Chao Yu 2019-11-01 986 sector_t last_block_in_bio; 4c8ff7095bef64 Chao Yu 2019-11-01 987 unsigned fgp_flag = FGP_LOCK | FGP_WRITE | FGP_CREAT; 4c8ff7095bef64 Chao Yu 2019-11-01 988 pgoff_t start_idx = start_idx_of_cluster(cc); 4c8ff7095bef64 Chao Yu 2019-11-01 989 int i, ret; 4c8ff7095bef64 Chao Yu 2019-11-01 990 bool prealloc; 4c8ff7095bef64 Chao Yu 2019-11-01 991 4c8ff7095bef64 Chao Yu 2019-11-01 992 retry: d078319d069ef4 Wang Xiaojun 2020-06-16 993 ret = f2fs_cluster_blocks(cc); 4c8ff7095bef64 Chao Yu 2019-11-01 994 if (ret <= 0) 4c8ff7095bef64 Chao Yu 2019-11-01 995 return ret; 4c8ff7095bef64 Chao Yu 2019-11-01 996 4c8ff7095bef64 Chao Yu 2019-11-01 997 /* compressed case */ 4c8ff7095bef64 Chao Yu 2019-11-01 998 prealloc = (ret < cc->cluster_size); 4c8ff7095bef64 Chao Yu 2019-11-01 999 4c8ff7095bef64 Chao Yu 2019-11-01 1000 ret = f2fs_init_compress_ctx(cc); 4c8ff7095bef64 Chao Yu 2019-11-01 1001 if (ret) 4c8ff7095bef64 Chao Yu 2019-11-01 1002 return ret; 4c8ff7095bef64 Chao Yu 2019-11-01 1003 4c8ff7095bef64 Chao Yu 2019-11-01 1004 /* keep page reference to avoid page reclaim */ 4c8ff7095bef64 Chao Yu 2019-11-01 1005 for (i = 0; i < cc->cluster_size; i++) { 4c8ff7095bef64 Chao Yu 2019-11-01 1006 page = f2fs_pagecache_get_page(mapping, start_idx + i, 4c8ff7095bef64 Chao Yu 2019-11-01 1007 fgp_flag, GFP_NOFS); 4c8ff7095bef64 Chao Yu 2019-11-01 1008 if (!page) { 4c8ff7095bef64 Chao Yu 2019-11-01 1009 ret = -ENOMEM; 4c8ff7095bef64 Chao Yu 2019-11-01 1010 goto unlock_pages; 4c8ff7095bef64 Chao Yu 2019-11-01 1011 } 4c8ff7095bef64 Chao Yu 2019-11-01 1012 4c8ff7095bef64 Chao Yu 2019-11-01 1013 if (PageUptodate(page)) 4c8ff7095bef64 Chao Yu 2019-11-01 1014 unlock_page(page); 4c8ff7095bef64 Chao Yu 2019-11-01 1015 else 4c8ff7095bef64 Chao Yu 2019-11-01 1016 f2fs_compress_ctx_add_page(cc, page); 4c8ff7095bef64 Chao Yu 2019-11-01 1017 } 4c8ff7095bef64 Chao Yu 2019-11-01 1018 4c8ff7095bef64 Chao Yu 2019-11-01 1019 if (!f2fs_cluster_is_empty(cc)) { 4c8ff7095bef64 Chao Yu 2019-11-01 1020 struct bio *bio = NULL; 4c8ff7095bef64 Chao Yu 2019-11-01 1021 4c8ff7095bef64 Chao Yu 2019-11-01 1022 ret = f2fs_read_multi_pages(cc, &bio, cc->cluster_size, 0683728adab251 Chao Yu 2020-02-18 1023 &last_block_in_bio, false, true); 4c8ff7095bef64 Chao Yu 2019-11-01 1024 f2fs_destroy_compress_ctx(cc); 4c8ff7095bef64 Chao Yu 2019-11-01 1025 if (ret) 4c8ff7095bef64 Chao Yu 2019-11-01 1026 goto release_pages; 4c8ff7095bef64 Chao Yu 2019-11-01 1027 if (bio) 4c8ff7095bef64 Chao Yu 2019-11-01 1028 f2fs_submit_bio(sbi, bio, DATA); 4c8ff7095bef64 Chao Yu 2019-11-01 1029 4c8ff7095bef64 Chao Yu 2019-11-01 1030 ret = f2fs_init_compress_ctx(cc); 4c8ff7095bef64 Chao Yu 2019-11-01 1031 if (ret) 4c8ff7095bef64 Chao Yu 2019-11-01 1032 goto release_pages; 4c8ff7095bef64 Chao Yu 2019-11-01 1033 } 4c8ff7095bef64 Chao Yu 2019-11-01 1034 4c8ff7095bef64 Chao Yu 2019-11-01 1035 for (i = 0; i < cc->cluster_size; i++) { 4c8ff7095bef64 Chao Yu 2019-11-01 @1036 f2fs_bug_on(sbi, cc->rpages[i]); 4c8ff7095bef64 Chao Yu 2019-11-01 1037 4c8ff7095bef64 Chao Yu 2019-11-01 1038 page = find_lock_page(mapping, start_idx + i); 4c8ff7095bef64 Chao Yu 2019-11-01 1039 f2fs_bug_on(sbi, !page); 4c8ff7095bef64 Chao Yu 2019-11-01 1040 4c8ff7095bef64 Chao Yu 2019-11-01 1041 f2fs_wait_on_page_writeback(page, DATA, true, true); 4c8ff7095bef64 Chao Yu 2019-11-01 1042 4c8ff7095bef64 Chao Yu 2019-11-01 1043 f2fs_compress_ctx_add_page(cc, page); 4c8ff7095bef64 Chao Yu 2019-11-01 1044 f2fs_put_page(page, 0); 4c8ff7095bef64 Chao Yu 2019-11-01 1045 4c8ff7095bef64 Chao Yu 2019-11-01 1046 if (!PageUptodate(page)) { 4c8ff7095bef64 Chao Yu 2019-11-01 1047 f2fs_unlock_rpages(cc, i + 1); bc67c5d0ce4065 Chao Yu 2020-06-08 1048 f2fs_put_rpages_mapping(mapping, start_idx, 4c8ff7095bef64 Chao Yu 2019-11-01 1049 cc->cluster_size); 4c8ff7095bef64 Chao Yu 2019-11-01 1050 f2fs_destroy_compress_ctx(cc); 4c8ff7095bef64 Chao Yu 2019-11-01 1051 goto retry; 4c8ff7095bef64 Chao Yu 2019-11-01 1052 } 4c8ff7095bef64 Chao Yu 2019-11-01 1053 } 4c8ff7095bef64 Chao Yu 2019-11-01 1054 4c8ff7095bef64 Chao Yu 2019-11-01 1055 if (prealloc) { 0ef818335f734b Chao Yu 2020-06-18 1056 f2fs_do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, true); 4c8ff7095bef64 Chao Yu 2019-11-01 1057 4c8ff7095bef64 Chao Yu 2019-11-01 1058 set_new_dnode(&dn, cc->inode, NULL, NULL, 0); 4c8ff7095bef64 Chao Yu 2019-11-01 1059 4c8ff7095bef64 Chao Yu 2019-11-01 1060 for (i = cc->cluster_size - 1; i > 0; i--) { 4c8ff7095bef64 Chao Yu 2019-11-01 1061 ret = f2fs_get_block(&dn, start_idx + i); 4c8ff7095bef64 Chao Yu 2019-11-01 1062 if (ret) { 4c8ff7095bef64 Chao Yu 2019-11-01 1063 i = cc->cluster_size; 4c8ff7095bef64 Chao Yu 2019-11-01 1064 break; 4c8ff7095bef64 Chao Yu 2019-11-01 1065 } 4c8ff7095bef64 Chao Yu 2019-11-01 1066 4c8ff7095bef64 Chao Yu 2019-11-01 1067 if (dn.data_blkaddr != NEW_ADDR) 4c8ff7095bef64 Chao Yu 2019-11-01 1068 break; 4c8ff7095bef64 Chao Yu 2019-11-01 1069 } 4c8ff7095bef64 Chao Yu 2019-11-01 1070 0ef818335f734b Chao Yu 2020-06-18 1071 f2fs_do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false); 4c8ff7095bef64 Chao Yu 2019-11-01 1072 } 4c8ff7095bef64 Chao Yu 2019-11-01 1073 4c8ff7095bef64 Chao Yu 2019-11-01 1074 if (likely(!ret)) { 4c8ff7095bef64 Chao Yu 2019-11-01 1075 *fsdata = cc->rpages; 4c8ff7095bef64 Chao Yu 2019-11-01 1076 *pagep = cc->rpages[offset_in_cluster(cc, index)]; 4c8ff7095bef64 Chao Yu 2019-11-01 1077 return cc->cluster_size; 4c8ff7095bef64 Chao Yu 2019-11-01 1078 } 4c8ff7095bef64 Chao Yu 2019-11-01 1079 4c8ff7095bef64 Chao Yu 2019-11-01 1080 unlock_pages: 4c8ff7095bef64 Chao Yu 2019-11-01 1081 f2fs_unlock_rpages(cc, i); 4c8ff7095bef64 Chao Yu 2019-11-01 1082 release_pages: bc67c5d0ce4065 Chao Yu 2020-06-08 1083 f2fs_put_rpages_mapping(mapping, start_idx, i); 4c8ff7095bef64 Chao Yu 2019-11-01 1084 f2fs_destroy_compress_ctx(cc); 4c8ff7095bef64 Chao Yu 2019-11-01 1085 return ret; 4c8ff7095bef64 Chao Yu 2019-11-01 1086 } 4c8ff7095bef64 Chao Yu 2019-11-01 1087 :::::: The code at line 1036 was first introduced by commit :::::: 4c8ff7095bef64fc47e996a938f7d57f9e077da3 f2fs: support data compression :::::: TO: Chao Yu :::::: CC: Jaegeuk Kim --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org