From: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
To: Paul Burton <paul.burton@imgtec.com>
Cc: <linux-mips@linux-mips.org>, Lars Persson <lars.persson@axis.com>,
"stable # v4 . 1+" <stable@vger.kernel.org>,
"Steven J. Hill" <Steven.Hill@imgtec.com>,
David Daney <david.daney@cavium.com>,
Huacai Chen <chenhc@lemote.com>,
Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>,
<linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Jerome Marchand <jmarchan@redhat.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [4/4] MIPS: Sync icache & dcache in set_pte_at
Date: Fri, 4 Mar 2016 13:01:02 -0800 [thread overview]
Message-ID: <56D9F78E.6090303@imgtec.com> (raw)
In-Reply-To: <20160304103714.GA5576@NP-P-BURTON>
Paul,
On 03/04/2016 02:37 AM, Paul Burton wrote:
> The problem is that there are other code paths which dirty pages (ie.
> call flush_dcache_page), then get as far as set_pte_at *without* calling
> flush_icache_page.
There is no problem with lazy flush of D-cache and PTE update. D-cache
works in PHYSICAL ADDRESSes and is independent from that is set in PTE
and TLB. You can even don't flush D-cache during page-fault, keep stuff
in D-cache and switch any PTE/TLB in any CPU - anything is coherent...
if we forget for a moment about cache aliasing, non-coherent I-cache and
DMA.
Cache aliasing is not compatible with SMP (until some public inter-L1
protocol is changed to accommodate virtual address).
I-cache incoherency is taken into account in flush_icache_page(),
including a completion of lazy D-cache flush at that point.
DMA ... well it is a complicated issue now but a simplest rule -
complete all flush before/after DMA and it is done in
dma_cache_wback_inv/dma_cache_inv (but I intentionally put out of issue
the speculative access which complicates an issue).
So, you fight a wrong enemy.
> Again - I included call traces from 2 paths that hit
> this right in the commit message.
>
> So:
>
> - flush_icache_page isn't always called before we *need* to writeback
> the page from the dcache. This is demonstrably the case (again, see
> the commit message), and causes bugs when using UBIFS on boards
> using the pistachio SoC at least.
You didn't prove that it is because of your model. You referenced to
flush_icache_page absence in different places but that places don't
prepare a code page:
- forking process actually doesn't copy any page but set it
temporary non-writable, actual copy is done in page fault
- load_elf_binary doesn't load any code pages and again leaves that
process to page fault.
>
> - flush_icache_page is indicated as something that should go away in
> Documentation/cachetlb.txt. Why do you feel we should make use of
> it?
I think it is a wrong mark in doc.
I suspect that your problem with UBIFS is because any DMA-ed code page
should be flushed from DCache during page fault in flush_icache_page.
Current master branch code does it only if it is "dirty" but I suspect
that UBIFS may not do it in some place (doesn't mark it as
"dirty-by-kernel"). Besides that non-DMA-ed pages can be written by
device driver which has no access to that bit. For this reason in my
3.10 branch there is a kernel boot parameter option "mips_non_DMA_FS"
which enforces D-cache flush regardless it is dirty or not.
I again call you to look into
https://git.linux-mips.org/cgit/yegoshin/mips.git, branch
android-linux-mti-3.10 to understand that stuff.
- Leonid.
WARNING: multiple messages have this Message-ID (diff)
From: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
To: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org, Lars Persson <lars.persson@axis.com>,
"stable # v4 . 1+" <stable@vger.kernel.org>,
"Steven J. Hill" <Steven.Hill@imgtec.com>,
David Daney <david.daney@cavium.com>,
Huacai Chen <chenhc@lemote.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Jerome Marchand <jmarchan@redhat.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [4/4] MIPS: Sync icache & dcache in set_pte_at
Date: Fri, 4 Mar 2016 13:01:02 -0800 [thread overview]
Message-ID: <56D9F78E.6090303@imgtec.com> (raw)
Message-ID: <20160304210102.NKjdy2YNdggITeL4noioTWC9XDAUzFqjosUmAIfaRjc@z> (raw)
In-Reply-To: <20160304103714.GA5576@NP-P-BURTON>
Paul,
On 03/04/2016 02:37 AM, Paul Burton wrote:
> The problem is that there are other code paths which dirty pages (ie.
> call flush_dcache_page), then get as far as set_pte_at *without* calling
> flush_icache_page.
There is no problem with lazy flush of D-cache and PTE update. D-cache
works in PHYSICAL ADDRESSes and is independent from that is set in PTE
and TLB. You can even don't flush D-cache during page-fault, keep stuff
in D-cache and switch any PTE/TLB in any CPU - anything is coherent...
if we forget for a moment about cache aliasing, non-coherent I-cache and
DMA.
Cache aliasing is not compatible with SMP (until some public inter-L1
protocol is changed to accommodate virtual address).
I-cache incoherency is taken into account in flush_icache_page(),
including a completion of lazy D-cache flush at that point.
DMA ... well it is a complicated issue now but a simplest rule -
complete all flush before/after DMA and it is done in
dma_cache_wback_inv/dma_cache_inv (but I intentionally put out of issue
the speculative access which complicates an issue).
So, you fight a wrong enemy.
> Again - I included call traces from 2 paths that hit
> this right in the commit message.
>
> So:
>
> - flush_icache_page isn't always called before we *need* to writeback
> the page from the dcache. This is demonstrably the case (again, see
> the commit message), and causes bugs when using UBIFS on boards
> using the pistachio SoC at least.
You didn't prove that it is because of your model. You referenced to
flush_icache_page absence in different places but that places don't
prepare a code page:
- forking process actually doesn't copy any page but set it
temporary non-writable, actual copy is done in page fault
- load_elf_binary doesn't load any code pages and again leaves that
process to page fault.
>
> - flush_icache_page is indicated as something that should go away in
> Documentation/cachetlb.txt. Why do you feel we should make use of
> it?
I think it is a wrong mark in doc.
I suspect that your problem with UBIFS is because any DMA-ed code page
should be flushed from DCache during page fault in flush_icache_page.
Current master branch code does it only if it is "dirty" but I suspect
that UBIFS may not do it in some place (doesn't mark it as
"dirty-by-kernel"). Besides that non-DMA-ed pages can be written by
device driver which has no access to that bit. For this reason in my
3.10 branch there is a kernel boot parameter option "mips_non_DMA_FS"
which enforces D-cache flush regardless it is dirty or not.
I again call you to look into
https://git.linux-mips.org/cgit/yegoshin/mips.git, branch
android-linux-mti-3.10 to understand that stuff.
- Leonid.
next prev parent reply other threads:[~2016-03-04 21:01 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 2:37 [PATCH 0/4] MIPS cache & highmem fixes Paul Burton
2016-03-01 2:37 ` Paul Burton
2016-03-01 2:37 ` [PATCH 1/4] MIPS: Flush dcache for flush_kernel_dcache_page Paul Burton
2016-03-01 2:37 ` Paul Burton
2016-03-04 15:09 ` Lars Persson
2016-03-29 8:29 ` Ralf Baechle
2016-03-01 2:37 ` [PATCH 2/4] MIPS: Flush highmem pages in __flush_dcache_page Paul Burton
2016-03-01 2:37 ` Paul Burton
2016-03-29 8:35 ` Ralf Baechle
2016-03-29 8:55 ` Paul Burton
2016-03-29 8:55 ` Paul Burton
2016-03-01 2:37 ` [PATCH 3/4] MIPS: Handle highmem pages in __update_cache Paul Burton
2016-03-01 2:37 ` Paul Burton
2016-03-29 8:39 ` Ralf Baechle
2016-03-01 2:37 ` [PATCH 4/4] MIPS: Sync icache & dcache in set_pte_at Paul Burton
2016-03-01 2:37 ` Paul Burton
2016-03-01 9:44 ` Lars Persson
2016-03-01 9:44 ` Lars Persson
2016-03-01 17:13 ` David Daney
2016-03-01 17:13 ` David Daney
2016-03-01 17:19 ` Paul Burton
2016-03-01 17:19 ` Paul Burton
2016-03-02 14:12 ` Ralf Baechle
2016-03-02 14:24 ` Paul Burton
2016-03-02 14:24 ` Paul Burton
2016-03-04 17:43 ` David Daney
2016-03-04 17:43 ` David Daney
2016-03-04 17:47 ` Paul Burton
2016-03-04 17:47 ` Paul Burton
2016-03-03 3:03 ` [4/4] " Leonid Yegoshin
2016-03-03 3:03 ` Leonid Yegoshin
2016-03-04 10:37 ` Paul Burton
2016-03-04 10:37 ` Paul Burton
2016-03-04 15:20 ` Lars Persson
2016-03-04 21:01 ` Leonid Yegoshin [this message]
2016-03-04 21:01 ` Leonid Yegoshin
2016-03-04 21:21 ` Leonid Yegoshin
2016-03-04 21:21 ` Leonid Yegoshin
2016-03-05 1:06 ` Leonid Yegoshin
2016-03-05 1:06 ` Leonid Yegoshin
2016-03-04 19:02 ` [PATCH 4/4] " Lars Persson
2016-03-05 0:21 ` Paul Burton
2016-03-05 0:27 ` Paul Burton
2016-03-02 11:39 ` [PATCH 0/4] MIPS cache & highmem fixes Harvey Hunt
2016-03-02 11:39 ` Harvey Hunt
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=56D9F78E.6090303@imgtec.com \
--to=leonid.yegoshin@imgtec.com \
--cc=Steven.Hill@imgtec.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=chenhc@lemote.com \
--cc=david.daney@cavium.com \
--cc=jmarchan@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=lars.persson@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=paul.burton@imgtec.com \
--cc=ralf@linux-mips.org \
--cc=stable@vger.kernel.org \
/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