Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1164667
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code |
| Date | 2015-06-13 20:10 +0200 |
| Message-ID | <pAY2u-3N9-7@gated-at.bofh.it> (permalink) |
| References | (4 earlier) <pArzA-6WB-17@gated-at.bofh.it> <pAsci-7Wu-27@gated-at.bofh.it> <pAsci-7Wu-25@gated-at.bofh.it> <pADU5-87c-9@gated-at.bofh.it> <pAO37-611-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 06/13, Ingo Molnar wrote:
>
> * Oleg Nesterov <oleg@redhat.com> wrote:
>
> > > So we could add tsk->mm_leader or so,
> >
> > No, no, please do not. Just do something like
> >
> > for_each_process(p) {
> >
> > for_each_thread(p, t) {
>
> So far that's what the for_each_process_thread() iterations I added do, right?
Not really,
> > if (t->mm) {
> > do_something(t->mm);
> > break;
^^^^^
Note this "break". We stop the inner loop right after we find a thread "t"
with ->mm != NULL. In the likely case t == p (group leader) so the inner
loop stops on the 1st iteration.
> > But either way I don't understand what protects this ->mm. Perhaps this needs
> > find_lock_task_mm().
>
> That's indeed a bug: I'll add task_lock()/unlock() before looking at ->mm.
Well, in this particular case we are safe. As Boris explained this is called
from stop_machine(). But sync_global_pgds() is not safe.
> find_lock_task_mm() is not needed IMHO: we have a stable reference to 't', as
> task can only go away via RCU expiry, and all the iterations I added are (supposed
> to) be RCU safe.
Sure, you can do lock/unlock by hand. But find_lock_task_mm() can simplify
the code because it checks subthreads if group_leader->mm == NULL. You can
simply do
rcu_read_lock();
for_each_process(p) {
t = find_lock_task_mm(p);
if (!t)
continue;
do_something(t->mm);
task_unlock(t);
}
rcu_read_unlock();
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code Linus Torvalds <torvalds@linux-foundation.org> - 2015-06-11 22:40 +0200
Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code Linus Torvalds <torvalds@linux-foundation.org> - 2015-06-11 22:50 +0200
Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code Oleg Nesterov <oleg@redhat.com> - 2015-06-13 01:40 +0200
Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code Ingo Molnar <mingo@kernel.org> - 2015-06-13 09:30 +0200
Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code Oleg Nesterov <oleg@redhat.com> - 2015-06-13 20:10 +0200
csiph-web