Re: [kbuild-all] Re: fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 'get_victim_by_default'

2021-01-12 Thread Rong Chen
dirq.h:10:
    In file included from arch/powerpc/include/asm/hardirq.h:6:
    In file included from include/linux/irq.h:20:
    In file included from include/linux/io.h:13:
    In file included from arch/powerpc/include/asm/io.h:604:
    arch/powerpc/include/asm/io-defs.h:49:1: warning: performing 
pointer arithmetic on a null pointer has undefined behavior 
[-Wnull-pointer-arithmetic]
    DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned 
long c),

^~
    arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 
'DEF_PCI_AC_NORET'

    __do_##name al; \
    ^~
    :186:1: note: expanded from here
    __do_outsb
    ^
    arch/powerpc/include/asm/io.h:544:58: note: expanded from macro 
'__do_outsb'
    #define __do_outsb(p, b, n) 
writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))

~^
    In file included from fs/f2fs/gc.c:10:
    In file included from include/linux/backing-dev.h:15:
    In file included from include/linux/blkdev.h:13:
    In file included from include/linux/pagemap.h:11:
    In file included from include/linux/highmem.h:10:
    In file included from include/linux/hardirq.h:10:
    In file included from arch/powerpc/include/asm/hardirq.h:6:
    In file included from include/linux/irq.h:20:
    In file included from include/linux/io.h:13:
    In file included from arch/powerpc/include/asm/io.h:604:
    arch/powerpc/include/asm/io-defs.h:51:1: warning: performing 
pointer arithmetic on a null pointer has undefined behavior 
[-Wnull-pointer-arithmetic]
    DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned 
long c),

^~
    arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 
'DEF_PCI_AC_NORET'

    __do_##name al; \
    ^~
    :188:1: note: expanded from here
    __do_outsw
    ^
    arch/powerpc/include/asm/io.h:545:58: note: expanded from macro 
'__do_outsw'
    #define __do_outsw(p, b, n) 
writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))

~^
    In file included from fs/f2fs/gc.c:10:
    In file included from include/linux/backing-dev.h:15:
    In file included from include/linux/blkdev.h:13:
    In file included from include/linux/pagemap.h:11:
    In file included from include/linux/highmem.h:10:
    In file included from include/linux/hardirq.h:10:
    In file included from arch/powerpc/include/asm/hardirq.h:6:
    In file included from include/linux/irq.h:20:
    In file included from include/linux/io.h:13:
    In file included from arch/powerpc/include/asm/io.h:604:
    arch/powerpc/include/asm/io-defs.h:53:1: warning: performing 
pointer arithmetic on a null pointer has undefined behavior 
[-Wnull-pointer-arithmetic]
    DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned 
long c),

^~
    arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 
'DEF_PCI_AC_NORET'

    __do_##name al; \
    ^~
    :190:1: note: expanded from here
    __do_outsl
    ^
    arch/powerpc/include/asm/io.h:546:58: note: expanded from macro 
'__do_outsl'
    #define __do_outsl(p, b, n) 
writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))

~~~~~^
fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in 
function 'get_victim_by_default' [-Wframe-larger-than=]

    static int get_victim_by_default(struct f2fs_sb_info *sbi,
   ^
    13 warnings generated.


vim +/get_victim_by_default +622 fs/f2fs/gc.c

093749e296e29a4 Chao Yu   2020-08-04  613
0a8165d7c2cf139 Jaegeuk Kim   2012-11-29  614  /*
111d2495a8a8fbd Masanari Iida 2013-03-19  615   * This function is 
called from two paths.
7bc0900347e069a Jaegeuk Kim   2012-11-02  616   * One is garbage 
collection and the other is SSR segment selection.
7bc0900347e069a Jaegeuk Kim   2012-11-02  617   * When it is called 
during GC, it just gets a victim segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  618   * and it does not 
remove it from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  619   * When it is called 
from SSR segment selection, it finds a segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  620   * which has minimum 
valid blocks and removes it from dirty seglist.

7bc0900347e069a Jaegeuk Kim   2012-11-02  621   */
7bc0900347e069a Jaegeuk Kim   2012-11-02 @622  static int 
get_victim_by_default(struct f2fs_sb_info *sbi,
093749e296e29a4 Chao Yu   2020-08-04  623 unsigned int *result, 
int gc_type, int type,
093749e296e29a4 Chao Yu   2020-08-04  624  char 
alloc_mode, unsigned long long age)

7bc0900347e069a Jaegeuk Kim   2012-11-02  625  {
7bc0900347e069a Jaegeuk Kim 

Re: fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 'get_victim_by_default'

2021-01-11 Thread Chao Yu
long c),
^~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
__do_##name al; \
^~
:186:1: note: expanded from here
__do_outsb
^
arch/powerpc/include/asm/io.h:544:58: note: expanded from macro '__do_outsb'
#define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~^
In file included from fs/f2fs/gc.c:10:
In file included from include/linux/backing-dev.h:15:
In file included from include/linux/blkdev.h:13:
In file included from include/linux/pagemap.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
^~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
__do_##name al; \
^~
:188:1: note: expanded from here
__do_outsw
^
arch/powerpc/include/asm/io.h:545:58: note: expanded from macro '__do_outsw'
#define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~^
In file included from fs/f2fs/gc.c:10:
In file included from include/linux/backing-dev.h:15:
In file included from include/linux/blkdev.h:13:
In file included from include/linux/pagemap.h:11:
In file included from include/linux/highmem.h:10:
In file included from include/linux/hardirq.h:10:
In file included from arch/powerpc/include/asm/hardirq.h:6:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/powerpc/include/asm/io.h:604:
arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
^~
arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
__do_##name al; \
^~
:190:1: note: expanded from here
__do_outsl
^
arch/powerpc/include/asm/io.h:546:58: note: expanded from macro '__do_outsl'
#define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
~~~~~^

fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 
'get_victim_by_default' [-Wframe-larger-than=]

static int get_victim_by_default(struct f2fs_sb_info *sbi,
   ^
13 warnings generated.


vim +/get_victim_by_default +622 fs/f2fs/gc.c

093749e296e29a4 Chao Yu   2020-08-04  613
0a8165d7c2cf139 Jaegeuk Kim   2012-11-29  614  /*
111d2495a8a8fbd Masanari Iida 2013-03-19  615   * This function is called from 
two paths.
7bc0900347e069a Jaegeuk Kim   2012-11-02  616   * One is garbage collection and 
the other is SSR segment selection.
7bc0900347e069a Jaegeuk Kim   2012-11-02  617   * When it is called during GC, 
it just gets a victim segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  618   * and it does not remove it 
from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  619   * When it is called from SSR 
segment selection, it finds a segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  620   * which has minimum valid 
blocks and removes it from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  621   */
7bc0900347e069a Jaegeuk Kim   2012-11-02 @622  static int 
get_victim_by_default(struct f2fs_sb_info *sbi,
093749e296e29a4 Chao Yu   2020-08-04  623   unsigned int 
*result, int gc_type, int type,
093749e296e29a4 Chao Yu   2020-08-04  624   char 
alloc_mode, unsigned long long age)
7bc0900347e069a Jaegeuk Kim   2012-11-02  625  {
7bc0900347e069a Jaegeuk Kim   2012-11-02  626   struct dirty_seglist_info 
*dirty_i = DIRTY_I(sbi);
e066b83c9b40f3a Jaegeuk Kim   2017-04-13  627   struct sit_info *sm = 
SIT_I(sbi);
7bc0900347e069a Jaegeuk Kim   2012-11-02  628   struct victim_sel_policy p;
3fa565039e3338f Sheng Yong2016-09-29  629   unsigned int secno, last_victim;
04f0b2eaa3b3ee2 Qiuyang Sun   2019-06-05  630   unsigned int last_s

fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 'get_victim_by_default'

2021-01-09 Thread kernel test robot
m.h:10:
   In file included from include/linux/hardirq.h:10:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:604:
   arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
   ^~
   arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
   __do_##name al; \
   ^~
   :188:1: note: expanded from here
   __do_outsw
   ^
   arch/powerpc/include/asm/io.h:545:58: note: expanded from macro '__do_outsw'
   #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
   ~^
   In file included from fs/f2fs/gc.c:10:
   In file included from include/linux/backing-dev.h:15:
   In file included from include/linux/blkdev.h:13:
   In file included from include/linux/pagemap.h:11:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/hardirq.h:10:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:604:
   arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer 
arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
   ^~
   arch/powerpc/include/asm/io.h:601:3: note: expanded from macro 
'DEF_PCI_AC_NORET'
   __do_##name al; \
   ^~
   :190:1: note: expanded from here
   __do_outsl
   ^
   arch/powerpc/include/asm/io.h:546:58: note: expanded from macro '__do_outsl'
   #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
   ~^
>> fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 
>> 'get_victim_by_default' [-Wframe-larger-than=]
   static int get_victim_by_default(struct f2fs_sb_info *sbi,
  ^
   13 warnings generated.


vim +/get_victim_by_default +622 fs/f2fs/gc.c

093749e296e29a4 Chao Yu   2020-08-04  613  
0a8165d7c2cf139 Jaegeuk Kim   2012-11-29  614  /*
111d2495a8a8fbd Masanari Iida 2013-03-19  615   * This function is called from 
two paths.
7bc0900347e069a Jaegeuk Kim   2012-11-02  616   * One is garbage collection and 
the other is SSR segment selection.
7bc0900347e069a Jaegeuk Kim   2012-11-02  617   * When it is called during GC, 
it just gets a victim segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  618   * and it does not remove it 
from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  619   * When it is called from SSR 
segment selection, it finds a segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  620   * which has minimum valid 
blocks and removes it from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  621   */
7bc0900347e069a Jaegeuk Kim   2012-11-02 @622  static int 
get_victim_by_default(struct f2fs_sb_info *sbi,
093749e296e29a4 Chao Yu   2020-08-04  623   unsigned int 
*result, int gc_type, int type,
093749e296e29a4 Chao Yu   2020-08-04  624   char 
alloc_mode, unsigned long long age)
7bc0900347e069a Jaegeuk Kim   2012-11-02  625  {
7bc0900347e069a Jaegeuk Kim   2012-11-02  626   struct dirty_seglist_info 
*dirty_i = DIRTY_I(sbi);
e066b83c9b40f3a Jaegeuk Kim   2017-04-13  627   struct sit_info *sm = 
SIT_I(sbi);
7bc0900347e069a Jaegeuk Kim   2012-11-02  628   struct victim_sel_policy p;
3fa565039e3338f Sheng Yong2016-09-29  629   unsigned int secno, last_victim;
04f0b2eaa3b3ee2 Qiuyang Sun   2019-06-05  630   unsigned int last_segment;
093749e296e29a4 Chao Yu   2020-08-04  631   unsigned int nsearched;
093749e296e29a4 Chao Yu   2020-08-04  632   bool is_atgc;
97767500781fae9 Qilong Zhang  2020-06-28  633   int ret = 0;
7bc0900347e069a Jaegeuk Kim   2012-11-02  634  
210f41bc048263d Chao Yu   2014-09-15  635   
mutex_lock(_i->seglist_lock);
04f0b2eaa3b3ee2 Qiuyang Sun   2019-06-05  636   last_segment = MAIN_SECS(sbi) * 
sbi->segs_per_sec;
210f41bc048263d Chao Yu   2014-09-15  637  
7bc0900347e069a Jaegeuk Kim   2012-11-02  638   p.alloc_mode = alloc_mode;
093749e296e29a4 Chao Yu   2020-08-04  639   p.age = age;
093749e296e29a4 Chao Yu   2020-08-04  640   p.age_threshold = 
sbi->am.age_threshold;
7bc0900347e069a Jaegeuk Kim   2012-11-02  641  
093749e296e29

Re: fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 'get_victim_by_default'

2020-12-30 Thread Chao Yu

Hello,

I tried -Wframe-larger-than=512 in x86_64, and only below two functions
exceed the frame size threshold, will check powerpc64 later.

namei.c: In function ‘f2fs_update_extension_list’:
namei.c:276:1: warning: the frame size of 560 bytes is larger than 512 bytes 
[-Wframe-larger-than=]

node.c: In function ‘f2fs_destroy_node_manager’:
node.c:3271:1: warning: the frame size of 792 bytes is larger than 512 bytes 
[-Wframe-larger-than=]

Does this issue only occur in powerpc64? do you have results in other archs?

On 2020/12/30 2:45, kernel test robot wrote:

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   dea8dcf2a9fa8cc540136a6cd885c3beece16ec3
commit: 093749e296e29a4b0162eb925a6701a01e8c9a98 f2fs: support age threshold 
based garbage collection
date:   4 months ago
config: powerpc64-randconfig-r023-20201221 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
cee1e7d14f4628d6174b33640d502bff3b54ae45)
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=093749e296e29a4b0162eb925a6701a01e8c9a98
 git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
 git fetch --no-tags linus master
 git checkout 093749e296e29a4b0162eb925a6701a01e8c9a98
 # save the attached .config to linux build tree
 COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross 
ARCH=powerpc64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):


fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 
'get_victim_by_default' [-Wframe-larger-than=]

static int get_victim_by_default(struct f2fs_sb_info *sbi,
   ^
1 warning generated.


vim +/get_victim_by_default +622 fs/f2fs/gc.c

093749e296e29a4 Chao Yu   2020-08-04  613
0a8165d7c2cf139 Jaegeuk Kim   2012-11-29  614  /*
111d2495a8a8fbd Masanari Iida 2013-03-19  615   * This function is called from 
two paths.
7bc0900347e069a Jaegeuk Kim   2012-11-02  616   * One is garbage collection and 
the other is SSR segment selection.
7bc0900347e069a Jaegeuk Kim   2012-11-02  617   * When it is called during GC, 
it just gets a victim segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  618   * and it does not remove it 
from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  619   * When it is called from SSR 
segment selection, it finds a segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  620   * which has minimum valid 
blocks and removes it from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  621   */
7bc0900347e069a Jaegeuk Kim   2012-11-02 @622  static int 
get_victim_by_default(struct f2fs_sb_info *sbi,
093749e296e29a4 Chao Yu   2020-08-04  623   unsigned int 
*result, int gc_type, int type,
093749e296e29a4 Chao Yu   2020-08-04  624   char 
alloc_mode, unsigned long long age)
7bc0900347e069a Jaegeuk Kim   2012-11-02  625  {
7bc0900347e069a Jaegeuk Kim   2012-11-02  626   struct dirty_seglist_info 
*dirty_i = DIRTY_I(sbi);
e066b83c9b40f3a Jaegeuk Kim   2017-04-13  627   struct sit_info *sm = 
SIT_I(sbi);
7bc0900347e069a Jaegeuk Kim   2012-11-02  628   struct victim_sel_policy p;
3fa565039e3338f Sheng Yong2016-09-29  629   unsigned int secno, last_victim;
04f0b2eaa3b3ee2 Qiuyang Sun   2019-06-05  630   unsigned int last_segment;
093749e296e29a4 Chao Yu   2020-08-04  631   unsigned int nsearched;
093749e296e29a4 Chao Yu   2020-08-04  632   bool is_atgc;
97767500781fae9 Qilong Zhang  2020-06-28  633   int ret = 0;
7bc0900347e069a Jaegeuk Kim   2012-11-02  634
210f41bc048263d Chao Yu   2014-09-15  635   
mutex_lock(_i->seglist_lock);
04f0b2eaa3b3ee2 Qiuyang Sun   2019-06-05  636   last_segment = MAIN_SECS(sbi) * 
sbi->segs_per_sec;
210f41bc048263d Chao Yu   2014-09-15  637
7bc0900347e069a Jaegeuk Kim   2012-11-02  638   p.alloc_mode = alloc_mode;
093749e296e29a4 Chao Yu   2020-08-04  639   p.age = age;
093749e296e29a4 Chao Yu   2020-08-04  640   p.age_threshold = 
sbi->am.age_threshold;
7bc0900347e069a Jaegeuk Kim   2012-11-02  641
093749e296e29a4 Chao Yu   2020-08-04  642  retry:
093749e296e29a4 Chao Yu   2020-08-04  643   select_policy(sbi, gc_type, type, 
);
7bc0900347e069a Jaegeuk Kim   2012-11-02  644   p.min_segno = NULL_SEGNO;
093749e296e29a4 Chao Yu   2020-08-04  645   p.oldest_age = 0;
3fa565039e3338f Sheng Yong2016-09-29  646   p.min_cost = get_max_cost(sbi, 
);
7bc0900347e069a Jaegeuk Kim   2012-11-02  647
093749e296e29a4 Chao Yu   2020-08-04  648   is_atgc = (p.g

fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 'get_victim_by_default'

2020-12-29 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   dea8dcf2a9fa8cc540136a6cd885c3beece16ec3
commit: 093749e296e29a4b0162eb925a6701a01e8c9a98 f2fs: support age threshold 
based garbage collection
date:   4 months ago
config: powerpc64-randconfig-r023-20201221 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
cee1e7d14f4628d6174b33640d502bff3b54ae45)
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=093749e296e29a4b0162eb925a6701a01e8c9a98
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 093749e296e29a4b0162eb925a6701a01e8c9a98
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross 
ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> fs/f2fs/gc.c:622:12: warning: stack frame size of 3056 bytes in function 
>> 'get_victim_by_default' [-Wframe-larger-than=]
   static int get_victim_by_default(struct f2fs_sb_info *sbi,
  ^
   1 warning generated.


vim +/get_victim_by_default +622 fs/f2fs/gc.c

093749e296e29a4 Chao Yu   2020-08-04  613  
0a8165d7c2cf139 Jaegeuk Kim   2012-11-29  614  /*
111d2495a8a8fbd Masanari Iida 2013-03-19  615   * This function is called from 
two paths.
7bc0900347e069a Jaegeuk Kim   2012-11-02  616   * One is garbage collection and 
the other is SSR segment selection.
7bc0900347e069a Jaegeuk Kim   2012-11-02  617   * When it is called during GC, 
it just gets a victim segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  618   * and it does not remove it 
from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  619   * When it is called from SSR 
segment selection, it finds a segment
7bc0900347e069a Jaegeuk Kim   2012-11-02  620   * which has minimum valid 
blocks and removes it from dirty seglist.
7bc0900347e069a Jaegeuk Kim   2012-11-02  621   */
7bc0900347e069a Jaegeuk Kim   2012-11-02 @622  static int 
get_victim_by_default(struct f2fs_sb_info *sbi,
093749e296e29a4 Chao Yu   2020-08-04  623   unsigned int 
*result, int gc_type, int type,
093749e296e29a4 Chao Yu   2020-08-04  624   char 
alloc_mode, unsigned long long age)
7bc0900347e069a Jaegeuk Kim   2012-11-02  625  {
7bc0900347e069a Jaegeuk Kim   2012-11-02  626   struct dirty_seglist_info 
*dirty_i = DIRTY_I(sbi);
e066b83c9b40f3a Jaegeuk Kim   2017-04-13  627   struct sit_info *sm = 
SIT_I(sbi);
7bc0900347e069a Jaegeuk Kim   2012-11-02  628   struct victim_sel_policy p;
3fa565039e3338f Sheng Yong2016-09-29  629   unsigned int secno, last_victim;
04f0b2eaa3b3ee2 Qiuyang Sun   2019-06-05  630   unsigned int last_segment;
093749e296e29a4 Chao Yu   2020-08-04  631   unsigned int nsearched;
093749e296e29a4 Chao Yu   2020-08-04  632   bool is_atgc;
97767500781fae9 Qilong Zhang  2020-06-28  633   int ret = 0;
7bc0900347e069a Jaegeuk Kim   2012-11-02  634  
210f41bc048263d Chao Yu   2014-09-15  635   
mutex_lock(_i->seglist_lock);
04f0b2eaa3b3ee2 Qiuyang Sun   2019-06-05  636   last_segment = MAIN_SECS(sbi) * 
sbi->segs_per_sec;
210f41bc048263d Chao Yu   2014-09-15  637  
7bc0900347e069a Jaegeuk Kim   2012-11-02  638   p.alloc_mode = alloc_mode;
093749e296e29a4 Chao Yu   2020-08-04  639   p.age = age;
093749e296e29a4 Chao Yu   2020-08-04  640   p.age_threshold = 
sbi->am.age_threshold;
7bc0900347e069a Jaegeuk Kim   2012-11-02  641  
093749e296e29a4 Chao Yu   2020-08-04  642  retry:
093749e296e29a4 Chao Yu   2020-08-04  643   select_policy(sbi, gc_type, 
type, );
7bc0900347e069a Jaegeuk Kim   2012-11-02  644   p.min_segno = NULL_SEGNO;
093749e296e29a4 Chao Yu   2020-08-04  645   p.oldest_age = 0;
3fa565039e3338f Sheng Yong2016-09-29  646   p.min_cost = get_max_cost(sbi, 
);
7bc0900347e069a Jaegeuk Kim   2012-11-02  647  
093749e296e29a4 Chao Yu   2020-08-04  648   is_atgc = (p.gc_mode == GC_AT 
|| p.alloc_mode == AT_SSR);
093749e296e29a4 Chao Yu   2020-08-04  649   nsearched = 0;
093749e296e29a4 Chao Yu   2020-08-04  650  
093749e296e29a4 Chao Yu   2020-08-04  651   if (is_atgc)
093749e296e29a4 Chao Yu   2020-08-04  652   
SIT_I(sbi)->dirty_min_mtime = ULLONG_MAX;
093749e296e29a4 Chao Yu   2020-08-04  653  
e066b83c9b40f3a Jaegeuk Kim   2017-04-13  654   if (*result != NULL_SEGNO) {
97767500781fae9 Qilong Zhang  2020-06-28  655   if 
(!get_valid_blocks(sbi, *result, false)) {
9776750078