mmap coherency kernel to user

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi,
I have written a driver that implements mmap using the nopage method.
I handle the nopage simply by supplying a page that i get from
get_free_page.

As a user I'm using mmap (share mode) to get the page. I write to the
memory, then I cout its contents (in user mode), then I invoke an ioctl
that simply prints the content of the first bytes of the page, from the
kernel point of view.

The problem is that the kernel doesn't get updated often enough. i.e.
if I wait a second and invoke the ioctl I might see the new value, but
if I don't wait at all I see an older value.

I guess the problem has to do with cache coherency, but I couldn't find
a way to solve it (I tried flush_dcache_page before printing the
content of the page, I also tried changing the VMA prot mode to
no_cache but non of them helped).

The other direction is true as well, if I change the buffer in the
ioctl (after the mapping) I do not see the result in the user
application.

I'm using arm xscale processor. Kernel 2.6.12.

Any suggestions?


Re: mmap coherency kernel to user
Hi eransha,

Quoted text here. Click to load it

I don't think it is a cache problem. After all, the cache is the same for
user and kernel space.

Post some code.

best regards
Wolfgang


Re: mmap coherency kernel to user
Thanks for the response

I checked the code and it works fine on x86.
I think it has to do with the ARM, or something I miss-configured in
the kernel.

regards,
Eransha


Re: mmap coherency kernel to user
Quoted text here. Click to load it

No it's not, not on ARM. The dcache is VTVI so you have to invalidate
through the userspace virtual mapping to see the updated data in the
buffer.

-Matt

Re: mmap coherency kernel to user
Matt,
How do you invalidate it in the user space?


Re: mmap coherency kernel to user
Quoted text here. Click to load it

Try calling mmap() with the O_SYNC flag.

Re: mmap coherency kernel to user
didn't work.

I tired another thing: unmap the buffer as soon as I write the new
value, then call the ioctl, but it didn't do the trick.

doesn't unmapping need to invalidate the cache?


Site Timeline