fs/ext4/mballoc.c:2614:1: warning: stack frame size of 1152 bytes in function 'ext4_mb_regular_allocator'

From: kernel test robot
Date: Sat May 08 2021 - 19:09:11 EST


Hi Harshad,

FYI, the error/warning still remains.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b741596468b010af2846b75f5e75a842ce344a6e
commit: 196e402adf2e4cd66f101923409f1970ec5f1af3 ext4: improve cr 0 / cr 1 group scanning
date: 4 weeks ago
config: powerpc64-randconfig-r023-20210509 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 1312852040b3190a6cb7d7c1f61fe95a5e930d8d)
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 powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=196e402adf2e4cd66f101923409f1970ec5f1af3
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 196e402adf2e4cd66f101923409f1970ec5f1af3
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=powerpc64

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

All warnings (new ones prefixed by >>):

>> fs/ext4/mballoc.c:2614:1: warning: stack frame size of 1152 bytes in function 'ext4_mb_regular_allocator' [-Wframe-larger-than=]
ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
^
1 warning generated.


vim +/ext4_mb_regular_allocator +2614 fs/ext4/mballoc.c

cfd73237722135 Alex Zhuravlev 2020-04-21 2612
4ddfef7b41aebb Eric Sandeen 2008-04-29 2613 static noinline_for_stack int
4ddfef7b41aebb Eric Sandeen 2008-04-29 @2614 ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
c9de560ded61fa Alex Tomas 2008-01-29 2615 {
cfd73237722135 Alex Zhuravlev 2020-04-21 2616 ext4_group_t prefetch_grp = 0, ngroups, group, i;
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 2617 int cr = -1;
42ac1848eac588 Lukas Czerner 2015-06-08 2618 int err = 0, first_err = 0;
cfd73237722135 Alex Zhuravlev 2020-04-21 2619 unsigned int nr = 0, prefetch_ios = 0;
c9de560ded61fa Alex Tomas 2008-01-29 2620 struct ext4_sb_info *sbi;
c9de560ded61fa Alex Tomas 2008-01-29 2621 struct super_block *sb;
c9de560ded61fa Alex Tomas 2008-01-29 2622 struct ext4_buddy e4b;
66d5e0277e225c brookxu 2020-08-17 2623 int lost;
c9de560ded61fa Alex Tomas 2008-01-29 2624
c9de560ded61fa Alex Tomas 2008-01-29 2625 sb = ac->ac_sb;
c9de560ded61fa Alex Tomas 2008-01-29 2626 sbi = EXT4_SB(sb);
8df9675f8b498d Theodore Ts'o 2009-05-01 2627 ngroups = ext4_get_groups_count(sb);
fb0a387dcdcd21 Eric Sandeen 2009-09-16 2628 /* non-extent files are limited to low blocks/groups */
12e9b892002d9a Dmitry Monakhov 2010-05-16 2629 if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS)))
fb0a387dcdcd21 Eric Sandeen 2009-09-16 2630 ngroups = sbi->s_blockfile_groups;
fb0a387dcdcd21 Eric Sandeen 2009-09-16 2631
c9de560ded61fa Alex Tomas 2008-01-29 2632 BUG_ON(ac->ac_status == AC_STATUS_FOUND);
c9de560ded61fa Alex Tomas 2008-01-29 2633
c9de560ded61fa Alex Tomas 2008-01-29 2634 /* first, try the goal */
c9de560ded61fa Alex Tomas 2008-01-29 2635 err = ext4_mb_find_by_goal(ac, &e4b);
c9de560ded61fa Alex Tomas 2008-01-29 2636 if (err || ac->ac_status == AC_STATUS_FOUND)
c9de560ded61fa Alex Tomas 2008-01-29 2637 goto out;
c9de560ded61fa Alex Tomas 2008-01-29 2638
c9de560ded61fa Alex Tomas 2008-01-29 2639 if (unlikely(ac->ac_flags & EXT4_MB_HINT_GOAL_ONLY))
c9de560ded61fa Alex Tomas 2008-01-29 2640 goto out;
c9de560ded61fa Alex Tomas 2008-01-29 2641
c9de560ded61fa Alex Tomas 2008-01-29 2642 /*
e9a3cd48d65307 brookxu 2020-08-07 2643 * ac->ac_2order is set only if the fe_len is a power of 2
e9a3cd48d65307 brookxu 2020-08-07 2644 * if ac->ac_2order is set we also set criteria to 0 so that we
c9de560ded61fa Alex Tomas 2008-01-29 2645 * try exact allocation using buddy.
c9de560ded61fa Alex Tomas 2008-01-29 2646 */
c9de560ded61fa Alex Tomas 2008-01-29 2647 i = fls(ac->ac_g_ex.fe_len);
c9de560ded61fa Alex Tomas 2008-01-29 2648 ac->ac_2order = 0;
c9de560ded61fa Alex Tomas 2008-01-29 2649 /*
c9de560ded61fa Alex Tomas 2008-01-29 2650 * We search using buddy data only if the order of the request
c9de560ded61fa Alex Tomas 2008-01-29 2651 * is greater than equal to the sbi_s_mb_order2_reqs
b713a5ec55bf73 Theodore Ts'o 2009-03-31 2652 * You can tune it via /sys/fs/ext4/<partition>/mb_order2_req
d9b22cf9f5466a Jan Kara 2017-02-10 2653 * We also support searching for power-of-two requests only for
d9b22cf9f5466a Jan Kara 2017-02-10 2654 * requests upto maximum buddy size we have constructed.
c9de560ded61fa Alex Tomas 2008-01-29 2655 */
4b68f6df105966 Harshad Shirwadkar 2021-04-01 2656 if (i >= sbi->s_mb_order2_reqs && i <= MB_NUM_ORDERS(sb)) {
c9de560ded61fa Alex Tomas 2008-01-29 2657 /*
c9de560ded61fa Alex Tomas 2008-01-29 2658 * This should tell if fe_len is exactly power of 2
c9de560ded61fa Alex Tomas 2008-01-29 2659 */
c9de560ded61fa Alex Tomas 2008-01-29 2660 if ((ac->ac_g_ex.fe_len & (~(1 << (i - 1)))) == 0)
1a5d5e5d51e75a Jeremy Cline 2018-08-02 2661 ac->ac_2order = array_index_nospec(i - 1,
4b68f6df105966 Harshad Shirwadkar 2021-04-01 2662 MB_NUM_ORDERS(sb));
c9de560ded61fa Alex Tomas 2008-01-29 2663 }
c9de560ded61fa Alex Tomas 2008-01-29 2664
4ba74d00a20256 Theodore Ts'o 2009-08-09 2665 /* if stream allocation is enabled, use global goal */
4ba74d00a20256 Theodore Ts'o 2009-08-09 2666 if (ac->ac_flags & EXT4_MB_STREAM_ALLOC) {
c9de560ded61fa Alex Tomas 2008-01-29 2667 /* TBD: may be hot point */
c9de560ded61fa Alex Tomas 2008-01-29 2668 spin_lock(&sbi->s_md_lock);
c9de560ded61fa Alex Tomas 2008-01-29 2669 ac->ac_g_ex.fe_group = sbi->s_mb_last_group;
c9de560ded61fa Alex Tomas 2008-01-29 2670 ac->ac_g_ex.fe_start = sbi->s_mb_last_start;
c9de560ded61fa Alex Tomas 2008-01-29 2671 spin_unlock(&sbi->s_md_lock);
c9de560ded61fa Alex Tomas 2008-01-29 2672 }
4ba74d00a20256 Theodore Ts'o 2009-08-09 2673
c9de560ded61fa Alex Tomas 2008-01-29 2674 /* Let's just scan groups to find more-less suitable blocks */
c9de560ded61fa Alex Tomas 2008-01-29 2675 cr = ac->ac_2order ? 0 : 1;
c9de560ded61fa Alex Tomas 2008-01-29 2676 /*
c9de560ded61fa Alex Tomas 2008-01-29 2677 * cr == 0 try to get exact allocation,
c9de560ded61fa Alex Tomas 2008-01-29 2678 * cr == 3 try to get anything
c9de560ded61fa Alex Tomas 2008-01-29 2679 */
c9de560ded61fa Alex Tomas 2008-01-29 2680 repeat:
c9de560ded61fa Alex Tomas 2008-01-29 2681 for (; cr < 4 && ac->ac_status == AC_STATUS_CONTINUE; cr++) {
c9de560ded61fa Alex Tomas 2008-01-29 2682 ac->ac_criteria = cr;
ed8f9c751feb3a Aneesh Kumar K.V 2008-07-11 2683 /*
ed8f9c751feb3a Aneesh Kumar K.V 2008-07-11 2684 * searching for the right group start
ed8f9c751feb3a Aneesh Kumar K.V 2008-07-11 2685 * from the goal value specified
ed8f9c751feb3a Aneesh Kumar K.V 2008-07-11 2686 */
ed8f9c751feb3a Aneesh Kumar K.V 2008-07-11 2687 group = ac->ac_g_ex.fe_group;
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2688 ac->ac_last_optimal_group = group;
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2689 ac->ac_groups_linear_remaining = sbi->s_mb_max_linear_groups;
cfd73237722135 Alex Zhuravlev 2020-04-21 2690 prefetch_grp = group;
ed8f9c751feb3a Aneesh Kumar K.V 2008-07-11 2691
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2692 for (i = 0; i < ngroups; group = next_linear_group(ac, group, ngroups),
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2693 i++) {
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2694 int ret = 0, new_cr;
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2695
2ed5724d5a78a2 Theodore Ts'o 2013-06-12 2696 cond_resched();
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2697
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2698 ext4_mb_choose_next_group(ac, &new_cr, &group, ngroups);
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2699 if (new_cr != cr) {
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2700 cr = new_cr;
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2701 goto repeat;
196e402adf2e4c Harshad Shirwadkar 2021-04-01 2702 }
c9de560ded61fa Alex Tomas 2008-01-29 2703
cfd73237722135 Alex Zhuravlev 2020-04-21 2704 /*
cfd73237722135 Alex Zhuravlev 2020-04-21 2705 * Batch reads of the block allocation bitmaps
cfd73237722135 Alex Zhuravlev 2020-04-21 2706 * to get multiple READs in flight; limit
cfd73237722135 Alex Zhuravlev 2020-04-21 2707 * prefetching at cr=0/1, otherwise mballoc can
cfd73237722135 Alex Zhuravlev 2020-04-21 2708 * spend a lot of time loading imperfect groups
cfd73237722135 Alex Zhuravlev 2020-04-21 2709 */
cfd73237722135 Alex Zhuravlev 2020-04-21 2710 if ((prefetch_grp == group) &&
cfd73237722135 Alex Zhuravlev 2020-04-21 2711 (cr > 1 ||
cfd73237722135 Alex Zhuravlev 2020-04-21 2712 prefetch_ios < sbi->s_mb_prefetch_limit)) {
cfd73237722135 Alex Zhuravlev 2020-04-21 2713 unsigned int curr_ios = prefetch_ios;
cfd73237722135 Alex Zhuravlev 2020-04-21 2714
cfd73237722135 Alex Zhuravlev 2020-04-21 2715 nr = sbi->s_mb_prefetch;
cfd73237722135 Alex Zhuravlev 2020-04-21 2716 if (ext4_has_feature_flex_bg(sb)) {
82ef1370b0c175 Chunguang Xu 2020-12-04 2717 nr = 1 << sbi->s_log_groups_per_flex;
82ef1370b0c175 Chunguang Xu 2020-12-04 2718 nr -= group & (nr - 1);
82ef1370b0c175 Chunguang Xu 2020-12-04 2719 nr = min(nr, sbi->s_mb_prefetch);
cfd73237722135 Alex Zhuravlev 2020-04-21 2720 }
cfd73237722135 Alex Zhuravlev 2020-04-21 2721 prefetch_grp = ext4_mb_prefetch(sb, group,
cfd73237722135 Alex Zhuravlev 2020-04-21 2722 nr, &prefetch_ios);
cfd73237722135 Alex Zhuravlev 2020-04-21 2723 if (prefetch_ios == curr_ios)
cfd73237722135 Alex Zhuravlev 2020-04-21 2724 nr = 0;
cfd73237722135 Alex Zhuravlev 2020-04-21 2725 }
cfd73237722135 Alex Zhuravlev 2020-04-21 2726
8a57d9d61a6e36 Curt Wohlgemuth 2010-05-16 2727 /* This now checks without needing the buddy page */
8ef123fe02ca09 Ritesh Harjani 2020-05-20 2728 ret = ext4_mb_good_group_nolock(ac, group, cr);
42ac1848eac588 Lukas Czerner 2015-06-08 2729 if (ret <= 0) {
42ac1848eac588 Lukas Czerner 2015-06-08 2730 if (!first_err)
42ac1848eac588 Lukas Czerner 2015-06-08 2731 first_err = ret;
c9de560ded61fa Alex Tomas 2008-01-29 2732 continue;
42ac1848eac588 Lukas Czerner 2015-06-08 2733 }
c9de560ded61fa Alex Tomas 2008-01-29 2734
c9de560ded61fa Alex Tomas 2008-01-29 2735 err = ext4_mb_load_buddy(sb, group, &e4b);
c9de560ded61fa Alex Tomas 2008-01-29 2736 if (err)
c9de560ded61fa Alex Tomas 2008-01-29 2737 goto out;
c9de560ded61fa Alex Tomas 2008-01-29 2738
c9de560ded61fa Alex Tomas 2008-01-29 2739 ext4_lock_group(sb, group);
8a57d9d61a6e36 Curt Wohlgemuth 2010-05-16 2740
8a57d9d61a6e36 Curt Wohlgemuth 2010-05-16 2741 /*
8a57d9d61a6e36 Curt Wohlgemuth 2010-05-16 2742 * We need to check again after locking the
8a57d9d61a6e36 Curt Wohlgemuth 2010-05-16 2743 * block group
8a57d9d61a6e36 Curt Wohlgemuth 2010-05-16 2744 */
42ac1848eac588 Lukas Czerner 2015-06-08 2745 ret = ext4_mb_good_group(ac, group, cr);
8ef123fe02ca09 Ritesh Harjani 2020-05-20 2746 if (ret == 0) {
c9de560ded61fa Alex Tomas 2008-01-29 2747 ext4_unlock_group(sb, group);
e39e07fdfd98be Jing Zhang 2010-05-14 2748 ext4_mb_unload_buddy(&e4b);
c9de560ded61fa Alex Tomas 2008-01-29 2749 continue;
c9de560ded61fa Alex Tomas 2008-01-29 2750 }
c9de560ded61fa Alex Tomas 2008-01-29 2751
c9de560ded61fa Alex Tomas 2008-01-29 2752 ac->ac_groups_scanned++;
d9b22cf9f5466a Jan Kara 2017-02-10 2753 if (cr == 0)
c9de560ded61fa Alex Tomas 2008-01-29 2754 ext4_mb_simple_scan_group(ac, &e4b);
506bf2d82165c0 Eric Sandeen 2010-07-27 2755 else if (cr == 1 && sbi->s_stripe &&
506bf2d82165c0 Eric Sandeen 2010-07-27 2756 !(ac->ac_g_ex.fe_len % sbi->s_stripe))
c9de560ded61fa Alex Tomas 2008-01-29 2757 ext4_mb_scan_aligned(ac, &e4b);
c9de560ded61fa Alex Tomas 2008-01-29 2758 else
c9de560ded61fa Alex Tomas 2008-01-29 2759 ext4_mb_complex_scan_group(ac, &e4b);
c9de560ded61fa Alex Tomas 2008-01-29 2760
c9de560ded61fa Alex Tomas 2008-01-29 2761 ext4_unlock_group(sb, group);
e39e07fdfd98be Jing Zhang 2010-05-14 2762 ext4_mb_unload_buddy(&e4b);
c9de560ded61fa Alex Tomas 2008-01-29 2763
c9de560ded61fa Alex Tomas 2008-01-29 2764 if (ac->ac_status != AC_STATUS_CONTINUE)
c9de560ded61fa Alex Tomas 2008-01-29 2765 break;
c9de560ded61fa Alex Tomas 2008-01-29 2766 }
a6c75eaf11032f Harshad Shirwadkar 2021-04-01 2767 /* Processed all groups and haven't found blocks */
a6c75eaf11032f Harshad Shirwadkar 2021-04-01 2768 if (sbi->s_mb_stats && i == ngroups)
a6c75eaf11032f Harshad Shirwadkar 2021-04-01 2769 atomic64_inc(&sbi->s_bal_cX_failed[cr]);
c9de560ded61fa Alex Tomas 2008-01-29 2770 }
c9de560ded61fa Alex Tomas 2008-01-29 2771
c9de560ded61fa Alex Tomas 2008-01-29 2772 if (ac->ac_b_ex.fe_len > 0 && ac->ac_status != AC_STATUS_FOUND &&
c9de560ded61fa Alex Tomas 2008-01-29 2773 !(ac->ac_flags & EXT4_MB_HINT_FIRST)) {
c9de560ded61fa Alex Tomas 2008-01-29 2774 /*
c9de560ded61fa Alex Tomas 2008-01-29 2775 * We've been searching too long. Let's try to allocate
c9de560ded61fa Alex Tomas 2008-01-29 2776 * the best chunk we've found so far
c9de560ded61fa Alex Tomas 2008-01-29 2777 */
c9de560ded61fa Alex Tomas 2008-01-29 2778 ext4_mb_try_best_found(ac, &e4b);
c9de560ded61fa Alex Tomas 2008-01-29 2779 if (ac->ac_status != AC_STATUS_FOUND) {
c9de560ded61fa Alex Tomas 2008-01-29 2780 /*
c9de560ded61fa Alex Tomas 2008-01-29 2781 * Someone more lucky has already allocated it.
c9de560ded61fa Alex Tomas 2008-01-29 2782 * The only thing we can do is just take first
c9de560ded61fa Alex Tomas 2008-01-29 2783 * found block(s)
c9de560ded61fa Alex Tomas 2008-01-29 2784 */
66d5e0277e225c brookxu 2020-08-17 2785 lost = atomic_inc_return(&sbi->s_mb_lost_chunks);
66d5e0277e225c brookxu 2020-08-17 2786 mb_debug(sb, "lost chunk, group: %u, start: %d, len: %d, lost: %d\n",
c55ee7d202857b brookxu 2020-08-15 2787 ac->ac_b_ex.fe_group, ac->ac_b_ex.fe_start,
c55ee7d202857b brookxu 2020-08-15 2788 ac->ac_b_ex.fe_len, lost);
c55ee7d202857b brookxu 2020-08-15 2789
c9de560ded61fa Alex Tomas 2008-01-29 2790 ac->ac_b_ex.fe_group = 0;
c9de560ded61fa Alex Tomas 2008-01-29 2791 ac->ac_b_ex.fe_start = 0;
c9de560ded61fa Alex Tomas 2008-01-29 2792 ac->ac_b_ex.fe_len = 0;
c9de560ded61fa Alex Tomas 2008-01-29 2793 ac->ac_status = AC_STATUS_CONTINUE;
c9de560ded61fa Alex Tomas 2008-01-29 2794 ac->ac_flags |= EXT4_MB_HINT_FIRST;
c9de560ded61fa Alex Tomas 2008-01-29 2795 cr = 3;
c9de560ded61fa Alex Tomas 2008-01-29 2796 goto repeat;
c9de560ded61fa Alex Tomas 2008-01-29 2797 }
c9de560ded61fa Alex Tomas 2008-01-29 2798 }
a6c75eaf11032f Harshad Shirwadkar 2021-04-01 2799
a6c75eaf11032f Harshad Shirwadkar 2021-04-01 2800 if (sbi->s_mb_stats && ac->ac_status == AC_STATUS_FOUND)
a6c75eaf11032f Harshad Shirwadkar 2021-04-01 2801 atomic64_inc(&sbi->s_bal_cX_hits[ac->ac_criteria]);
c9de560ded61fa Alex Tomas 2008-01-29 2802 out:
42ac1848eac588 Lukas Czerner 2015-06-08 2803 if (!err && ac->ac_status != AC_STATUS_FOUND && first_err)
42ac1848eac588 Lukas Czerner 2015-06-08 2804 err = first_err;
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 2805
d3df14535f4a5b Ritesh Harjani 2020-05-10 2806 mb_debug(sb, "Best len %d, origin len %d, ac_status %u, ac_flags 0x%x, cr %d ret %d\n",
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 2807 ac->ac_b_ex.fe_len, ac->ac_o_ex.fe_len, ac->ac_status,
bbc4ec77e9f9c7 Ritesh Harjani 2020-05-10 2808 ac->ac_flags, cr, err);
cfd73237722135 Alex Zhuravlev 2020-04-21 2809
cfd73237722135 Alex Zhuravlev 2020-04-21 2810 if (nr)
cfd73237722135 Alex Zhuravlev 2020-04-21 2811 ext4_mb_prefetch_fini(sb, prefetch_grp, nr);
cfd73237722135 Alex Zhuravlev 2020-04-21 2812
c9de560ded61fa Alex Tomas 2008-01-29 2813 return err;
c9de560ded61fa Alex Tomas 2008-01-29 2814 }
c9de560ded61fa Alex Tomas 2008-01-29 2815

:::::: The code at line 2614 was first introduced by commit
:::::: 4ddfef7b41aebbbede73f361cb938800ba3072dc ext4: reduce mballoc stack usage with noinline_for_stack

:::::: TO: Eric Sandeen <sandeen@xxxxxxxxxx>
:::::: CC: Theodore Ts'o <tytso@xxxxxxx>

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

Attachment: .config.gz
Description: application/gzip