CC: [email protected]
CC: [email protected]
BCC: [email protected]
CC: [email protected]
TO: Jan Kara <[email protected]>
CC: Jens Axboe <[email protected]>
CC: "Michal Koutný" <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   ce522ba9ef7e2d9fb22a39eb3371c0c64e2a433e
commit: 76f1df88bbc2f984eb0418cc90de0a8384e63604 bfq: Limit number of requests 
consumed by each cgroup
date:   4 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 4 months ago
config: riscv-randconfig-c006-20220405 
(https://download.01.org/0day-ci/archive/20220411/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 
c4a1b07d0979e7ff20d7d541af666d822d66b566)
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 riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=76f1df88bbc2f984eb0418cc90de0a8384e63604
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 76f1df88bbc2f984eb0418cc90de0a8384e63604
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
                                   ^
   arch/riscv/include/asm/bug.h:79:29: note: expanded from macro '__WARN_FLAGS'
   #define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
                               ^
   arch/riscv/include/asm/bug.h:53:32: note: expanded from macro '__BUG_FLAGS'
   #define __BUG_FLAGS(flags)                                      \
                                                                   ^
   drivers/spi/spi-nxp-fspi.c:876:2: note: Calling 'nxp_fspi_prepare_lut'
           nxp_fspi_prepare_lut(f, op);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/spi/spi-nxp-fspi.c:538:6: note: Assuming field 'nbytes' is 0
           if (op->addr.nbytes) {
               ^~~~~~~~~~~~~~~
   drivers/spi/spi-nxp-fspi.c:538:2: note: Taking false branch
           if (op->addr.nbytes) {
           ^
   drivers/spi/spi-nxp-fspi.c:546:6: note: Assuming field 'nbytes' is not equal 
to 0
           if (op->dummy.nbytes) {
               ^~~~~~~~~~~~~~~~
   drivers/spi/spi-nxp-fspi.c:546:2: note: Taking true branch
           if (op->dummy.nbytes) {
           ^
   drivers/spi/spi-nxp-fspi.c:547:25: note: The result of the left shift is 
undefined because the left operand is negative
                   lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_DUMMY,
                                         ^
   drivers/spi/spi-nxp-fspi.c:311:36: note: expanded from macro 'LUT_DEF'
           ((((ins) << INSTR_SHIFT) | ((pad) << PAD_SHIFT) | \
                                       ~~~~~ ^
   drivers/spi/spi-nxp-fspi.c:560:25: warning: The result of the left shift is 
undefined because the left operand is negative 
[clang-analyzer-core.UndefinedBinaryOperatorResult]
                   lutval[lutidx / 2] |= LUT_DEF(lutidx,
                                         ^
   drivers/spi/spi-nxp-fspi.c:311:36: note: expanded from macro 'LUT_DEF'
           ((((ins) << INSTR_SHIFT) | ((pad) << PAD_SHIFT) | \
                                             ^
   drivers/spi/spi-nxp-fspi.c:872:2: note: Assuming 'err' is not equal to 0
           WARN_ON(err);
           ^
   include/asm-generic/bug.h:121:23: note: expanded from macro 'WARN_ON'
           int __ret_warn_on = !!(condition);                              \
                                ^~~~~~~~~~~~
   drivers/spi/spi-nxp-fspi.c:872:2: note: Taking true branch
           WARN_ON(err);
           ^
   include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
           if (unlikely(__ret_warn_on))                                    \
           ^
   drivers/spi/spi-nxp-fspi.c:872:2: note: Loop condition is false.  Exiting 
loop
           WARN_ON(err);
           ^
   include/asm-generic/bug.h:123:3: note: expanded from macro 'WARN_ON'
                   __WARN();                                               \
                   ^
   include/asm-generic/bug.h:96:19: note: expanded from macro '__WARN'
   #define __WARN()                __WARN_FLAGS(BUGFLAG_TAINT(TAINT_WARN))
                                   ^
   arch/riscv/include/asm/bug.h:79:29: note: expanded from macro '__WARN_FLAGS'
   #define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
                               ^
   arch/riscv/include/asm/bug.h:53:32: note: expanded from macro '__BUG_FLAGS'
   #define __BUG_FLAGS(flags)                                      \
                                                                   ^
   drivers/spi/spi-nxp-fspi.c:876:2: note: Calling 'nxp_fspi_prepare_lut'
           nxp_fspi_prepare_lut(f, op);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/spi/spi-nxp-fspi.c:538:6: note: Assuming field 'nbytes' is 0
           if (op->addr.nbytes) {
               ^~~~~~~~~~~~~~~
   drivers/spi/spi-nxp-fspi.c:538:2: note: Taking false branch
           if (op->addr.nbytes) {
           ^
   drivers/spi/spi-nxp-fspi.c:546:6: note: Assuming field 'nbytes' is 0
           if (op->dummy.nbytes) {
               ^~~~~~~~~~~~~~~~
   drivers/spi/spi-nxp-fspi.c:546:2: note: Taking false branch
           if (op->dummy.nbytes) {
           ^
   drivers/spi/spi-nxp-fspi.c:559:6: note: Assuming field 'nbytes' is not equal 
to 0
           if (op->data.nbytes) {
               ^~~~~~~~~~~~~~~
   drivers/spi/spi-nxp-fspi.c:559:2: note: Taking true branch
           if (op->data.nbytes) {
           ^
   drivers/spi/spi-nxp-fspi.c:561:12: note: Assuming field 'dir' is not equal 
to SPI_MEM_DATA_IN
                                                 op->data.dir == 
SPI_MEM_DATA_IN ?
                                                 ^
   drivers/spi/spi-nxp-fspi.c:311:6: note: expanded from macro 'LUT_DEF'
           ((((ins) << INSTR_SHIFT) | ((pad) << PAD_SHIFT) | \
               ^~~
   drivers/spi/spi-nxp-fspi.c:561:12: note: '?' condition is false
                                                 op->data.dir == 
SPI_MEM_DATA_IN ?
                                                 ^
   drivers/spi/spi-nxp-fspi.c:560:25: note: The result of the left shift is 
undefined because the left operand is negative
                   lutval[lutidx / 2] |= LUT_DEF(lutidx,
                                         ^
   drivers/spi/spi-nxp-fspi.c:311:36: note: expanded from macro 'LUT_DEF'
           ((((ins) << INSTR_SHIFT) | ((pad) << PAD_SHIFT) | \
                                       ~~~~~ ^
   Suppressed 10 warnings (3 in non-user code, 7 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   13 warnings generated.
>> block/bfq-iosched.c:631:11: warning: Division by zero 
>> [clang-analyzer-core.DivideZero]
                   limit = DIV_ROUND_CLOSEST(limit * entity->weight, wsum);
                           ^
   include/linux/math.h:92:26: note: expanded from macro 'DIV_ROUND_CLOSEST'
                   (((__x) + ((__d) / 2)) / (__d)) :       \
                                          ^
   block/bfq-iosched.c:672:27: note: Assuming 'bic' is non-null
           struct bfq_queue *bfqq = bic ? bic_to_bfqq(bic, op_is_sync(op)) : 
NULL;
                                    ^~~
   block/bfq-iosched.c:672:27: note: '?' condition is true
   block/bfq-iosched.c:677:6: note: Assuming the condition is true
           if (op_is_sync(op) && !op_is_write(op)) {
               ^~~~~~~~~~~~~~
   block/bfq-iosched.c:677:6: note: Left side of '&&' is true
   block/bfq-iosched.c:677:24: note: Assuming the condition is true
           if (op_is_sync(op) && !op_is_write(op)) {
                                 ^~~~~~~~~~~~~~~~
   block/bfq-iosched.c:677:2: note: Taking true branch
           if (op_is_sync(op) && !op_is_write(op)) {
           ^
   block/bfq-iosched.c:689:6: note: Assuming 'bfqq' is non-null
           if (bfqq && bfqq_request_over_limit(bfqq, limit))
               ^~~~
   block/bfq-iosched.c:689:6: note: Left side of '&&' is true
   block/bfq-iosched.c:689:14: note: Calling 'bfqq_request_over_limit'
           if (bfqq && bfqq_request_over_limit(bfqq, limit))
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   block/bfq-iosched.c:583:6: note: Assuming field 'on_st_or_in_serv' is true
           if (!entity->on_st_or_in_serv)
               ^~~~~~~~~~~~~~~~~~~~~~~~~
   block/bfq-iosched.c:583:2: note: Taking false branch
           if (!entity->on_st_or_in_serv)
           ^
   block/bfq-iosched.c:588:6: note: Assuming 'depth' is <= 
BFQ_LIMIT_INLINE_DEPTH
           if (depth > BFQ_LIMIT_INLINE_DEPTH) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   block/bfq-iosched.c:588:2: note: Taking false branch
           if (depth > BFQ_LIMIT_INLINE_DEPTH) {
           ^
   block/bfq-iosched.c:598:2: note: Loop condition is true.  Entering loop body
           for_each_entity(entity) {
           ^
   block/bfq-iosched.h:1028:2: note: expanded from macro 'for_each_entity'
           for (; entity ; entity = entity->parent)
           ^
   block/bfq-iosched.c:604:7: note: Assuming field 'on_st_or_in_serv' is true
                   if (!entity->on_st_or_in_serv)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
   block/bfq-iosched.c:604:3: note: Taking false branch
                   if (!entity->on_st_or_in_serv)
                   ^
   block/bfq-iosched.c:607:20: note: Assuming 'level' is < 'depth'
                   if (WARN_ON_ONCE(level >= depth))
                                    ^
   include/asm-generic/bug.h:104:25: note: expanded from macro 'WARN_ON_ONCE'
           int __ret_warn_on = !!(condition);                      \
                                  ^~~~~~~~~
   block/bfq-iosched.c:607:7: note: Taking false branch
                   if (WARN_ON_ONCE(level >= depth))
                       ^
   include/asm-generic/bug.h:105:2: note: expanded from macro 'WARN_ON_ONCE'
           if (unlikely(__ret_warn_on))                            \
           ^
   block/bfq-iosched.c:607:3: note: Taking false branch
                   if (WARN_ON_ONCE(level >= depth))
                   ^
   block/bfq-iosched.c:598:2: note: Loop condition is false. Execution 
continues on line 611
           for_each_entity(entity) {
           ^
   block/bfq-iosched.h:1028:2: note: expanded from macro 'for_each_entity'
           for (; entity ; entity = entity->parent)
           ^
   block/bfq-iosched.c:611:15: note: Assuming 'level' is equal to 'depth'
           WARN_ON_ONCE(level != depth);
                        ^
   include/asm-generic/bug.h:104:25: note: expanded from macro 'WARN_ON_ONCE'
           int __ret_warn_on = !!(condition);                      \
                                  ^~~~~~~~~
   block/bfq-iosched.c:611:2: note: Taking false branch
           WARN_ON_ONCE(level != depth);
           ^
   include/asm-generic/bug.h:105:2: note: expanded from macro 'WARN_ON_ONCE'
           if (unlikely(__ret_warn_on))                            \
           ^
   block/bfq-iosched.c:612:2: note: Loop condition is true.  Entering loop body
           for (level--; level >= 0; level--) {
           ^
   block/bfq-iosched.c:614:7: note: 'level' is <= 0
                   if (level > 0) {
                       ^~~~~
   block/bfq-iosched.c:614:3: note: Taking false branch
                   if (level > 0) {
                   ^
   block/bfq-iosched.c:625:4: note: The value 0 is assigned to 'wsum'
                           wsum = 0;
                           ^~~~~~~~
   block/bfq-iosched.c:626:16: note: Assuming 'i' is > 'class_idx'
                           for (i = 0; i <= class_idx; i++) {
                                       ^~~~~~~~~~~~~~
   block/bfq-iosched.c:626:4: note: Loop condition is false. Execution 
continues on line 631
                           for (i = 0; i <= class_idx; i++) {

vim +631 block/bfq-iosched.c

76f1df88bbc2f9 Jan Kara 2021-11-25  569  
76f1df88bbc2f9 Jan Kara 2021-11-25  570  #ifdef CONFIG_BFQ_GROUP_IOSCHED
76f1df88bbc2f9 Jan Kara 2021-11-25  571  static bool 
bfqq_request_over_limit(struct bfq_queue *bfqq, int limit)
76f1df88bbc2f9 Jan Kara 2021-11-25  572  {
76f1df88bbc2f9 Jan Kara 2021-11-25  573         struct bfq_data *bfqd = 
bfqq->bfqd;
76f1df88bbc2f9 Jan Kara 2021-11-25  574         struct bfq_entity *entity = 
&bfqq->entity;
76f1df88bbc2f9 Jan Kara 2021-11-25  575         struct bfq_entity 
*inline_entities[BFQ_LIMIT_INLINE_DEPTH];
76f1df88bbc2f9 Jan Kara 2021-11-25  576         struct bfq_entity **entities = 
inline_entities;
76f1df88bbc2f9 Jan Kara 2021-11-25  577         int depth, level;
76f1df88bbc2f9 Jan Kara 2021-11-25  578         int class_idx = 
bfqq->ioprio_class - 1;
76f1df88bbc2f9 Jan Kara 2021-11-25  579         struct bfq_sched_data 
*sched_data;
76f1df88bbc2f9 Jan Kara 2021-11-25  580         unsigned long wsum;
76f1df88bbc2f9 Jan Kara 2021-11-25  581         bool ret = false;
76f1df88bbc2f9 Jan Kara 2021-11-25  582  
76f1df88bbc2f9 Jan Kara 2021-11-25  583         if (!entity->on_st_or_in_serv)
76f1df88bbc2f9 Jan Kara 2021-11-25  584                 return false;
76f1df88bbc2f9 Jan Kara 2021-11-25  585  
76f1df88bbc2f9 Jan Kara 2021-11-25  586         /* +1 for bfqq entity, root 
cgroup not included */
76f1df88bbc2f9 Jan Kara 2021-11-25  587         depth = 
bfqg_to_blkg(bfqq_group(bfqq))->blkcg->css.cgroup->level + 1;
76f1df88bbc2f9 Jan Kara 2021-11-25  588         if (depth > 
BFQ_LIMIT_INLINE_DEPTH) {
76f1df88bbc2f9 Jan Kara 2021-11-25  589                 entities = 
kmalloc_array(depth, sizeof(*entities), GFP_NOIO);
76f1df88bbc2f9 Jan Kara 2021-11-25  590                 if (!entities)
76f1df88bbc2f9 Jan Kara 2021-11-25  591                         return false;
76f1df88bbc2f9 Jan Kara 2021-11-25  592         }
76f1df88bbc2f9 Jan Kara 2021-11-25  593  
76f1df88bbc2f9 Jan Kara 2021-11-25  594         spin_lock_irq(&bfqd->lock);
76f1df88bbc2f9 Jan Kara 2021-11-25  595         sched_data = entity->sched_data;
76f1df88bbc2f9 Jan Kara 2021-11-25  596         /* Gather our ancestors as we 
need to traverse them in reverse order */
76f1df88bbc2f9 Jan Kara 2021-11-25  597         level = 0;
76f1df88bbc2f9 Jan Kara 2021-11-25  598         for_each_entity(entity) {
76f1df88bbc2f9 Jan Kara 2021-11-25  599                 /*
76f1df88bbc2f9 Jan Kara 2021-11-25  600                  * If at some level 
entity is not even active, allow request
76f1df88bbc2f9 Jan Kara 2021-11-25  601                  * queueing so that BFQ 
knows there's work to do and activate
76f1df88bbc2f9 Jan Kara 2021-11-25  602                  * entities.
76f1df88bbc2f9 Jan Kara 2021-11-25  603                  */
76f1df88bbc2f9 Jan Kara 2021-11-25  604                 if 
(!entity->on_st_or_in_serv)
76f1df88bbc2f9 Jan Kara 2021-11-25  605                         goto out;
76f1df88bbc2f9 Jan Kara 2021-11-25  606                 /* Uh, more parents 
than cgroup subsystem thinks? */
76f1df88bbc2f9 Jan Kara 2021-11-25  607                 if (WARN_ON_ONCE(level 
>= depth))
76f1df88bbc2f9 Jan Kara 2021-11-25  608                         break;
76f1df88bbc2f9 Jan Kara 2021-11-25  609                 entities[level++] = 
entity;
76f1df88bbc2f9 Jan Kara 2021-11-25  610         }
76f1df88bbc2f9 Jan Kara 2021-11-25  611         WARN_ON_ONCE(level != depth);
76f1df88bbc2f9 Jan Kara 2021-11-25  612         for (level--; level >= 0; 
level--) {
76f1df88bbc2f9 Jan Kara 2021-11-25  613                 entity = 
entities[level];
76f1df88bbc2f9 Jan Kara 2021-11-25  614                 if (level > 0) {
76f1df88bbc2f9 Jan Kara 2021-11-25  615                         wsum = 
bfq_entity_service_tree(entity)->wsum;
76f1df88bbc2f9 Jan Kara 2021-11-25  616                 } else {
76f1df88bbc2f9 Jan Kara 2021-11-25  617                         int i;
76f1df88bbc2f9 Jan Kara 2021-11-25  618                         /*
76f1df88bbc2f9 Jan Kara 2021-11-25  619                          * For bfqq 
itself we take into account service trees
76f1df88bbc2f9 Jan Kara 2021-11-25  620                          * of all 
higher priority classes and multiply their
76f1df88bbc2f9 Jan Kara 2021-11-25  621                          * weights so 
that low prio queue from higher class
76f1df88bbc2f9 Jan Kara 2021-11-25  622                          * gets more 
requests than high prio queue from lower
76f1df88bbc2f9 Jan Kara 2021-11-25  623                          * class.
76f1df88bbc2f9 Jan Kara 2021-11-25  624                          */
76f1df88bbc2f9 Jan Kara 2021-11-25  625                         wsum = 0;
76f1df88bbc2f9 Jan Kara 2021-11-25  626                         for (i = 0; i 
<= class_idx; i++) {
76f1df88bbc2f9 Jan Kara 2021-11-25  627                                 wsum = 
wsum * IOPRIO_BE_NR +
76f1df88bbc2f9 Jan Kara 2021-11-25  628                                         
sched_data->service_tree[i].wsum;
76f1df88bbc2f9 Jan Kara 2021-11-25  629                         }
76f1df88bbc2f9 Jan Kara 2021-11-25  630                 }
76f1df88bbc2f9 Jan Kara 2021-11-25 @631                 limit = 
DIV_ROUND_CLOSEST(limit * entity->weight, wsum);
76f1df88bbc2f9 Jan Kara 2021-11-25  632                 if (entity->allocated 
>= limit) {
76f1df88bbc2f9 Jan Kara 2021-11-25  633                         
bfq_log_bfqq(bfqq->bfqd, bfqq,
76f1df88bbc2f9 Jan Kara 2021-11-25  634                                 "too 
many requests: allocated %d limit %d level %d",
76f1df88bbc2f9 Jan Kara 2021-11-25  635                                 
entity->allocated, limit, level);
76f1df88bbc2f9 Jan Kara 2021-11-25  636                         ret = true;
76f1df88bbc2f9 Jan Kara 2021-11-25  637                         break;
76f1df88bbc2f9 Jan Kara 2021-11-25  638                 }
76f1df88bbc2f9 Jan Kara 2021-11-25  639         }
76f1df88bbc2f9 Jan Kara 2021-11-25  640  out:
76f1df88bbc2f9 Jan Kara 2021-11-25  641         spin_unlock_irq(&bfqd->lock);
76f1df88bbc2f9 Jan Kara 2021-11-25  642         if (entities != inline_entities)
76f1df88bbc2f9 Jan Kara 2021-11-25  643                 kfree(entities);
76f1df88bbc2f9 Jan Kara 2021-11-25  644         return ret;
76f1df88bbc2f9 Jan Kara 2021-11-25  645  }
76f1df88bbc2f9 Jan Kara 2021-11-25  646  #else
76f1df88bbc2f9 Jan Kara 2021-11-25  647  static bool 
bfqq_request_over_limit(struct bfq_queue *bfqq, int limit)
76f1df88bbc2f9 Jan Kara 2021-11-25  648  {
76f1df88bbc2f9 Jan Kara 2021-11-25  649         return false;
76f1df88bbc2f9 Jan Kara 2021-11-25  650  }
76f1df88bbc2f9 Jan Kara 2021-11-25  651  #endif
76f1df88bbc2f9 Jan Kara 2021-11-25  652  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to