From: public_filter@yahoo.com (P F)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] mmaping with VIVT cache
Date: Fri, 17 Sep 2010 12:07:50 -0700 (PDT) [thread overview]
Message-ID: <589851.42712.qm@web120206.mail.ne1.yahoo.com> (raw)
--- On Thu, 9/16/10, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> On Wed, Sep 15, 2010 at 05:25:38PM-0700, P F wrote:
> > The mmap'd buffer is allocated by vmalloc_32(), and later mapped with
> > vmalloc_to_page()/vm_insert_page().? The DMA'dbuffer is allocated by
> > usb_buffer_alloc().? At the appropriate time, the DMA'd buffer is
> > memcpy()'d into the mmap'd buffer, and userspace is allowed to handle
> > it, at which point it is corrupt.
>
> Ah, that's slightly different as you're not talking about
> the DMA buffers themselves.
>
> However, anyone who is not familiar with VIVT or aliasing
> VIPT caches is going to be caught out by this sort of thing (which
> basically means most ARMs, and at least some PA-RISC.)
Again, thank you for the explanation, Russell.? For some reason I did not
quite grok the root cause of this issue before, but it is now clear to me.
> I don't think we have any APIs in the kernel to handle
> aliasing between the vmalloc space and userspace...
Perhaps I am revealing my ignorance of the driver ecosystem, but I find
this somewhat surprising.? I would think that this sort of construction
would not be uncommon.
For this issue, I can see two solutions:
1.) somehow make the vmalloc'd space non-cacheable so both the user- and
kernelspace mappings match, and there is no cache to alias
2.) invalidate the cache of the userspace mapping before handing the
buffer to userspace (after memcpy() above)
As Laurent noted earlier, (1) is a nonstarter as it has a negative
performance impact.? (2) I propose is a valid and correct solution.? This
is driver-specific, but each buffer corresponds to an image frame (e.g.,
from a webcam), so they are independent, and therefore it does not make
sense to share the cache between frames.? As long as userspace holds the
buffer, the cache is valid, but once it relinquishes the buffer, the cache
holds only stale data and should be purged.
>From your comment, I take it that there is no kernel API to invalidate the
cache of a range in a VMA. Do you think linux-mm would be a more
appropriate forum to continue investigating? Any input would be
appreciated.
next reply other threads:[~2010-09-17 19:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-17 19:07 P F [this message]
2010-09-17 21:06 ` [RFC] mmaping with VIVT cache Russell King - ARM Linux
2010-09-20 10:38 ` Pawel Moll
2010-09-20 10:50 ` Russell King - ARM Linux
2010-09-20 11:31 ` Pawel Moll
-- strict thread matches above, loose matches on Subject: below --
2010-09-16 0:25 P F
2010-09-16 23:05 ` Russell King - ARM Linux
2010-09-13 19:58 P F
2010-09-14 23:50 ` Russell King - ARM Linux
2010-09-15 1:06 ` Eric Miao
2010-09-15 7:31 ` Russell King - ARM Linux
2010-09-15 7:37 ` Eric Miao
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=589851.42712.qm@web120206.mail.ne1.yahoo.com \
--to=public_filter@yahoo.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.