CC: [email protected]
CC: [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/axboe/linux-block.git 
for-5.17/block
head:   a77f46727daa3febf99663ab1a43c86cf3c2b957
commit: 3d7a7c45e29d5d1f5a9622557acb47443e8b6e28 [47/67] bfq: Limit number of 
requests consumed by each cgroup
:::::: branch date: 9 hours ago
:::::: commit date: 2 days ago
config: riscv-randconfig-c006-20211127 
(https://download.01.org/0day-ci/archive/20211128/[email protected]/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
5162b558d8c0b542e752b037e72a69d5fd51eb1e)
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/axboe/linux-block.git/commit/?id=3d7a7c45e29d5d1f5a9622557acb47443e8b6e28
        git remote add axboe-block 
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git
        git fetch --no-tags axboe-block for-5.17/block
        git checkout 3d7a7c45e29d5d1f5a9622557acb47443e8b6e28
        # 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 >>)
                                 ^
   net/decnet/dn_route.c:875:6: note: 'fi' is null
           if (fi) {
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                                
        ^~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
   net/decnet/dn_route.c:875:2: note: '?' condition is false
           if (fi) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   net/decnet/dn_route.c:875:2: note: Taking false branch
           if (fi) {
           ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   net/decnet/dn_route.c:883:6: note: Assuming 'dev' is equal to null
           if (dev != NULL && rt->n == NULL) {
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
   net/decnet/dn_route.c:883:18: note: Left side of '&&' is false
           if (dev != NULL && rt->n == NULL) {
                           ^
   net/decnet/dn_route.c:883:2: note: '?' condition is false
           if (dev != NULL && rt->n == NULL) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                 ^
   net/decnet/dn_route.c:883:6: note: 'dev' is equal to null
           if (dev != NULL && rt->n == NULL) {
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                                
        ^~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
   net/decnet/dn_route.c:883:18: note: Left side of '&&' is false
           if (dev != NULL && rt->n == NULL) {
                           ^
   net/decnet/dn_route.c:883:2: note: '?' condition is false
           if (dev != NULL && rt->n == NULL) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   net/decnet/dn_route.c:883:2: note: Taking false branch
           if (dev != NULL && rt->n == NULL) {
           ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   net/decnet/dn_route.c:890:39: note: Access to field 'mtu' results in a 
dereference of a null pointer (loaded from field 'dev')
           if (dst_metric(&rt->dst, RTAX_MTU) > rt->dst.dev->mtu)
                                                ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 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:583:6: note: Assuming field 'on_st_or_in_serv' is true
           if (!entity->on_st_or_in_serv)
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
   block/bfq-iosched.c:583:2: note: '?' condition is false
           if (!entity->on_st_or_in_serv)
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                 ^
   block/bfq-iosched.c:583:15: note: Field 'on_st_or_in_serv' is true
           if (!entity->on_st_or_in_serv)
                        ^
   block/bfq-iosched.c:583:2: note: '?' condition is false
           if (!entity->on_st_or_in_serv)
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   block/bfq-iosched.c:583:2: note: Taking false branch
           if (!entity->on_st_or_in_serv)
           ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   block/bfq-iosched.c:588:6: note: Assuming 'depth' is <= 16
           if (depth > BFQ_LIMIT_INLINE_DEPTH) {
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
   block/bfq-iosched.c:588:2: note: '?' condition is false
           if (depth > BFQ_LIMIT_INLINE_DEPTH) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                 ^
   block/bfq-iosched.c:588:6: note: 'depth' is <= 16
           if (depth > BFQ_LIMIT_INLINE_DEPTH) {
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                                
        ^~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
   block/bfq-iosched.c:588:2: note: '?' condition is false
           if (depth > BFQ_LIMIT_INLINE_DEPTH) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   block/bfq-iosched.c:588:2: note: Taking false branch
           if (depth > BFQ_LIMIT_INLINE_DEPTH) {
           ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   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)

vim +631 block/bfq-iosched.c

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

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

Reply via email to