From: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
To: James Hogan <james.hogan@imgtec.com>
Cc: <yhb@ruijie.com.cn>, <ralf@linux-mips.org>, <linux-mips@linux-mips.org>
Subject: Re: [PATCH] MIPS: We need to clear MMU contexts of all other processes when asid_cache(cpu) wraps to 0.
Date: Mon, 11 Jul 2016 12:39:03 -0700 [thread overview]
Message-ID: <5783F5D7.2090804@imgtec.com> (raw)
In-Reply-To: <20160711192121.GC26799@jhogan-linux.le.imgtec.org>
On 07/11/2016 12:21 PM, James Hogan wrote:
> On Mon, Jul 11, 2016 at 11:19:30AM -0700, Leonid Yegoshin wrote:
>> On 07/11/2016 11:07 AM, James Hogan wrote:
>>>
>> Not exactly. The change must be done only for local CPU which executes
>> at the moment get_new_mmu_context(). Just prevent preemption here and
>> change of cpu_context(THIS_CPU,...) can be done safely - other CPUs
>> don't do anything with this variable besides killing it (writing 0 to it).
> Right, but I was thinking more along the lines of whether you can ensure
> the other tasks / mm continues to exist. I think this is partly achieved
> by the read_lock'ing of tasklist_lock, but also possibly by the
> find_lock_task_mm() call, which has a comment saying:
>
> /*
> * The process p may have detached its own ->mm while exiting or through
> * use_mm(), but one or more of its subthreads may still have a valid
> * pointer. Return p, or any of its subthreads with a valid ->mm, with
> * task_lock() held.
> */
>
> (but of course I could be mistaken and something else guarantees it
> won't go away).
I don't look into details of that but a safe way to do is - walk through
all memory maps and lock it before change.
And to walk through memory maps we could use something like
'find_lock_task_mm' but if there is a concern like you stated above then
we could walk through all subthreads of task or just through all threads
in system - anywhere, this even (ASID wrap) is pretty rare.
The advantage is in keeping all that stuff local and avoid patching
other arch and common code.
>
> Note also that I have a patch I'm about to submit which changes some of
> those assignments of 0 to assign 1 instead (so as not to confuse the
> cache management code into thinking the CPU has never run the code when
> it has, while still triggering ASID regeneration). That applies here
> too, so it should perhaps be doing something like this instead:
>
> if (t->mm != mm && cpu_context(cpu, t->mm))
> cpu_context(cpu, t->mm) = 1;
Not sure, but did you have chance to look into having another variable
for cache flush control? It can be that some more states may be needed
in future, so - just disjoin both, TLB and cache coontrol.
- Leonid.
>
> Cheers
> James
>
>> You can look into flush_tlb_mm() for example how it is cleared for
>> single memory map.
>>
>> We have a macro to safely walk all processes, right? (don't remember
>> it's name).
>>
>>
WARNING: multiple messages have this Message-ID (diff)
From: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
To: James Hogan <james.hogan@imgtec.com>
Cc: yhb@ruijie.com.cn, ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: Re: [PATCH] MIPS: We need to clear MMU contexts of all other processes when asid_cache(cpu) wraps to 0.
Date: Mon, 11 Jul 2016 12:39:03 -0700 [thread overview]
Message-ID: <5783F5D7.2090804@imgtec.com> (raw)
Message-ID: <20160711193903.sMhPpjZngb7twPRydZFXic6V7R_1hb6NoS0ZYnZZ2kE@z> (raw)
In-Reply-To: <20160711192121.GC26799@jhogan-linux.le.imgtec.org>
On 07/11/2016 12:21 PM, James Hogan wrote:
> On Mon, Jul 11, 2016 at 11:19:30AM -0700, Leonid Yegoshin wrote:
>> On 07/11/2016 11:07 AM, James Hogan wrote:
>>>
>> Not exactly. The change must be done only for local CPU which executes
>> at the moment get_new_mmu_context(). Just prevent preemption here and
>> change of cpu_context(THIS_CPU,...) can be done safely - other CPUs
>> don't do anything with this variable besides killing it (writing 0 to it).
> Right, but I was thinking more along the lines of whether you can ensure
> the other tasks / mm continues to exist. I think this is partly achieved
> by the read_lock'ing of tasklist_lock, but also possibly by the
> find_lock_task_mm() call, which has a comment saying:
>
> /*
> * The process p may have detached its own ->mm while exiting or through
> * use_mm(), but one or more of its subthreads may still have a valid
> * pointer. Return p, or any of its subthreads with a valid ->mm, with
> * task_lock() held.
> */
>
> (but of course I could be mistaken and something else guarantees it
> won't go away).
I don't look into details of that but a safe way to do is - walk through
all memory maps and lock it before change.
And to walk through memory maps we could use something like
'find_lock_task_mm' but if there is a concern like you stated above then
we could walk through all subthreads of task or just through all threads
in system - anywhere, this even (ASID wrap) is pretty rare.
The advantage is in keeping all that stuff local and avoid patching
other arch and common code.
>
> Note also that I have a patch I'm about to submit which changes some of
> those assignments of 0 to assign 1 instead (so as not to confuse the
> cache management code into thinking the CPU has never run the code when
> it has, while still triggering ASID regeneration). That applies here
> too, so it should perhaps be doing something like this instead:
>
> if (t->mm != mm && cpu_context(cpu, t->mm))
> cpu_context(cpu, t->mm) = 1;
Not sure, but did you have chance to look into having another variable
for cache flush control? It can be that some more states may be needed
in future, so - just disjoin both, TLB and cache coontrol.
- Leonid.
>
> Cheers
> James
>
>> You can look into flush_tlb_mm() for example how it is cleared for
>> single memory map.
>>
>> We have a macro to safely walk all processes, right? (don't remember
>> it's name).
>>
>>
next prev parent reply other threads:[~2016-07-11 19:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-10 13:04 MIPS: We need to clear MMU contexts of all other processes when asid_cache(cpu) wraps to 0 yhb
2016-07-10 13:04 ` yhb
2016-07-11 9:30 ` James Hogan
2016-07-11 9:30 ` James Hogan
2016-07-11 18:02 ` Leonid Yegoshin
2016-07-11 18:02 ` Leonid Yegoshin
2016-07-11 18:05 ` [PATCH] " Leonid Yegoshin
2016-07-11 18:05 ` Leonid Yegoshin
2016-07-11 18:07 ` James Hogan
2016-07-11 18:07 ` James Hogan
2016-07-11 18:19 ` [PATCH] " Leonid Yegoshin
2016-07-11 18:19 ` Leonid Yegoshin
2016-07-11 19:21 ` James Hogan
2016-07-11 19:21 ` James Hogan
2016-07-11 19:39 ` Leonid Yegoshin [this message]
2016-07-11 19:39 ` Leonid Yegoshin
2016-07-11 20:18 ` James Hogan
2016-07-11 20:18 ` James Hogan
-- strict thread matches above, loose matches on Subject: below --
2016-07-12 3:48 yhb
2016-07-12 3:48 ` yhb
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=5783F5D7.2090804@imgtec.com \
--to=leonid.yegoshin@imgtec.com \
--cc=james.hogan@imgtec.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
--cc=yhb@ruijie.com.cn \
/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