From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "Linux Kernel" <linux-kernel@vger.kernel.org>,
"Richard Guy Briggs" <rgb@redhat.com>,
"Eric Paris" <eparis@redhat.com>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Dave Jones" <davej@redhat.com>,
"Oleg Nesterov" <oleg@redhat.com>,
"Frédéric Weisbecker" <fweisbec@gmail.com>
Subject: Re: [PATCH v2] context_tracking: Restore previous state in schedule_user
Date: Wed, 3 Dec 2014 15:50:02 -0800 [thread overview]
Message-ID: <20141203235002.GW25340@linux.vnet.ibm.com> (raw)
In-Reply-To: <e840280bba54050816470caa870bd9f561efc545.1417649608.git.luto@amacapital.net>
On Wed, Dec 03, 2014 at 03:37:08PM -0800, Andy Lutomirski wrote:
> It appears that some SCHEDULE_USER (asm for schedule_user) callers
> in arch/x86/kernel/entry_64.S are called from RCU kernel context,
> and schedule_user will return in RCU user context. This causes RCU
> warnings and possible failures.
>
> This is intended to be a minimal fix suitable for 3.18.
>
> Reported-and-tested-by: Dave Jones <davej@redhat.com>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Frédéric Weisbecker <fweisbec@gmail.com>
> Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Looks like the RCU entry/exit stuff is properly accounted for, so:
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
>
> Hi all-
>
> This is intended to be a suitable last-minute fix for the RCU issue that
> Dave saw.
>
> Dave, can you confirm that this fixes it?
>
> Frédéric, can you confirm that you think that this will have no effect
> on correct callers of schedule_user and that will do the right thing
> for incorrect callers of schedule_user?
>
> I don't like the x86 asm that calls this at all, and I don't really
> like the fragility of the mechanism is general, but I think that this
> improves the situation enough to avoid problems in the short term.
>
> With the obvious warning added, I get:
>
> [ 0.751022] ------------[ cut here ]------------
> [ 0.751937] WARNING: CPU: 0 PID: 72 at kernel/sched/core.c:2883 schedule_user+0xcf/0xe0()
> [ 0.753477] Modules linked in:
> [ 0.754089] CPU: 0 PID: 72 Comm: mount Not tainted 3.18.0-rc7+ #653
> [ 0.755258] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014
> [ 0.757655] 0000000000000009 ffff880005c13f00 ffffffff81741dca ffff8800069f5a50
> [ 0.759228] 0000000000000000 ffff880005c13f40 ffffffff8108e781 0000000000000246
> [ 0.760758] 0000000000000000 00007fff970441c8 00007fff97043fd0 00007f67794ebcc8
> [ 0.762294] Call Trace:
> [ 0.762775] [<ffffffff81741dca>] dump_stack+0x46/0x58
> [ 0.763739] [<ffffffff8108e781>] warn_slowpath_common+0x81/0xa0
> [ 0.764865] [<ffffffff8108e85a>] warn_slowpath_null+0x1a/0x20
> [ 0.765958] [<ffffffff8174565f>] schedule_user+0xcf/0xe0
> [ 0.766974] [<ffffffff8174ae69>] sysret_careful+0x19/0x1c
> [ 0.768011] ---[ end trace 329f34db2b3be966 ]---
>
> So, yes, we have a bug, and this could cause any number of strange
> problems.
>
> Changes from v1:
> - Added Dave's Tested-by.
> - Fixed a comment typo.
>
> kernel/sched/core.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 24beb9bb4c3e..89e7283015a6 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2874,10 +2874,14 @@ asmlinkage __visible void __sched schedule_user(void)
> * or we have been woken up remotely but the IPI has not yet arrived,
> * we haven't yet exited the RCU idle mode. Do it here manually until
> * we find a better solution.
> + *
> + * NB: There are buggy callers of this function. Ideally we
> + * should warn if prev_state != IN_USER, but that will trigger
> + * too frequently to make sense yet.
> */
> - user_exit();
> + enum ctx_state prev_state = exception_enter();
> schedule();
> - user_enter();
> + exception_exit(prev_state);
> }
> #endif
>
> --
> 1.9.3
>
next prev parent reply other threads:[~2014-12-03 23:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-03 18:19 audit: rcu_read_lock() used illegally while idle Dave Jones
2014-12-03 19:29 ` Paul E. McKenney
2014-12-03 20:06 ` Andy Lutomirski
2014-12-03 20:19 ` Dave Jones
2014-12-03 20:38 ` Andy Lutomirski
2014-12-03 22:08 ` Frederic Weisbecker
2014-12-03 22:12 ` Andy Lutomirski
2014-12-03 23:49 ` Frederic Weisbecker
2014-12-03 23:18 ` [PATCH] context_tracking: Restore previous state in schedule_user Andy Lutomirski
2014-12-03 23:26 ` Andy Lutomirski
2014-12-03 23:31 ` Dave Jones
2014-12-03 23:58 ` Frederic Weisbecker
2014-12-04 0:04 ` Andy Lutomirski
2014-12-04 0:30 ` Dave Jones
2014-12-04 0:38 ` Andy Lutomirski
2014-12-04 1:13 ` Frederic Weisbecker
2014-12-03 23:37 ` [PATCH v2] " Andy Lutomirski
2014-12-03 23:50 ` Paul E. McKenney [this message]
2014-12-04 0:01 ` Frederic Weisbecker
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=20141203235002.GW25340@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=davej@redhat.com \
--cc=eparis@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=oleg@redhat.com \
--cc=rgb@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox