[fuse-devel] Re: [parisc-linux] [PATCH] Fixs to work on ARM and PARIC platforms.

James Bottomley James.Bottomley at SteelEye.com
Tue Apr 4 09:40:04 MDT 2006


On Tue, 2006-04-04 at 10:50 +0200, Miklos Szeredi wrote:
> I still don't see _why_ you need all aliases flushed from
> get_user_pages() when you are only accessing the page through a single
> address.

Because the aliases may contain dirty cache lines.  Even if they only
contained clean cache lines, those lines would then obscure the changed
data is anyone accessed them.  What you're trying to do is to alter the
user's view of a page by modifying the kernel's view of it.  This is
what gets you into the caching problems in the first place.

> Think of it this way: 
> 
> get_user_pages(... write=0 ...) + memcpy() is equivalent to
> copy_from_user()
> 
> get_user_pages(... write=1 ...) + memcpy() + flush_kernel_dcache_page()
> is equivalent to copy_to_user()
> 
> copy_from_user() and copy_to_user() don't care about aliases, do they?

No, because if you look at the implementation, you'll see that
copy_to/from_user() copy straight into the user view (i.e. via the user
cache lines).

> > > Added to the mix are copy_to/from_user_page() which already seem to do
> > > the above, and are used in combination with get_user_pages() which
> > > results in multiple redundant cache flushes.  Not too clean, is it?
> > 
> > I don't see that they do.  If flush_dcache_page() also does anon pages,
> > then the arch implementation of flush_anon_page() will be empty.  If it
> > doesn't, then the flush_anon_page() and flush_dcache_page() are mutually
> > exclusive, anyway (because they both check the anon flag).
> 
> No, I was thinking of 
> 
>   get_user_pages()
>   copy_to_user_page()/copy_from_user_page()
> 
> copy_to/from_user_page are defined as:
> 
> 	  flush_cache_page(vma, vaddr, page_to_pfn(page)); \
> 	  memcpy(dst, src, len); \
> 	  ...
> 
> So they do flush the caches _once more_ after get_user_pages() should
> have already done so.

Well, copy_to/from_user_page() is designed to be fully cache complete,
it certainly can't assume that someone called get_user_pages() on the
page (like copy_to/from_user).

James





More information about the parisc-linux mailing list