Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1163585 > unrolled thread
| Started by | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| First post | 2015-06-11 22:40 +0200 |
| Last post | 2015-06-13 20:10 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Date | 2015-06-11 22:40 +0200 |
| Subject | Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code |
| Message-ID | <pAhqx-8v7-1@gated-at.bofh.it> |
On Thu, Jun 11, 2015 at 7:07 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> But we want to remove the pgd_list, so convert the code over to walk
> all tasks in the system. This is an equivalent method.
This is not at all equivalent, and it looks stupid.
Don't use "for_each_process_thread(g, p)". You only care about each
mm, and threads all share the same mm, so just do
for_each_process(p)
instead of iterating over all threads too.
No?
Linus
--
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/
[toc] | [next] | [standalone]
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Date | 2015-06-11 22:50 +0200 |
| Message-ID | <pAhAf-fl-53@gated-at.bofh.it> |
| In reply to | #1163585 |
On Thu, Jun 11, 2015 at 1:37 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> Don't use "for_each_process_thread(g, p)". You only care about each
> mm, and threads all share the same mm, so just do
>
> for_each_process(p)
>
> instead of iterating over all threads too.
Hmm. I may be wrong. It strikes me that one of the group leaders might
have exited but the subthreads live on. We'd see p->mm being NULL,
even though the mm was originally in use.
Ugh. So maybe the code really does need to iterate over all threads.
Linus
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Date | 2015-06-13 01:40 +0200 |
| Subject | Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code |
| Message-ID | <pAGIi-3SR-1@gated-at.bofh.it> |
| In reply to | #1163606 |
On 06/12, Boris Ostrovsky wrote:
>
> On 06/12/2015 04:53 PM, Oleg Nesterov wrote:
>>>
>>> for_each_process(p) {
>>>
>>> for_each_thread(p, t) {
>>> if (t->mm) {
>>> do_something(t->mm);
>>> break;
>>> }
>>> }
>>> }
>>>
>>> But either way I don't understand what protects this ->mm. Perhaps this needs
>>> find_lock_task_mm().
>>
>> And, I don't understand this code, probably this doesn't matter, but.
>>
>> unpin_all() is probably fine, but xen_mm_pin_all() can race with fork()
>> and miss the new child. Is it OK?
>
>
> Currently xen_mm_pin_all() is only called in the suspend path, out of
> stop_machine(), so presumably at that time fork is not possible.
OK, thanks, this also means that this code shouldn't worry about ->mm,
it should be stable.
But for_each_process() in sync_global_pgds() should, afaics.
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/
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2015-06-13 09:30 +0200 |
| Subject | Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code |
| Message-ID | <pAO37-611-1@gated-at.bofh.it> |
| In reply to | #1163606 |
* 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?
> if (t->mm) {
> do_something(t->mm);
> break;
> }
> }
> }
>
> 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.
find_lock_task_mm() is not needed IMHO: we have a stable reference to 't', as a
task can only go away via RCU expiry, and all the iterations I added are (supposed
to) be RCU safe.
Thanks,
Ingo
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Date | 2015-06-13 20:10 +0200 |
| Subject | Re: [PATCH 07/12] x86/virt/guest/xen: Remove use of pgd_list from the Xen guest code |
| Message-ID | <pAY2u-3N9-7@gated-at.bofh.it> |
| In reply to | #1164582 |
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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web