linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: benh@kernel.crashing.org (Benjamin Herrenschmidt)
To: linux-arm-kernel@lists.infradead.org
Subject: USB mass storage and ARM cache coherency
Date: Fri, 05 Mar 2010 08:25:01 +1100	[thread overview]
Message-ID: <1267737901.22204.67.camel@pasglop> (raw)
In-Reply-To: <1267691180.31654.93.camel@mulgrave.site>


> > Still, you do need to flush I when a page cache page is recycled.
> 
> Technically not if we've got all the I flushing when mapped executable
> sorted out.  This is one of the dangers of over flushing ... if we start
> flushing where we don't need it "just to be sure" we end up papering
> over holes in the operating system and make catching actual bugs in
> operations a lot harder.

Well, ok so we are talking past each other here :-) So let me try to
summarize what we do, and then write up what I'd like to be able to do
but can't quite see how to get there just yet.

On PPC, we keep track of whether a page is "cache clean" with PG_arch1. 

We only bother with flushing it when mapping it and yes, it's an
expensive operation.

We do it from within set_pte_at() and/or ptep_set_access_flags(), at
which point w test PG_arch_1, and if clear, do the flush and set it.

On systems that support per-page exec permission, we optimize things a
bit, in that unless this is an exec fault, we "skip" the flush when
mapping the page and filter out the exec permission (so that's a read
access for example). We later do the flush when exec is attempted.

On systems that don't (earlier 32-bit powerpc), we -have- to flush any
mapped page sadly as one could be mapped for read and actually executed
from. This is -not- a case of "let userspace shoot themselves in the
foot", letting stale icache leak through to userspace here is actually a
security hole in theory (granted, unlikely but we got barked at enough
when we tried to optimize that out).

Now, when we do the flush as described above, we do both D$ and I$
passes at once.

It would be indeed nice to be able to avoid the D$ flush when the page
was the target of a DMA operation, since the D$ flush is the most
expensive part of the process.

However, I don't see how to do that without having a separate page bit
to keep track of the D$ vs. I$ state. For example, if we use PG_arch_1
exclusively for D$, and always flush I$ on mapping to userspace, we end
up with a lot of I$ spurrious flushes any time glibc text for example is
mapped into a new process.

> The other thing you might not appreciate in ppc land is that for a lot
> of other systems (well, like parisc) flushing a dirty cache line is
> incredibly expensive (because we halt the CPU to wait for the memory
> eviction), 

Same here. High end server PPCs have the I$ snoop the D$ but on all the
other ones, we pay a dear price for those flushes, which is why I'm
trying to see how I could exploit the trick of not doing the D$ side
flush at least for targets of DMA ops, but as I said, I can't see how it
can be done properly without another tracking bit in struct page.

> so ideally we want to flush as late as possible to give the
> natural operations a chance to clean most of the cache lines.  Flushing
> a clean cache line on parisc as well as invalidations are fast
> operations.  That's why the kmap makes the most sense to us for
> implementing PIO ops ... it's the farthest point we can flush the cache
> at (because beyond it we've lost the mapping the VIPT cache requires to

Cheers,
Ben.

> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2010-03-04 21:25 UTC|newest]

Thread overview: 155+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100129185434.GH19501@one-eyed-alien.net>
     [not found] ` <1265045354.25750.52.camel@pc1117.cambridge.arm.com>
2010-02-08  6:55   ` USB mass storage and ARM cache coherency Pavel Machek
2010-02-08  7:33     ` Andreas Mohr
2010-02-08 10:19       ` Catalin Marinas
2010-02-08  9:51     ` Catalin Marinas
2010-02-08 10:03       ` Andy Green
2010-02-17  9:50         ` Sascha Hauer
2010-02-17  9:57           ` Andy Green
2010-02-08 10:52       ` Pavel Machek
2010-02-08 11:28         ` Catalin Marinas
2010-02-16  7:57           ` Shilimkar, Santosh
2010-02-16  8:22             ` Oliver Neukum
2010-02-16  8:55               ` Shilimkar, Santosh
2010-02-16  9:07                 ` Oliver Neukum
2010-02-16  9:39                   ` Russell King - ARM Linux
2010-02-16 13:32                     ` Oliver Neukum
2010-02-16 13:40                       ` Shilimkar, Santosh
2010-02-16 13:46                         ` Oliver Neukum
2010-02-16 14:12                           ` Shilimkar, Santosh
2010-02-16 14:22                             ` Oliver Neukum
2010-02-16 14:45                               ` Shilimkar, Santosh
2010-02-16 15:44                                 ` Alan Stern
2010-02-17  8:55                               ` Shilimkar, Santosh
2010-02-17  9:10                                 ` Oliver Neukum
2010-02-17  9:17                                   ` Shilimkar, Santosh
2010-02-17 17:02                                 ` Alan Stern
2010-02-17 20:26                                   ` Russell King - ARM Linux
2010-02-17 20:30                                   ` Gadiyar, Anand
2010-02-18  6:56                                     ` Oliver Neukum
2010-02-18  7:14                                       ` Gadiyar, Anand
2010-02-17 12:29                     ` Jamie Lokier
2010-02-17  3:21                 ` Ming Lei
2010-02-17  9:05               ` Benjamin Herrenschmidt
2010-02-17  9:15                 ` Oliver Neukum
2010-02-17  9:40                   ` Benjamin Herrenschmidt
2010-02-17 10:09                     ` Oliver Neukum
2010-02-17 10:18                       ` Benjamin Herrenschmidt
2010-02-17 10:23                         ` Oliver Neukum
2010-02-17 12:15                           ` Benjamin Herrenschmidt
2010-02-17  9:55                 ` Russell King - ARM Linux
2010-02-17 10:05                   ` Benjamin Herrenschmidt
2010-02-17 15:27                 ` Catalin Marinas
2010-02-17 20:37                   ` Benjamin Herrenschmidt
2010-02-17 20:44                     ` Russell King - ARM Linux
2010-02-17 22:31                       ` Benjamin Herrenschmidt
2010-02-19 17:15                         ` Catalin Marinas
2010-02-19 17:36                           ` Catalin Marinas
2010-02-19 20:53                             ` Oliver Neukum
2010-02-24  2:48                               ` Benjamin Herrenschmidt
2010-02-24  7:16                                 ` Oliver Neukum
2010-02-24 21:12                                   ` Benjamin Herrenschmidt
2010-02-25  3:48                                     ` Oliver Neukum
2010-02-26  0:22                                       ` Benjamin Herrenschmidt
2010-02-25 12:36                                     ` James Bottomley
2010-02-24  2:47                             ` Benjamin Herrenschmidt
2010-02-24 16:19                               ` Alan Stern
2010-02-24 21:13                                 ` Benjamin Herrenschmidt
2010-02-24 21:50                                   ` Alan Stern
2010-02-25 20:52                                     ` Benjamin Herrenschmidt
2010-02-26 16:00                                   ` Catalin Marinas
2010-02-26 21:36                                     ` Benjamin Herrenschmidt
2010-02-26 16:25                               ` Catalin Marinas
2010-02-26 16:52                                 ` Alan Stern
2010-02-26 21:51                                   ` Benjamin Herrenschmidt
2010-02-26 21:00                                 ` Russell King - ARM Linux
2010-02-28  0:14                                   ` Benjamin Herrenschmidt
2010-02-28  5:01                                     ` James Bottomley
2010-03-01 10:39                                       ` Catalin Marinas
2010-03-01 11:06                                         ` Russell King - ARM Linux
2010-03-02 12:11                                       ` FUJITA Tomonori
2010-03-02 17:05                                         ` Catalin Marinas
2010-03-02 17:47                                           ` Catalin Marinas
2010-03-02 23:33                                             ` Benjamin Herrenschmidt
2010-03-03 10:21                                               ` Catalin Marinas
2010-03-02 23:29                                           ` Benjamin Herrenschmidt
2010-03-03  3:47                                             ` FUJITA Tomonori
2010-03-03  5:10                                               ` Benjamin Herrenschmidt
2010-03-03  5:40                                                 ` James Bottomley
2010-03-03  9:36                                                   ` Russell King - ARM Linux
2010-03-03 10:24                                                     ` James Bottomley
2010-03-03 19:41                                                       ` Russell King - ARM Linux
2010-03-04  2:00                                                   ` Benjamin Herrenschmidt
2010-03-04  8:26                                                     ` James Bottomley
2010-03-04 21:25                                                       ` Benjamin Herrenschmidt [this message]
2010-03-03  6:35                                                 ` FUJITA Tomonori
2010-03-03 10:43                                               ` Catalin Marinas
2010-03-03 10:40                                             ` Catalin Marinas
2010-03-03 21:54                                           ` Pavel Machek
2010-03-04  6:54                                             ` Wolfgang Mües
2010-03-04  9:31                                               ` Russell King - ARM Linux
2010-03-06 10:56                                                 ` Wolfgang Mües
2010-03-06 11:05                                                   ` Oliver Neukum
2010-03-06 19:44                                                   ` Russell King - ARM Linux
2010-03-04 13:47                                               ` Catalin Marinas
2010-03-04 13:35                                             ` Catalin Marinas
2010-03-04 13:51                                               ` Pavel Machek
2010-03-04 14:21                                                 ` James Bottomley
2010-03-04 14:27                                                   ` Russell King - ARM Linux
2010-03-04 15:25                                                     ` Catalin Marinas
2010-03-04 15:34                                                       ` Russell King - ARM Linux
2010-03-04 21:31                                                       ` Benjamin Herrenschmidt
2010-03-06 10:47                                                     ` James Bottomley
2010-03-06 19:36                                                       ` Russell King - ARM Linux
2010-03-06 21:07                                                         ` Benjamin Herrenschmidt
2010-03-07  5:54                                                         ` James Bottomley
2010-03-08 11:17                                                         ` Catalin Marinas
2010-03-06 21:03                                                       ` Benjamin Herrenschmidt
2010-03-07  3:37                                                         ` James Bottomley
2010-03-08  8:46                                                           ` FUJITA Tomonori
2010-03-09  2:25                                                           ` Benjamin Herrenschmidt
2010-03-04 15:29                                                   ` Catalin Marinas
2010-03-04 15:41                                                     ` Paul Mundt
2010-03-04 16:30                                                       ` Russell King - ARM Linux
2010-03-04 17:34                                                         ` Catalin Marinas
2010-03-04 17:54                                                           ` Russell King - ARM Linux
2010-03-04 18:07                                                       ` Catalin Marinas
2010-03-04 21:37                                                         ` Benjamin Herrenschmidt
2010-03-04 22:11                                                           ` Catalin Marinas
2010-03-05  4:34                                                             ` Benjamin Herrenschmidt
2010-03-05  9:27                                                               ` Catalin Marinas
2010-03-05  1:17                                                           ` Paul Mundt
2010-03-05  4:44                                                             ` Benjamin Herrenschmidt
2010-03-10  3:52                                                               ` Paul Mundt
2010-03-11 21:44                                                                 ` Benjamin Herrenschmidt
2010-03-04 21:34                                                       ` Benjamin Herrenschmidt
2010-03-04 21:28                                                   ` Benjamin Herrenschmidt
2010-03-04 21:40                                                     ` Russell King - ARM Linux
2010-03-05  4:31                                                       ` Benjamin Herrenschmidt
2010-03-04 15:35                                                 ` Catalin Marinas
2010-03-07  8:23                                                   ` Pavel Machek
2010-03-08 10:57                                                     ` Catalin Marinas
2010-03-02 23:26                                         ` Benjamin Herrenschmidt
2010-03-01 10:42                                     ` Catalin Marinas
2010-03-03 20:24                                       ` Jamie Lokier
2010-02-26 21:40                                 ` Benjamin Herrenschmidt
2010-02-26 21:49                                   ` Russell King - ARM Linux
2010-02-28  0:24                                     ` Benjamin Herrenschmidt
2010-02-28 19:17                                       ` Pavel Machek
2010-03-01 11:10                                       ` Catalin Marinas
2010-03-02  4:11                                         ` Benjamin Herrenschmidt
2010-02-24  2:39                           ` Benjamin Herrenschmidt
2010-02-26 16:44                             ` Catalin Marinas
2010-02-26 21:49                               ` Benjamin Herrenschmidt
2010-02-26 22:03                                 ` Russell King - ARM Linux
2010-02-28  0:29                                   ` Benjamin Herrenschmidt
2010-02-28 23:20                                   ` Catalin Marinas
2010-02-28 23:17                                 ` Catalin Marinas
2010-02-17 15:27                 ` Catalin Marinas
2010-02-17 15:39                 ` Catalin Marinas
2010-02-17 15:40                 ` Catalin Marinas
2010-02-17 15:40                 ` Catalin Marinas
2010-02-17 16:19                   ` Catalin Marinas
2010-02-17 16:19                   ` Catalin Marinas
2010-02-16  8:44             ` Russell King - ARM Linux
2010-02-16  8:51               ` Gadiyar, Anand
2010-02-20  7:21                 ` Pete Zaitcev

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=1267737901.22204.67.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).