Fixs to work on ARM and PARIC platforms.
Subsystems (2)
Quoted 7 lines · Ryan Bradetich
2. I had to add an additional cache flush in the
fuse_copy_dofunction. On both ARM and PARISC, the data was corrupted unless cache is flushed first. Unfortunately I hit it with a very big hammer (flush_cache_all) ... I am hoping someone more familiar with the caches will suggest a better flush function to use. I tried to use theflush_kernel_dcache_pageandflush_dcache_pagefunctions without any luck :(
You're right that a flush_cache_all() isn't going to be acceptable. However, the patch is to a non-existent file, so I don't really see how we can help unless you reduce it to a test case like the previous copytest failures.
James
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 4 lines · Ryan Bradetich
--- fuse-2.6.0-pre2/kernel/dev.c.orig 2006-04-01 00:40:28.000000000
-0800
+++fuse-2.6.0-pre2/kernel/dev.c2006-04-01 00:40:43.000000000
-0800
Is this path just wrong and you meant fs/fuse/dev.c?
In which case, the placement of the flush and the fact that flush_dcache_page() doesn't bring coherency indicates one of the input pages is incoherent at the user level. So it looks like you have an anonymous page you haven't called get_user_pages() on .... and by the way, you have checked that you're actually using the kernel with the parisc implementations of flush_kernel_dcache_page() and flush_anon_page()?
James
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 5 lines
1. The rwlock
tree_lockin struct fuse was not properly initialized usingpthread_rwlock_init(). This normally works on other archs (besides
PARISC) since the lock can be initialized to 0 values, this is not true on the PARISC platform ... these locks must be initialized properly to work on PARISC.
Good find, thanks.
The initialization should actually look like this:
pthread_rwlock_init(&f->tree_lock, NULL);
I can't imagine how your version managed to work...
Quoted 6 lines
2. I had to add an additional cache flush in the
fuse_copy_dofunction. On both ARM and PARISC, the data was corrupted unless cache is flushed first. Unfortunately I hit it with a very big hammer (flush_cache_all) ... I am hoping someone more familiar with the caches will suggest a better flush function to use. I tried to use theflush_kernel_dcache_pageandflush_dcache_pagefunctions without any luck :(
You should try using the parisc patchset from:
http://cvs.parisc-linux.org/download/linux-2.6/
and replace flush_dcache_page() with flush_kernel_dcache_page() in FUSE source.
Thanks,
Miklos
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 7 lines · Ryan Bradetich
Quoted 4 lines
--- fuse-2.6.0-pre2/kernel/dev.c.orig 2006-04-01 00:40:28.000000000
-0800
+++fuse-2.6.0-pre2/kernel/dev.c2006-04-01 00:40:43.000000000
-0800Is this path just wrong and you meant
fs/fuse/dev.c?
Yeah. It's the out-of-tree version, which closely resembles the in-tree one.
Quoted 7 lines
In which case, the placement of the flush and the fact that
flush_dcache_page()doesn't bring coherency indicates one of the input pages is incoherent at the user level. So it looks like you have an anonymous page you haven't calledget_user_pages()on .... and by the way, you have checked that you're actually using the kernel with the parisc implementations offlush_kernel_dcache_page()andflush_anon_page()?
BTW, these seem to be needed for ARM too. Do you have any idea who I should bug about this? The MAINTAINERS file is far from clear on this point.
Thanks,
Miklos
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 3 lines · Miklos Szeredi
BTW, these seem to be needed for ARM too. Do you have any idea who I should bug about this? The
MAINTAINERSfile is far from clear on this point.
Erm, not just arm. The anon page problem looks like it might afflict other incoherent architectures (like sparc and ppc); it just depends whether their flush_dcache_page() accidentally flushes anonymous pages or not.
For arm, it does look like the arm list won't accept postings, so I'd send patches to Russell King <[email protected]>
James
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 3 lines · Miklos Szeredi
I'm confused. What was the exact reason for having a separate function for anon pages? Wouldn't unifying the functionality of
flush_dcache_page()andflush_anon_page()make more sense?
No because flush_dcache_page() is designed for filesystems, which should never see anonymous pages.
Quoted 3 lines
Otherwise sparc and ppc would have to check
PageAnon()from bothflush_dcache_page()andflush_anon_page()and call a common function, which seems to just complicate things without any gain.
I don't think what you propose is desirable or possible:flush_dcache_pages() is designed not to have to flush them (it can't actually because it can't find them properly) but it may flush them by accident if they get swept up into the implementation. Sparc and PPC are CAM flushing implementations, so I suspect the cache just needs to be asked to flush a single physical address and it will find all the virtual aliases and flush them (including the anonymous pages).
James
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 7 lines
Quoted 3 lines
Otherwise sparc and ppc would have to check
PageAnon()from bothflush_dcache_page()andflush_anon_page()and call a common function, which seems to just complicate things without any gain.I don't think what you propose is desirable or possible:
flush_dcache_pages()is designed not to have to flush them (it can't actually because it can't find them properly)
I see now, that flush_anon_page() also gets the virtual address.
Pardon my ignorance, but I'm still not getting the whole picture.
Current (with your API updates) get_user_pages() does the following on PARISC:
flush_anon_page():
- If page is anonymous, the the user address is flushed which was passed to get_user_pages().
flush_dcache_page():
- The kernel address is flushed regardless whether the page is anonymous or not
- If the page is file backed, then all user addresses refering to the page are flushed
Why this discrepancy between anonymous and file backed pages? Wounldn't it be enough for file backed pages too to flush only one user address?
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?
Thanks,
Miklos
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 6 lines · Miklos Szeredi
Quoted 3 lines
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).
Yes. But how will this ensure that the above problems (dirty/clean cache lines in aliases) won't cause any problems?
It doesn't. The object is to write into the user cache as though the actual user process had done it (i.e. disregarding all aliasing).
Quoted 7 lines
What is the difference between
- updating cached data through the user view
- flushing the cache lines for the user view, then updating data through the kernel view and finally flushing the cache lines for the kernel view
In the former, the data usually ends up in dirty user cache lines. In the latter the cache lines are entirely clean after the procedure.
Quoted 2 lines
I don't see in either case that the cache lines for any other aliases are touched. Is there still some difference in behavior?
Yes, in the former, only a single alias (the user view) is affected. In the latter, all views are accounted for.
James
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
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).
Yes. But how will this ensure that the above problems (dirty/clean cache lines in aliases) won't cause any problems?
It doesn't. The object is to write into the user cache as though the actual user process had done it (i.e. disregarding all aliasing).
Which is also what the object of get_user_pages() + memcpy() is. The fact that in the process some part of the cache is flushed is irrelevant.
get_user_pages() is used as a _substitute_ for copy_*_user() if the memory copying needs to be done from a different VM context.
Quoted 8 lines
Quoted 7 lines
What is the difference between
- updating cached data through the user view
- flushing the cache lines for the user view, then updating data through the kernel view and finally flushing the cache lines for the kernel view
Quoted 8 lines
In the former, the data usually ends up in dirty user cache lines. In the latter the cache lines are entirely clean after the procedure.
Quoted 2 lines
I don't see in either case that the cache lines for any other aliases are touched. Is there still some difference in behavior?
Yes, in the former, only a single alias (the user view) is affected. In the latter, all views are accounted for.
I think we agree on what happens, but not about why it is needed to happen.
With your fix get_user_pages() guarantees _more_ coherency than copy_from/to_user(). This not a bug per-se, but it does require a new interface (flush_anon_pages()) and provides "strange" cache coherency semantics.
By strange I mean, that all views of file backed pages are flushed, but only one view of anononymous pages. This IMO doesn't make too much sense, but feel free to correct me if I'm wrong.
How about this?
mm/memory.c +2 -2
@@ -1072,8 +1072,8 @@ int get_user_pages(struct task_struct *tif (pages) { pages[i] = page; -flush_anon_page (page, start); -flush_dcache_page (page); +flush_cache_page (vma, start,page_to_pfn (page)); +flush_kernel_dcache_page (page); }if (vmas) vmas[i] = vma;
The flushing semantics are cleaner, and the flush_anon_page() interface is not needed.
Miklos
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 1 line · Miklos Szeredi
How about this?
It would double flush the page on a lot of architectures
James
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 5 lines · Miklos Szeredi
Quoted 3 lines
Quoted 1 line
How about this?
It would double flush the page on a lot of architectures
Which?
Well ... all of them. Anonymous pages coming into get_user_pages() is pretty much the exception. You do this for every page. But anyway, even if you fixed that, Dave Miller vetoed an implementation based on flush_cache_page() on the grounds that the implementation is nop'd on quite a few architectures because of the way it's used ... it was the first fix I tried to get past linux-arch.
James
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
How about this?
It would double flush the page on a lot of architectures
Which?
Well ... all of them. Anonymous pages coming into
get_user_pages()is pretty much the exception.
I don't think that holds, since I would imagine most user pages _are_ anonymous.
Ptrace is one of the more notable users of get_user_pages() so I checked what happens if I run 'strace /bin/true' on an instrumented kernel.
Anon pages won by 214 to 26.
Quoted 4 lines
You do this for every page. But anyway, even if you fixed that, Dave Miller vetoed an implementation based on
flush_cache_page()on the grounds that the implementation is nop'd on quite a few architectures because of the way it's used
Sounds like another case of a crappy interface.
But I don't care overmuch. I'll submit a patch for ARM and let this issue rest in peace.
Anyway, thanks for the fast course on CPU caches :)
Miklos
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux