From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Sasha Levin <sasha.levin@oracle.com>,
Ingo Molnar <mingo@kernel.org>, Peter Anvin <hpa@zytor.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Andy Lutomirski <luto@amacapital.net>,
Denys Vlasenko <dvlasenk@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Chuck Ebbert <cebbert.lkml@gmail.com>
Subject: [PATCH 0/1] stop the unbound recursion in preempt_schedule_context()
Date: Sun, 5 Oct 2014 22:23:00 +0200 [thread overview]
Message-ID: <20141005202300.GA27962@redhat.com> (raw)
In-Reply-To: <20141004003300.GA6297@redhat.com>
On 10/04, Oleg Nesterov wrote:
>
> On 10/03, Linus Torvalds wrote:
> >
> > On Fri, Oct 3, 2014 at 5:01 PM, Linus Torvalds
> > <torvalds@linux-foundation.org> wrote:
> > >
> > > The real fix would appear to be to use
> > > "preempt_enable_no_resched_notrace()", which your patch did, but
> > > without the loop.
> >
> > Actually, the real fix would be to not be stupid, and just make the
> > code do something like
> >
> > > if (likely(!preemptible()))
> > > return;
> > >
> > > __preempt_count_add(PREEMPT_ACTIVE);
> > > prev_ctx = exception_enter();
> > >
> > > __schedule();
> > >
> > > exception_exit(prev_ctx);
> > > __preempt_count_sub(PREEMPT_ACTIVE);
> >
> > and *not* enable preemption around the scheduling at all.
Yes, I think you are right. And I hate to admit that I didn't think about
this simplification. The only complication is that we should move this
function from context_tracking.c to sched/core.c.
However, I still think we need the need_resched() loop, we can't do this
only once.
And in fact the simplest fix could just turn it into
local_irq_disable();
preempt_schedule_irq();
local_irq_enable();
> Again, it is too late for me... Most probably I am wrong, but somehow
> it seems to me that the real fix should try to kill preempt_schedule_context()
> altogether and teach preempt_schedule() to play well with CONTEXT_TRACKING.
Yes, the very fact that
preempt_enable() != trace_preempt_on() + preempt_enable_notrace()
looks simply wrong imo. And preempt_enable_notrace() has users outside of
the tracing code which can run in IN_USER state. For example, why should
__perf_sw_event() worry about context_tracking.state?
OTOH, if the caller of preempt_enable_notrace() actually needs to take care
of potential IN_USER state, then it probably has other problems. And indeed,
ftrace_ops_control_func() has to check rcu_is_watching() anyway.
IOW, imho 29bb9e5a75 "tracing/context-tracking: Add preempt_schedule_context()
for tracing" was not a right solution. Perhaps the tracing functions can be
changed to switch to IN_KERNEL mode, or at least perhaps we can add the
special preempt_disable_ftrace() helper. But this needs another discussion.
Either way, I do think that preempt_schedule_context() in its current form
must die.
Oleg.
next prev parent reply other threads:[~2014-10-05 20:26 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-21 18:41 [PATCH v3 0/2] x86: reimplement ___preempt_schedule*() using THUNK helpers Oleg Nesterov
2014-09-21 18:41 ` [PATCH v3 1/2] " Oleg Nesterov
2014-09-24 15:02 ` [tip:x86/asm] x86: Speed up ___preempt_schedule*() by " tip-bot for Oleg Nesterov
2014-10-03 4:50 ` Sasha Levin
2014-10-03 13:39 ` Chuck Ebbert
2014-10-03 21:41 ` Oleg Nesterov
2014-10-03 21:56 ` Andy Lutomirski
2014-10-03 23:48 ` Linus Torvalds
2014-10-03 23:51 ` Oleg Nesterov
2014-10-03 22:48 ` Chuck Ebbert
2014-10-03 22:53 ` Andy Lutomirski
2014-10-03 23:13 ` H. Peter Anvin
2014-10-03 23:37 ` Oleg Nesterov
2014-10-03 21:16 ` Oleg Nesterov
2014-10-03 23:26 ` Oleg Nesterov
2014-10-04 0:01 ` Linus Torvalds
2014-10-04 0:11 ` Linus Torvalds
2014-10-04 0:33 ` Oleg Nesterov
2014-10-05 20:23 ` Oleg Nesterov [this message]
2014-10-05 20:23 ` [PATCH 1/1] stop the unbound recursion in preempt_schedule_context() Oleg Nesterov
2014-10-28 11:03 ` [tip:sched/core] sched: " tip-bot for Oleg Nesterov
2014-10-05 23:53 ` [PATCH 0/1] " Oleg Nesterov
2014-10-04 0:19 ` [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers Oleg Nesterov
2014-09-21 18:42 ` [PATCH v3 2/2] x86, lib/Makefile: remove the unnecessary "+= thunk_64.o" Oleg Nesterov
2014-09-24 15:02 ` [tip:x86/asm] x86/lib/Makefile: Remove " tip-bot for Oleg Nesterov
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=20141005202300.GA27962@redhat.com \
--to=oleg@redhat.com \
--cc=cebbert.lkml@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sasha.levin@oracle.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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.