All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [peterz-queue:sched/core-sched 10/11] kernel/sched/core.c:5262 pick_next_task() error: we previously assumed 'next' could be null (see line 5258)
Date: Mon, 11 Jan 2021 13:41:37 +0300	[thread overview]
Message-ID: <20210111104137.GC5083@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 5105 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git sched/core-sched
head:   ead81f232b5b31ab6240a719ff3bad564c3f0e4c
commit: 6f7eefbb382e8c5fa56180f8cd5becb5f882a3d6 [10/11] sched/fair: Snapshot the min_vruntime of CPUs on force idle
config: x86_64-randconfig-m001-20210108 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
kernel/sched/core.c:5262 pick_next_task() error: we previously assumed 'next' could be null (see line 5258)

vim +/next +5262 kernel/sched/core.c

2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5225  
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5226  	put_prev_task_balance(rq, prev, rf);
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5227  
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5228  	smt_mask = cpu_smt_mask(cpu);
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5229) 	need_sync = !!rq->core->core_cookie;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5230) 
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5231) 	/* reset state */
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5232) 	rq->core->core_cookie = 0UL;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5233) 	if (rq->core->core_forceidle) {
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5234) 		need_sync = true;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5235) 		fi_before = true;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5236) 		rq->core->core_forceidle = false;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5237) 	}
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5238  
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5239  	/*
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5240  	 * core->core_task_seq, core->core_pick_seq, rq->core_sched_seq
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5241  	 *
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5242  	 * @task_seq guards the task state ({en,de}queues)
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5243  	 * @pick_seq is the @task_seq we did a selection on
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5244  	 * @sched_seq is the @pick_seq we scheduled
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5245  	 *
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5246  	 * However, preemptions can cause multiple picks on the same task set.
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5247  	 * 'Fix' this by also increasing @task_seq for every pick.
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5248  	 */
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5249  	rq->core->core_task_seq++;
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5250  
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5251) 	/*
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5252) 	 * Optimize for common case where this CPU has no cookies
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5253) 	 * and there are no cookied tasks running on siblings.
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5254) 	 */
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5255) 	if (!need_sync) {
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5256) 		for_each_class(class) {
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5257) 			next = class->pick_task(rq);
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17 @5258) 			if (next)
                                                                                    ^^^^
Will we always find a valid "next"?

d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5259) 				break;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5260) 		}
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5261) 
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17 @5262) 		if (!next->core_cookie) {
                                                                             ^^^^^^^^^^^^^^^^^
Unchecked dereference.

d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5263) 			rq->core_pick = NULL;
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5264) 			/*
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5265) 			 * For robustness, update the min_vruntime_fi for
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5266) 			 * unconstrained picks as well.
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5267) 			 */
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5268) 			WARN_ON_ONCE(fi_before);
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5269) 			task_vruntime_update(rq, next, false);
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5270) 			goto done;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5271) 		}
651b592b4b80bae Vineeth Pillai          2020-11-17  5272  	}
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5273) 

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30068 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [peterz-queue:sched/core-sched 10/11] kernel/sched/core.c:5262 pick_next_task() error: we previously assumed 'next' could be null (see line 5258)
Date: Mon, 11 Jan 2021 13:41:37 +0300	[thread overview]
Message-ID: <20210111104137.GC5083@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 5105 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git sched/core-sched
head:   ead81f232b5b31ab6240a719ff3bad564c3f0e4c
commit: 6f7eefbb382e8c5fa56180f8cd5becb5f882a3d6 [10/11] sched/fair: Snapshot the min_vruntime of CPUs on force idle
config: x86_64-randconfig-m001-20210108 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
kernel/sched/core.c:5262 pick_next_task() error: we previously assumed 'next' could be null (see line 5258)

vim +/next +5262 kernel/sched/core.c

2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5225  
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5226  	put_prev_task_balance(rq, prev, rf);
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5227  
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5228  	smt_mask = cpu_smt_mask(cpu);
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5229) 	need_sync = !!rq->core->core_cookie;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5230) 
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5231) 	/* reset state */
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5232) 	rq->core->core_cookie = 0UL;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5233) 	if (rq->core->core_forceidle) {
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5234) 		need_sync = true;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5235) 		fi_before = true;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5236) 		rq->core->core_forceidle = false;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5237) 	}
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5238  
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5239  	/*
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5240  	 * core->core_task_seq, core->core_pick_seq, rq->core_sched_seq
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5241  	 *
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5242  	 * @task_seq guards the task state ({en,de}queues)
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5243  	 * @pick_seq is the @task_seq we did a selection on
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5244  	 * @sched_seq is the @pick_seq we scheduled
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5245  	 *
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5246  	 * However, preemptions can cause multiple picks on the same task set.
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5247  	 * 'Fix' this by also increasing @task_seq for every pick.
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5248  	 */
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5249  	rq->core->core_task_seq++;
2d8ac06b6ca3a0f Peter Zijlstra          2020-11-17  5250  
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5251) 	/*
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5252) 	 * Optimize for common case where this CPU has no cookies
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5253) 	 * and there are no cookied tasks running on siblings.
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5254) 	 */
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5255) 	if (!need_sync) {
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5256) 		for_each_class(class) {
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5257) 			next = class->pick_task(rq);
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17 @5258) 			if (next)
                                                                                    ^^^^
Will we always find a valid "next"?

d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5259) 				break;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5260) 		}
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5261) 
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17 @5262) 		if (!next->core_cookie) {
                                                                             ^^^^^^^^^^^^^^^^^
Unchecked dereference.

d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5263) 			rq->core_pick = NULL;
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5264) 			/*
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5265) 			 * For robustness, update the min_vruntime_fi for
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5266) 			 * unconstrained picks as well.
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5267) 			 */
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5268) 			WARN_ON_ONCE(fi_before);
6f7eefbb382e8c5 Joel Fernandes (Google  2020-11-17  5269) 			task_vruntime_update(rq, next, false);
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5270) 			goto done;
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5271) 		}
651b592b4b80bae Vineeth Pillai          2020-11-17  5272  	}
d7bbf5f9ab91135 Joel Fernandes (Google  2020-11-17  5273) 

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30068 bytes --]

             reply	other threads:[~2021-01-11 10:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 10:41 Dan Carpenter [this message]
2021-01-11 10:41 ` [peterz-queue:sched/core-sched 10/11] kernel/sched/core.c:5262 pick_next_task() error: we previously assumed 'next' could be null (see line 5258) Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2021-01-08 14:32 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210111104137.GC5083@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.