public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Schspa Shi <schspa@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	bsegall@google.com, mgorman@suse.de, bristot@redhat.com,
	vschneid@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] sched/rt: fix bad task migration for rt tasks
Date: Sat, 09 Jul 2022 03:55:40 +0800	[thread overview]
Message-ID: <m2v8s7nzr6.fsf@gmail.com> (raw)
In-Reply-To: <20220708154111.36e662b2@gandalf.local.home>


Steven Rostedt <rostedt@goodmis.org> writes:

> On Sat, 09 Jul 2022 03:14:44 +0800
> Schspa Shi <schspa@gmail.com> wrote:
>
>> Steven Rostedt <rostedt@goodmis.org> writes:
>> 
>> > On Sat, 09 Jul 2022 02:19:42 +0800
>> > Schspa Shi <schspa@gmail.com> wrote:
>> >  
>> >> Yes, it's what I did in the V1 patch.
>> >> Link: https://lore.kernel.org/all/20220623182932.58589-1-schspa@gmail.com/
>> >> 
>> >> But I think it's not the best solution for this problem.
>> >> In these scenarios, we still have a chance to make the task run faster
>> >> by retrying to retry to push the currently running task on this CPU away.
>> >> 
>> >> There is more details on V2 patch's replay message.
>> >> Link: https://lore.kernel.org/all/CAMA88TrZ-o4W81Yfw9Wcs3ghoxwpeAKtFejtMTt78GNB0tKaSA@mail.gmail.com/#t  
>> >
>> > The thing is, this situation can only happen if we release the rq lock in
>> > find_lock_lowest_rq(), and we should not be checking for it in the other
>> > cases.
>> >  
>> 
>> If we haven't unlock the rq in find_lock_lowest_rq(), it will return
>> NULL. It won't call this code added.
>> 
>> 	if (unlikely(is_migration_disabled(next_task))) {
>> 		put_task_struct(next_task);
>> 		goto retry;
>> 	}
>
> Because it doesn't need to. If it did not unlock the run queue, there's no
> way that next_task could have run, because we hold the rq lock for
> next_task. Which means that its "migrate_disable" state would not have
> changed from the first time we checked.
>

OK, I get it.

>> 
>> 	deactivate_task(rq, next_task, 0);
>> 	set_task_cpu(next_task, lowest_rq->cpu);
>> 
>> Beside, find_lock_lowest_rq() return NULL doesn't means rq is rleased,
>> We need to add a _find_lock_lowest_rq to get the correct rq released
>> flags?
>
> It it returns NULL it either means that the rq lock was released or that it
> did not find a rq to push to. Which means there's nothing more to do anyway.
>
>> 
>> > Perhaps add the check in find_lock_lowest_rq() and also in the !lowest_rq
>> > case do:
>> >
>> > 		task = pick_next_pushable_task(rq);
>> > 		if (task == next_task) {
>> > +			/*
>> > +			 * If next task has now disabled migrating, see if we
>> > +			 * can push the current task.
>> > +			 */
>> > +			if (unlikely(is_migrate_disabled(task)))
>> > +				goto retry;  
>> 
>> Ahh, It can be added, And do we need this to be a separate PATCH?
>
> Sure.
>
> The "fix" to the crash you see should be in the find_lock_lowest_rq() as I
> suggested. And then you can add this as an optimization.

OK, I will make a V4 patch for this, Please review it then.

>
> -- Steve
>
>> 
>> > 			/*
>> > 			 * The task hasn't migrated, and is still the next
>> > 			 * eligible task, but we failed to find a run-queue
>> > 			 * to push it to.  Do not retry in this case, since
>> > 			 * other CPUs will pull from us when ready.
>> > 			 */
>> > 			goto out;
>> > 		}
>> >
>> > -- Steve  
>> 

-- 
BRs
Schspa Shi

      reply	other threads:[~2022-07-08 19:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 16:50 [PATCH v3] sched/rt: fix bad task migration for rt tasks Schspa Shi
2022-07-07 17:53 ` Steven Rostedt
2022-07-08  4:51   ` Schspa Shi
2022-07-08 18:00     ` Steven Rostedt
2022-07-08 18:19       ` Schspa Shi
2022-07-08 19:06         ` Steven Rostedt
2022-07-08 19:14           ` Schspa Shi
2022-07-08 19:41             ` Steven Rostedt
2022-07-08 19:55               ` Schspa Shi [this message]

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=m2v8s7nzr6.fsf@gmail.com \
    --to=schspa@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox