Skip to contentSkip to conversation

nios2: update_mmu_cache clear the old entry from the TLB

RFC PATCH Nicholas Piggin 2 participants 8 messages Sep 29, 2018 – Oct 8, 2018 2 messages not in the archive Memory management

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi,

Did you get a chance to look at these?

This first patch 1/11 solves the lockup problem that Guenter reported with my changes to core mm code. So I plan to resubmit my patches to Andrew's -mm tree with this patch to avoid nios2 breakage.

Thanks,
Nick

Quoted 40 lines · On Mon, 24 Sep 2018 01:08:20 +1000 Nicholas Piggin <[email protected]> wrote:

Fault paths like do_read_fault will install a Linux pte with the young bit clear. The CPU will fault again because the TLB has not been updated, this time a valid pte exists so handle_pte_fault will just set the young bit with ptep_set_access_flags, which flushes the TLB.

The TLB is flushed so the next attempt will go to the fast TLB handler which loads the TLB with the new Linux pte. The access then proceeds.

This design is fragile to depend on the young bit being clear after the initial Linux fault. A proposed core mm change to immediately set the young bit upon such a fault, results in ptep_set_access_flags not flushing the TLB because it finds no change to the pte. The spurious fault fix path only flushes the TLB if the access was a store. If it was a load, then this results in an infinite loop of page faults.

This change adds a TLB flush in update_mmu_cache, which removes that TLB entry upon the first fault. This will cause the fast TLB handler to load the new pte and avoid the Linux page fault entirely.

---
 arch/nios2/mm/cacheflush.c | 2 ++
 1 file changed, 2 insertions(+)
arch/nios2/mm/cacheflush.c +2 -0
index 506f6e1c86d5..d58e7e80dc0d 100644
@@ -204,6 +204,8 @@ void update_mmu_cache(struct vm_area_struct *vma,
 	struct page *page;
 	struct address_space *mapping;
 
+	flush_tlb_page(vma, address);
+
 	if (!pfn_valid(pfn))
 		return;
 
Signature · 1 line
2.18.0
#3 lore raw
Quoted 10 lines · Nicholas Piggin

Hi,

Did you get a chance to look at these?

This first patch 1/11 solves the lockup problem that Guenter reported with my changes to core mm code. So I plan to resubmit my patches to Andrew's -mm tree with this patch to avoid nios2 breakage.

Thanks,
Nick

Do you have git repo that contains these patches? If not, can you send them as attachment to my email?

Regards
Ley Foon

Quoted 54 lines
Quoted 50 lines · On Mon, 24 Sep 2018 01:08:20 +1000 Nicholas Piggin <[email protected]> wrote:

Fault paths like do_read_fault will install a Linux pte with the young
bit clear. The CPU will fault again because the TLB has not been updated, this time a valid pte exists so handle_pte_fault will just set the young bit with ptep_set_access_flags, which flushes the TLB.

The TLB is flushed so the next attempt will go to the fast TLB handler
which loads the TLB with the new Linux pte. The access then proceeds.

This design is fragile to depend on the young bit being clear after the initial Linux fault. A proposed core mm change to immediately set
the young bit upon such a fault, results in ptep_set_access_flags not
flushing the TLB because it finds no change to the pte. The spurious
fault fix path only flushes the TLB if the access was a store. If it
was a load, then this results in an infinite loop of page faults.

This change adds a TLB flush in update_mmu_cache, which removes that
TLB entry upon the first fault. This will cause the fast TLB handler
to load the new pte and avoid the Linux page fault entirely.

---
 arch/nios2/mm/cacheflush.c | 2 ++

 1 file changed, 2 insertions(+)
arch/nios2/mm/cacheflush.c +0 -0
index 506f6e1c86d5..d58e7e80dc0d 100644
@@ -204,6 +204,8 @@ void update_mmu_cache(struct vm_area_struct
 *vma,
  	struct page *page;
  	struct address_space *mapping;

arch/nios2/mm/cacheflush.c +2 -0
+	flush_tlb_page(vma, address);
+

  if (!pfn_valid(pfn))
  return;

#4 lore raw
Quoted 9 lines · On Mon, 01 Oct 2018 23:24:23 +0800 Ley Foon Tan <[email protected]> wrote:
Quoted 8 lines · Nicholas Piggin

Hi,

Did you get a chance to look at these?

This first patch 1/11 solves the lockup problem that Guenter reported with my changes to core mm code. So I plan to resubmit my patches to Andrew's -mm tree with this patch to avoid nios2 breakage.

Quoted 5 lines
Quoted 2 lines

Thanks,
Nick

Do you have git repo that contains these patches? If not, can you send them as attachment to my email?

I can do that, but it would be good to work with inline patches because that's the usual method (rather than attached patches).

You should be able to just download or save your email and patch it, export to mbox and git am it, etc. So they should be quite easy to work with.

Thanks,
Nick

#5 lore raw
In reply to Ley Foon Tan
Quoted 9 lines · On Mon, 01 Oct 2018 23:24:23 +0800 Ley Foon Tan <[email protected]> wrote:
Quoted 8 lines · Nicholas Piggin

Hi,

Did you get a chance to look at these?

This first patch 1/11 solves the lockup problem that Guenter reported with my changes to core mm code. So I plan to resubmit my patches to Andrew's -mm tree with this patch to avoid nios2 breakage.

Quoted 5 lines
Quoted 2 lines

Thanks,
Nick

Do you have git repo that contains these patches? If not, can you send them as attachment to my email?

Here's a tree with these patches plus 3 of the core mm code changes which caused nios2 to hang

https://github.com/npiggin/linux/commits/nios2

Thanks,
Nick

#6 lore raw
Quoted 17 lines · Nicholas Piggin
Quoted 14 lines · On Mon, 01 Oct 2018 23:24:23 +0800 Ley Foon Tan <[email protected]> wrote:
Quoted 12 lines · Nicholas Piggin

Hi,

Did you get a chance to look at these?

This first patch 1/11 solves the lockup problem that Guenter reported
with my changes to core mm code. So I plan to resubmit my patches to Andrew's -mm tree with this patch to avoid nios2 breakage.

Thanks,
Nick

Quoted 8 lines
Quoted 3 lines

Do you have git repo that contains these patches? If not, can you send
them as attachment to my email?

Here's a tree with these patches plus 3 of the core mm code changes which caused nios2 to hang

https://github.com/npiggin/linux/commits/nios2

Hi Nick

Tested your patches on the github branch. Kernel bootup and ethernet ping are working.

Regards
Ley Foon

#7 lore raw
Quoted 24 lines · On Fri, 05 Oct 2018 09:52:56 +0800 Ley Foon Tan <[email protected]> wrote:
Quoted 23 lines · Nicholas Piggin
Quoted 12 lines · On Mon, 01 Oct 2018 23:24:23 +0800 Ley Foon Tan <[email protected]> wrote:
Quoted 10 lines · Nicholas Piggin

Hi,

Did you get a chance to look at these?

This first patch 1/11 solves the lockup problem that Guenter reported
with my changes to core mm code. So I plan to resubmit my patches to Andrew's -mm tree with this patch to avoid nios2 breakage.

Quoted 5 lines
Quoted 2 lines

Thanks,
Nick

Do you have git repo that contains these patches? If not, can you send
them as attachment to my email?

Here's a tree with these patches plus 3 of the core mm code changes which caused nios2 to hang

Quoted 6 lines
Quoted 2 lines

https://github.com/npiggin/linux/commits/nios2

Hi Nick

Tested your patches on the github branch. Kernel bootup and ethernet ping are working.

Hi Ley,

Thank you for testing. I would like to send patch 1 together with my generic TLB optimisation patches to Andrew. Can I get a Reviewed-by or ack from you on that?

As to the other nios2 patches, I will leave them to you to merge them if you want them.

Thanks,
Nick

Reviewed-by
#8 lore raw
Quoted 38 lines · Nicholas Piggin
Quoted 35 lines · On Fri, 05 Oct 2018 09:52:56 +0800 Ley Foon Tan <[email protected]> wrote:
Quoted 25 lines · Nicholas Piggin

On Mon, 01 Oct 2018 23:24:23 +0800
Ley Foon Tan <[email protected]> wrote:

Quoted 15 lines · Nicholas Piggin
Quoted 12 lines

Hi,

Did you get a chance to look at these?

This first patch 1/11 solves the lockup problem that Guenter reported
with my changes to core mm code. So I plan to resubmit my patches
to Andrew's -mm tree with this patch to avoid nios2 breakage.

Quoted 6 lines
Quoted 2 lines

Thanks,
Nick

Do you have git repo that contains these patches? If not, can you
send
them as attachment to my email?

Quoted 6 lines

Here's a tree with these patches plus 3 of the core mm code changes
which caused nios2 to hang

https://github.com/npiggin/linux/commits/nios2

Hi Nick

Quoted 8 lines
Quoted 3 lines

Tested your patches on the github branch. Kernel bootup and ethernet
ping are working.

Hi Ley,

Thank you for testing. I would like to send patch 1 together with my generic TLB optimisation patches to Andrew. Can I get a Reviewed-by or ack from you on that?

For that series,

Quoted 3 lines

As to the other nios2 patches, I will leave them to you to merge them if you want them.

I can merge these nios2 patches. BTW, any dependency between these nios2 patches with the generic TLB optimisation patches? e.g: patch applying sequence.

Regards
Ley Foon

#9 lore raw
Quoted 42 lines · On Tue, 09 Oct 2018 01:02:18 +0800 Ley Foon Tan <[email protected]> wrote:
Quoted 41 lines · Nicholas Piggin
Quoted 38 lines · On Fri, 05 Oct 2018 09:52:56 +0800 Ley Foon Tan <[email protected]> wrote:
Quoted 25 lines · Nicholas Piggin

On Mon, 01 Oct 2018 23:24:23 +0800
Ley Foon Tan <[email protected]> wrote:

Quoted 15 lines · Nicholas Piggin
Quoted 12 lines

Hi,

Did you get a chance to look at these?

This first patch 1/11 solves the lockup problem that Guenter reported
with my changes to core mm code. So I plan to resubmit my patches
to Andrew's -mm tree with this patch to avoid nios2 breakage.

Quoted 6 lines
Quoted 2 lines

Thanks,
Nick

Do you have git repo that contains these patches? If not, can you
send
them as attachment to my email?

Quoted 6 lines

Here's a tree with these patches plus 3 of the core mm code changes
which caused nios2 to hang

https://github.com/npiggin/linux/commits/nios2

Hi Nick

Tested your patches on the github branch. Kernel bootup and ethernet
ping are working.

Quoted 7 lines
Quoted 5 lines

Hi Ley,

Thank you for testing. I would like to send patch 1 together with my generic TLB optimisation patches to Andrew. Can I get a Reviewed-by or ack from you on that?

For that series,

Thank you, I will use it for patch 1 if necessary

Quoted 7 lines
Quoted 4 lines

As to the other nios2 patches, I will leave them to you to merge them if you want them.

I can merge these nios2 patches. BTW, any dependency between these nios2 patches with the generic TLB optimisation patches? e.g: patch applying sequence.

That would be good. The only dependency is that the generic TLB patches depend on nios2 patch 1, so you should be able to take them and merge them now. I will have to take care of the patch 1 dependency when submitting the generic TLB patches.

Thanks,
Nick

Quoted 5 lines

Regards
Ley Foon