:::::: :::::: Manual check reason: "low confidence static check warning: block/bfq-iosched.c:631:11: warning: Division by zero [clang-analyzer-core.DivideZero]" ::::::
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: 69cb6c6556ad89620547318439d6be8bb1629a5a commit: 76f1df88bbc2f984eb0418cc90de0a8384e63604 bfq: Limit number of requests consumed by each cgroup date: 7 months ago :::::: branch date: 20 hours ago :::::: commit date: 7 months ago config: arm-randconfig-c002-20220625 (https://download.01.org/0day-ci/archive/20220703/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 42a7ddb428c999229491b0effbb1a4059149fba8) 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 arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi # 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 COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <[email protected]> clang-analyzer warnings: (new ones prefixed by >>) if (bio_add_page(bio, page, length, 0) < length) { ^ fs/mpage.c:641:2: note: Assuming the condition is true BUG_ON(PageWriteback(page)); ^ include/asm-generic/bug.h:65:36: note: expanded from macro 'BUG_ON' #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) ^~~~~~~~~~~~~~~~~~~ include/linux/compiler.h:78:40: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^~~~ fs/mpage.c:641:2: note: Taking false branch BUG_ON(PageWriteback(page)); ^ include/asm-generic/bug.h:65:32: note: expanded from macro 'BUG_ON' #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) ^ fs/mpage.c:641:2: note: Loop condition is false. Exiting loop BUG_ON(PageWriteback(page)); ^ include/asm-generic/bug.h:65:27: note: expanded from macro 'BUG_ON' #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) ^ fs/mpage.c:644:6: note: 'boundary' is 0 if (boundary || (first_unmapped != blocks_per_page)) { ^~~~~~~~ fs/mpage.c:644:6: note: Left side of '||' is false fs/mpage.c:644:19: note: 'first_unmapped' is equal to 'blocks_per_page' if (boundary || (first_unmapped != blocks_per_page)) { ^~~~~~~~~~~~~~ fs/mpage.c:644:2: note: Taking false branch if (boundary || (first_unmapped != blocks_per_page)) { ^ fs/mpage.c:651:26: note: Assigned value is garbage or undefined mpd->last_block_in_bio = blocks[blocks_per_page - 1]; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 7 warnings (7 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. 8 warnings generated. drivers/gpu/drm/gud/gud_pipe.c:596:33: warning: Access to field 'width' results in a dereference of a null pointer (loaded from variable 'fb') [clang-analyzer-core.NullDereference] drm_rect_init(&damage, 0, 0, fb->width, fb->height); ^~ drivers/gpu/drm/gud/gud_pipe.c:566:2: note: 'fb' initialized here struct drm_framebuffer *fb = state->fb; ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/gud/gud_pipe.c:571:6: note: Assuming field 'mode_changed' is false if (crtc->state->mode_changed || !crtc->state->enable) { ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/gud/gud_pipe.c:571:6: note: Left side of '||' is false drivers/gpu/drm/gud/gud_pipe.c:571:35: note: Assuming field 'enable' is true if (crtc->state->mode_changed || !crtc->state->enable) { ^~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/gud/gud_pipe.c:571:2: note: Taking false branch if (crtc->state->mode_changed || !crtc->state->enable) { ^ drivers/gpu/drm/gud/gud_pipe.c:582:6: note: Assuming the condition is false if (!drm_dev_enter(drm, &idx)) ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/gud/gud_pipe.c:582:2: note: Taking false branch if (!drm_dev_enter(drm, &idx)) ^ drivers/gpu/drm/gud/gud_pipe.c:585:6: note: Assuming field 'fb' is non-null if (!old_state->fb) ^~~~~~~~~~~~~~ drivers/gpu/drm/gud/gud_pipe.c:585:2: note: Taking false branch if (!old_state->fb) ^ drivers/gpu/drm/gud/gud_pipe.c:588:6: note: Assuming 'fb' is null if (fb && (crtc->state->mode_changed || crtc->state->connectors_changed)) ^~ drivers/gpu/drm/gud/gud_pipe.c:588:9: note: Left side of '&&' is false if (fb && (crtc->state->mode_changed || crtc->state->connectors_changed)) ^ drivers/gpu/drm/gud/gud_pipe.c:591:6: note: Assuming field 'active_changed' is false if (crtc->state->active_changed) ^~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/gud/gud_pipe.c:591:2: note: Taking false branch if (crtc->state->active_changed) ^ drivers/gpu/drm/gud/gud_pipe.c:594:6: note: Assuming the condition is true if (drm_atomic_helper_damage_merged(old_state, state, &damage)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/gud/gud_pipe.c:594:2: note: Taking true branch if (drm_atomic_helper_damage_merged(old_state, state, &damage)) { ^ drivers/gpu/drm/gud/gud_pipe.c:595:7: note: Assuming the condition is true if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/gud/gud_pipe.c:595:3: note: Taking true branch if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE) ^ drivers/gpu/drm/gud/gud_pipe.c:596:33: note: Access to field 'width' results in a dereference of a null pointer (loaded from variable 'fb') drm_rect_init(&damage, 0, 0, fb->width, fb->height); ^~ Suppressed 7 warnings (7 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. 7 warnings generated. Suppressed 7 warnings (7 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. 10 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:146:18: note: expanded from macro 'WARN_ON_ONCE' DO_ONCE_LITE_IF(condition, WARN_ON, 1) ^~~~~~~~~ include/linux/once_lite.h:15:27: note: expanded from macro 'DO_ONCE_LITE_IF' bool __ret_do_once = !!(condition); \ ^~~~~~~~~ block/bfq-iosched.c:607:7: note: '__ret_do_once' is false if (WARN_ON_ONCE(level >= depth)) ^ include/asm-generic/bug.h:146:2: note: expanded from macro 'WARN_ON_ONCE' DO_ONCE_LITE_IF(condition, WARN_ON, 1) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/once_lite.h:17:16: note: expanded from macro 'DO_ONCE_LITE_IF' if (unlikely(__ret_do_once && !__already_done)) { \ ^~~~~~~~~~~~~ include/linux/compiler.h:78:42: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ block/bfq-iosched.c:607:7: note: Left side of '&&' is false if (WARN_ON_ONCE(level >= depth)) ^ include/asm-generic/bug.h:146:2: note: expanded from macro 'WARN_ON_ONCE' DO_ONCE_LITE_IF(condition, WARN_ON, 1) ^ include/linux/once_lite.h:17:30: note: expanded from macro 'DO_ONCE_LITE_IF' if (unlikely(__ret_do_once && !__already_done)) { \ ^ block/bfq-iosched.c:607:7: note: Taking false branch if (WARN_ON_ONCE(level >= depth)) ^ include/asm-generic/bug.h:146:2: note: expanded from macro 'WARN_ON_ONCE' DO_ONCE_LITE_IF(condition, WARN_ON, 1) ^ include/linux/once_lite.h:17:3: note: expanded from macro 'DO_ONCE_LITE_IF' if (unlikely(__ret_do_once && !__already_done)) { \ ^ 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); 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]
