The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2] sched: Have do_idle() call __schedule() without enabling preemption
Date: Thu, 13 Apr 2017 09:48:40 -0400	[thread overview]
Message-ID: <20170413094840.347b9829@gandalf.local.home> (raw)
In-Reply-To: <20170413084453.ad4falb7kc53viri@hirez.programming.kicks-ass.net>

On Thu, 13 Apr 2017 10:44:53 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> On Wed, Apr 12, 2017 at 02:27:44PM -0400, Steven Rostedt wrote:
> > + * schedule_idle() is similar to schedule_preempt_disable() except
> > + * that it never enables preemption.  
> 
> That's not right. The primary distinction is that it doesn't call
> sched_submit_work().

That has nothing to do with fixing synchronize_rcu_tasks(), which is
the entire point of my patch, thus it is *not* the primary distinction.
Keeping schedule from enabling preemption and calling functions is the
bug fix. Not calling sched_submit_work() is just an added optimization
benefit.

The point of the patch is to stop idle from enabling preemption,
because it doesn't need to, as sched_submit_work() is a nop for it.
I'll update my change log to mention that.

> 
> And because that function is a no-op for the idle thread, the idle
> thread can do without calling that and therefore avoid the preemption
> window.
> 
> You also need a few words about fake idle threads, search play_idle()
> callers.

Thanks, this is the first I heard of these. I'll go look at them.

> 
> You could also make schedule_idle() more robust by adding a WARN for the
> blk_schedule_flush_plug() condition.

Why? The call to schedule_preempt_disabled() never got that far when
coming from do_idle().

static inline void sched_submit_work(struct task_struct *tsk)
{
	if (!tsk->state || tsk_is_pi_blocked(tsk))
		return;
	/*
	 * If we are going to sleep and we have plugged IO queued,
	 * make sure to submit it to avoid deadlocks.
	 */
	if (blk_needs_flush_plug(tsk))
		blk_schedule_flush_plug(tsk);
}

Isn't tsk->state always zero for the idle task?

A better case would be WARN_ON(tsk->state)


> 
> 
> You Changelog is still entirely long and rambling but fails to mention
> the fundamental important stuff :-(


Remember, this patch is to fix a bug and not to optimize idle, although
that is an added benefit. The bug I am fixing, which is in linux-next
now, is that the idle thread breaks synchronize_rcu_tasks() when
calling schedule() with preemption enabled. That's what my ramblings in
the change log are talking about.

-- Steve

  reply	other threads:[~2017-04-13 13:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12 18:27 [PATCH v2] sched: Have do_idle() call __schedule() without enabling preemption Steven Rostedt
2017-04-12 18:32 ` Steven Rostedt
2017-04-12 23:48 ` Paul E. McKenney
2017-04-13  0:40   ` Steven Rostedt
2017-04-13  0:50     ` Paul E. McKenney
2017-04-13  8:44 ` Peter Zijlstra
2017-04-13 13:48   ` Steven Rostedt [this message]
2017-04-13 14:38     ` Peter Zijlstra
2017-04-13 14:54       ` Steven Rostedt

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=20170413094840.347b9829@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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