[kbuild] Re: [PATCH v2 4/5] ext4: improve cr 0 / cr 1 group scanning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Harshad,

url:    https://github.com/0day-ci/linux/commits/Harshad-Shirwadkar/ext4-drop-s_mb_bal_lock-and-convert-protected-fields-to-atomic/20210210-054647 
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git  dev
config: s390-randconfig-m031-20210209 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

New smatch warnings:
fs/ext4/mballoc.c:930 ext4_mb_choose_next_group_cr1() error: uninitialized symbol 'avg_fragment_size'.

vim +/avg_fragment_size +930 fs/ext4/mballoc.c

ef4eebad9c018a Harshad Shirwadkar 2021-02-09  878  static int ext4_mb_choose_next_group_cr1(struct ext4_allocation_context *ac,
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  879  		int *new_cr, ext4_group_t *group, ext4_group_t ngroups)
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  880  {
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  881  	struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  882  	int avg_fragment_size, best_so_far;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  883  	struct rb_node *node, *found;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  884  	struct ext4_group_info *grp;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  885  
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  886  	/*
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  887  	 * If there is contention on the lock, instead of waiting for the lock
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  888  	 * to become available, just continue searching lineraly. We'll resume
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  889  	 * our rb tree search later starting at ac->ac_last_optimal_group.
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  890  	 */
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  891  	if (!read_trylock(&sbi->s_mb_rb_lock))
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  892  		return 1;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  893  
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  894  	if (ac->ac_flags & EXT4_MB_CR1_OPTIMIZED) {
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  895  		/* We have found something at CR 1 in the past */
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  896  		grp = ext4_get_group_info(ac->ac_sb, ac->ac_last_optimal_group);
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  897  		for (found = rb_next(&grp->bb_avg_fragment_size_rb); found != NULL;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  898  		     found = rb_next(found)) {
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  899  			grp = rb_entry(found, struct ext4_group_info,
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  900  				       bb_avg_fragment_size_rb);
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  901  			/*
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  902  			 * Perform this check without locking, we'll lock later
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  903  			 * to confirm.
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  904  			 */
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  905  			if (likely(ext4_mb_good_group(ac, grp->bb_group, 1)))
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  906  				break;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  907  		}
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  908  
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  909  		goto done;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  910  	}
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  911  
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  912  	node = sbi->s_mb_avg_fragment_size_root.rb_node;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  913  	best_so_far = 0;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  914  	found = NULL;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  915  
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  916  	while (node) {
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  917  		grp = rb_entry(node, struct ext4_group_info,
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  918  			       bb_avg_fragment_size_rb);
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  919  		/*
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  920  		 * Perform this check without locking, we'll lock later to confirm.
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  921  		 */
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  922  		if (ext4_mb_good_group(ac, grp->bb_group, 1)) {
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  923  			avg_fragment_size = grp->bb_fragments ?
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  924  				grp->bb_free / grp->bb_fragments : 0;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  925  			if (!best_so_far || avg_fragment_size < best_so_far) {
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  926  				best_so_far = avg_fragment_size;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  927  				found = node;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  928  			}
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  929  		}

avg_fragment_size not initialized on else path.

ef4eebad9c018a Harshad Shirwadkar 2021-02-09 @930  		if (avg_fragment_size > ac->ac_g_ex.fe_len)
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  931  			node = node->rb_right;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  932  		else
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  933  			node = node->rb_left;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  934  	}
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  935  
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  936  done:
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  937  	if (found) {
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  938  		grp = rb_entry(found, struct ext4_group_info,
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  939  			       bb_avg_fragment_size_rb);
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  940  		*group = grp->bb_group;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  941  		ac->ac_flags |= EXT4_MB_CR1_OPTIMIZED;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  942  	} else {
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  943  		*new_cr = 2;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  944  	}
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  945  
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  946  	read_unlock(&sbi->s_mb_rb_lock);
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  947  	ac->ac_last_optimal_group = *group;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  948  	return 0;
ef4eebad9c018a Harshad Shirwadkar 2021-02-09  949  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx 

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- kbuild@xxxxxxxxxxxx
To unsubscribe send an email to kbuild-leave@xxxxxxxxxxxx

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux