From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Kirill Tkhai <tkhai@yandex.ru>,
Kirill Tkhai <ktkhai@parallels.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Vladimir Davydov <vdavydov@parallels.com>
Subject: Re: [PATCH v3] sched/numa: fix unsafe get_task_struct() in task_numa_assign()
Date: Tue, 21 Oct 2014 21:03:35 +0200 [thread overview]
Message-ID: <20141021190335.GA12851@redhat.com> (raw)
In-Reply-To: <20141021094558.GQ23531@worktop.programming.kicks-ass.net>
On 10/21, Peter Zijlstra wrote:
>
> On Mon, Oct 20, 2014 at 10:50:06PM +0200, Oleg Nesterov wrote:
> > Let me explain what I personally dislike in v3:
> >
> > - I think that we do not have enough reasons for
> > SLAB_DESTROY_BY_RCU. This is the serious change.
>
> What exactly would the downsides be? SDBR has very limited space
> overhead iirc.
Yes, SDBR is nice (and it could probably have more users), but my
concern is not overhead. Please see below.
> > - Again, perhaps we should start we a simple and stupid fix.
> > We can do get_task_struct() under rq->lock or, if nothing
> > else, just
> >
> > raw_spin_lock_irq(&rq->lock);
> > cur = rq->curr;
> > if (is_idle_task(cur) || (cur->flags & PF_EXITING))
> > cur = NULL;
> > raw_spin_unlock_irq(&rq->lock);
>
> I think I agree with you, this is the simple safe option and is
> something we can easily backport. After that we can add creative bits on
> top.
Agreed.
Kirill, could you please make a patch?
> I think I prefer the SLAB_DESTROY_BY_RCU thing over the probe_kernel
> thing
I won't really insist, but let me try to explain why I dislike it in
this particular case.
- It is not clear who else (except task_numa_compare) will need it.
And it looks at bit strange to make task_struct SLAB_DESTROY_BY_RCU
just to read a word in task_numa_compare().
- In some sense, the usage of SDBR looks simply "wrong" in this case.
IOW, I agree that probe_kernel_read() is ugly, but in this case
SDBR acts exactly the same way as probe_kernel_read().
SDBR does not make the object rcu-safe, it only protects the object
type plus ensures that this memory can't go away. It was designed
for the case when you read the stable members initialized in ctor
(usually a lock) and verify/lock the object.
But in this case we can not detect that the object is still alive
without the additional trick, so when you read ->sighand or ->flags,
the fact that this memory is still "struct task_struct" doesn't help
and doesn't matter at all. Only the subsequent "task == rq->curr"
check proves that yes, this is task_struct.
OTOH, (afaics) we only need probe_kernel_read() if CONFIG_DEBUG_SLAB.
And in fact I think that "read the valid but potentially freed kernel
pointer" deserves another helper, it can have more users. For example,
please look at get_freepointer_safe().
What if we add get_kernel(x, ptr) macro to factor out the IS_ENABLED()
of ifdef hack? Or inline function... This way the new xxx() helper we
discussed won't look that bad.
But again, I agree that this subjective, I won't really argue.
Oleg.
next prev parent reply other threads:[~2014-10-21 19:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-20 10:15 Kirill Tkhai
2014-10-20 14:47 ` Oleg Nesterov
2014-10-20 16:56 ` Oleg Nesterov
2014-10-20 18:27 ` Oleg Nesterov
2014-10-20 20:18 ` Kirill Tkhai
2014-10-20 20:50 ` Oleg Nesterov
2014-10-20 21:05 ` Kirill Tkhai
2014-10-20 21:34 ` Oleg Nesterov
2014-10-20 22:57 ` Peter Zijlstra
2014-10-21 9:45 ` Peter Zijlstra
2014-10-21 19:03 ` Oleg Nesterov [this message]
2014-10-21 20:03 ` Kirill Tkhai
2014-10-21 20:10 ` Kirill Tkhai
2014-10-22 9:09 ` Peter Zijlstra
2014-10-22 16:14 ` Oleg Nesterov
2014-10-22 16:37 ` Peter Zijlstra
2014-10-22 18:14 ` introduce probe_slab_address? (Was: sched/numa: fix unsafe get_task_struct() in task_numa_assign()) Oleg Nesterov
2014-10-22 18:59 ` introduce probe_slab_address? David Miller
2014-10-22 19:42 ` Oleg Nesterov
2014-10-22 20:08 ` David Miller
2014-10-22 20:20 ` Oleg Nesterov
2014-10-24 9:44 ` Peter Zijlstra
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=20141021190335.GA12851@redhat.com \
--to=oleg@redhat.com \
--cc=ktkhai@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tkhai@yandex.ru \
--cc=vdavydov@parallels.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
Powered by JetHome