linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>,
	"Luis Claudio R . Goncalves" <lgoncalv@redhat.com>,
	Clark Williams <williams@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] rt: Increase/decrease the nr of migratory tasks when enabling/disabling migration
Date: Thu, 22 Jun 2017 21:49:44 +0200	[thread overview]
Message-ID: <20170622194943.ho4yekdqqeg2qiva@gmail.com> (raw)
In-Reply-To: <5c90773d-1283-d3de-4282-e3855331d4e4@redhat.com>


* Daniel Bristot de Oliveira <bristot@redhat.com> wrote:

> On 06/22/2017 10:38 AM, Ingo Molnar wrote:
> > 
> > * Daniel Bristot de Oliveira <bristot@redhat.com> wrote:
> > 
> >>  void migrate_disable(void)
> >>  {
> >>  	struct task_struct *p = current;
> >> +	struct rq *rq;
> >> +	struct rq_flags rf;
> >> +
> >>  
> >>  	if (in_atomic() || irqs_disabled()) {
> >>  #ifdef CONFIG_SCHED_DEBUG
> >> @@ -7593,10 +7596,21 @@ void migrate_disable(void)
> >>  	preempt_disable();
> >>  	preempt_lazy_disable();
> >>  	pin_current_cpu();
> >> -	p->migrate_disable = 1;
> >>  
> >> -	p->cpus_ptr = cpumask_of(smp_processor_id());
> >> +	rq = task_rq_lock(p, &rf);
> >> +	if (unlikely((p->sched_class == &rt_sched_class ||
> >> +		      p->sched_class == &dl_sched_class) &&
> >> +		      p->nr_cpus_allowed > 1)) {
> >> +		if (p->sched_class == &rt_sched_class)
> >> +			task_rq(p)->rt.rt_nr_migratory--;
> >> +		else
> >> +			task_rq(p)->dl.dl_nr_migratory--;
> >> +	}
> >>  	p->nr_cpus_allowed = 1;
> >> +	task_rq_unlock(rq, p, &rf);
> >> +	p->cpus_ptr = cpumask_of(smp_processor_id());
> >> +	p->migrate_disable = 1;
> >> +
> >>  
> >>  	preempt_enable();
> >>  }
> >> @@ -7605,6 +7619,9 @@ EXPORT_SYMBOL(migrate_disable);
> >>  void migrate_enable(void)
> >>  {
> >>  	struct task_struct *p = current;
> >> +	struct rq *rq;
> >> +	struct rq_flags rf;
> >> +
> >>  
> >>  	if (in_atomic() || irqs_disabled()) {
> >>  #ifdef CONFIG_SCHED_DEBUG
> >> @@ -7628,17 +7645,24 @@ void migrate_enable(void)
> >>  
> >>  	preempt_disable();
> >>  
> >> -	p->cpus_ptr = &p->cpus_mask;
> >> -	p->nr_cpus_allowed = cpumask_weight(&p->cpus_mask);
> >>  	p->migrate_disable = 0;
> >> +	p->cpus_ptr = &p->cpus_mask;
> >>  
> >> -	if (p->migrate_disable_update) {
> >> -		struct rq *rq;
> >> -		struct rq_flags rf;
> >> +	rq = task_rq_lock(p, &rf);
> >> +	p->nr_cpus_allowed = cpumask_weight(&p->cpus_mask);
> >> +	if (unlikely((p->sched_class == &rt_sched_class ||
> >> +		      p->sched_class == &dl_sched_class) &&
> >> +		      p->nr_cpus_allowed > 1)) {
> >> +		if (p->sched_class == &rt_sched_class)
> >> +			task_rq(p)->rt.rt_nr_migratory++;
> >> +		else
> >> +			task_rq(p)->dl.dl_nr_migratory++;
> >> +	}
> >> +	task_rq_unlock(rq, p, &rf);
> > 
> > The fix looks good to me, but AFAICS the repeat pattern introduced here could be 
> > factored out into a helper function instead, right?
> 
> Like:
> 
> static inline int task_in_rt_class(struct task_struct *p)
> {
> 	return p->sched_class == &rt_sched_class;
> }
> 
> static inline int task_in_dl_class(struct task_struct *p)
> {
> 	return p->sched_class == &dl_sched_class;
> }
> 
> ?

So AFAICS it's this block that is used twice:

> >> +	rq = task_rq_lock(p, &rf);
> >> +	p->nr_cpus_allowed = cpumask_weight(&p->cpus_mask);
> >> +	if (unlikely((p->sched_class == &rt_sched_class ||
> >> +		      p->sched_class == &dl_sched_class) &&
> >> +		      p->nr_cpus_allowed > 1)) {
> >> +		if (p->sched_class == &rt_sched_class)
> >> +			task_rq(p)->rt.rt_nr_migratory++;
> >> +		else
> >> +			task_rq(p)->dl.dl_nr_migratory++;
> >> +	}
> >> +	task_rq_unlock(rq, p, &rf);

or is there some difference I haven't noticed?

Thanks,

	Ingo

  reply	other threads:[~2017-06-22 19:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 19:28 [PATCH 0/2] rt: Increase/decrease the nr of migratory tasks when enabling/disabling migration Daniel Bristot de Oliveira
2017-06-21 19:29 ` [PATCH 1/2] sched/debug: Inform the number of rt/dl task that can migrate Daniel Bristot de Oliveira
2017-06-22  9:29   ` Ingo Molnar
2017-06-22 13:02     ` Daniel Bristot de Oliveira
2017-06-21 19:29 ` [PATCH 2/2] rt: Increase/decrease the nr of migratory tasks when enabling/disabling migration Daniel Bristot de Oliveira
2017-06-22  8:38   ` Ingo Molnar
2017-06-22 13:31     ` Daniel Bristot de Oliveira
2017-06-22 19:49       ` Ingo Molnar [this message]
2017-06-23 13:36         ` Daniel Bristot de Oliveira
2017-06-24  6:41           ` Ingo Molnar
2017-06-26 12:16             ` Daniel Bristot de Oliveira

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=20170622194943.ho4yekdqqeg2qiva@gmail.com \
    --to=mingo@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=bristot@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=williams@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;
as well as URLs for NNTP newsgroup(s).