diff options
author | John David Anglin <dave.anglin@bell.net> | 2013-02-03 17:59:09 -0500 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2013-02-20 16:49:19 -0500 |
commit | 7633453978c54874849c5f40487ac9e14d43fc12 (patch) | |
tree | 552bc9a01785d2bcdca5cb283b6b2b3af5e3e5b8 | |
parent | 93c3e913e104c9277e32a0d7e03f268d146c57ee (diff) |
parisc: fixes and cleanups in page cache flushing (1/4)
This is the first patch in a series of 4, with which the page cache flushing of
parisc will gets fixed and enhanced. This even fixes the nasty "minifail" bug
(http://wiki.parisc-linux.org/TestCases?highlight=%28minifail%29) which
prevented parisc to stay an official debian port. Basically the flush in
copy_user_page together with the TLB patch from commit
7139bc1579901b53db7e898789e916ee2fb52d78 is what fixes the minifail bug.
This patch still uses the TMPALIAS approach. The new copy_user_page
implementation calls flush_dcache_page_asm to flush the user dcache page
(crucial for minifail fix) via a kernel TMPALIAS mapping. After that, it just
copies the page using the kernel mapping. It does a final flush if needed.
Generally it is hard to avoid doing some cache flushes using the kernel mapping
(e.g., copy_to_user_page and copy_from_user_page).
This patch depends on a subsequent change to pacache.S implementing
clear_page_asm and copy_page_asm. These are optimized routines to clear and
copy a page. The calls in clear_user_page and copy_user_page could be replaced
by calls to memset and memcpy, respectively. I tested prefetch optimizations
in clear_page_asm and copy_page_asm but didn't see any significant performance
improvement on rp3440. I'm not sure if these are routines are significantly
faster than memset and/or memcpy, but they are there for further performance
evaluation.
Signed-off-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r-- | arch/parisc/include/asm/page.h | 20 | ||||
-rw-r--r-- | arch/parisc/kernel/cache.c | 49 | ||||
-rw-r--r-- | arch/parisc/kernel/parisc_ksyms.c | 5 |
3 files changed, 40 insertions, 34 deletions
diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h index 4e0e7dbf0f3f..b7adb2ac049c 100644 --- a/arch/parisc/include/asm/page.h +++ b/arch/parisc/include/asm/page.h | |||
@@ -21,15 +21,27 @@ | |||
21 | #include <asm/types.h> | 21 | #include <asm/types.h> |
22 | #include <asm/cache.h> | 22 | #include <asm/cache.h> |
23 | 23 | ||
24 | #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) | 24 | #define clear_page(page) clear_page_asm((void *)(page)) |
25 | #define copy_page(to,from) copy_user_page_asm((void *)(to), (void *)(from)) | 25 | #define copy_page(to, from) copy_page_asm((void *)(to), (void *)(from)) |
26 | 26 | ||
27 | struct page; | 27 | struct page; |
28 | 28 | ||
29 | void copy_user_page_asm(void *to, void *from); | 29 | void clear_page_asm(void *page); |
30 | void copy_page_asm(void *to, void *from); | ||
31 | void clear_user_page(void *vto, unsigned long vaddr, struct page *pg); | ||
30 | void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, | 32 | void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, |
31 | struct page *pg); | 33 | struct page *pg); |
32 | void clear_user_page(void *page, unsigned long vaddr, struct page *pg); | 34 | |
35 | /* #define CONFIG_PARISC_TMPALIAS */ | ||
36 | |||
37 | #ifdef CONFIG_PARISC_TMPALIAS | ||
38 | void clear_user_highpage(struct page *page, unsigned long vaddr); | ||
39 | #define clear_user_highpage clear_user_highpage | ||
40 | struct vm_area_struct; | ||
41 | void copy_user_highpage(struct page *to, struct page *from, | ||
42 | unsigned long vaddr, struct vm_area_struct *vma); | ||
43 | #define __HAVE_ARCH_COPY_USER_HIGHPAGE | ||
44 | #endif | ||
33 | 45 | ||
34 | /* | 46 | /* |
35 | * These are used to make use of C type-checking.. | 47 | * These are used to make use of C type-checking.. |
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index b89a85ab945e..d9cbb4b22c9f 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c | |||
@@ -329,17 +329,6 @@ EXPORT_SYMBOL(flush_kernel_dcache_page_asm); | |||
329 | EXPORT_SYMBOL(flush_data_cache_local); | 329 | EXPORT_SYMBOL(flush_data_cache_local); |
330 | EXPORT_SYMBOL(flush_kernel_icache_range_asm); | 330 | EXPORT_SYMBOL(flush_kernel_icache_range_asm); |
331 | 331 | ||
332 | void clear_user_page_asm(void *page, unsigned long vaddr) | ||
333 | { | ||
334 | unsigned long flags; | ||
335 | /* This function is implemented in assembly in pacache.S */ | ||
336 | extern void __clear_user_page_asm(void *page, unsigned long vaddr); | ||
337 | |||
338 | purge_tlb_start(flags); | ||
339 | __clear_user_page_asm(page, vaddr); | ||
340 | purge_tlb_end(flags); | ||
341 | } | ||
342 | |||
343 | #define FLUSH_THRESHOLD 0x80000 /* 0.5MB */ | 332 | #define FLUSH_THRESHOLD 0x80000 /* 0.5MB */ |
344 | int parisc_cache_flush_threshold __read_mostly = FLUSH_THRESHOLD; | 333 | int parisc_cache_flush_threshold __read_mostly = FLUSH_THRESHOLD; |
345 | 334 | ||
@@ -373,20 +362,9 @@ void __init parisc_setup_cache_timing(void) | |||
373 | printk(KERN_INFO "Setting cache flush threshold to %x (%d CPUs online)\n", parisc_cache_flush_threshold, num_online_cpus()); | 362 | printk(KERN_INFO "Setting cache flush threshold to %x (%d CPUs online)\n", parisc_cache_flush_threshold, num_online_cpus()); |
374 | } | 363 | } |
375 | 364 | ||
376 | extern void purge_kernel_dcache_page(unsigned long); | 365 | extern void purge_kernel_dcache_page_asm(unsigned long); |
377 | extern void clear_user_page_asm(void *page, unsigned long vaddr); | 366 | extern void clear_user_page_asm(void *, unsigned long); |
378 | 367 | extern void copy_user_page_asm(void *, void *, unsigned long); | |
379 | void clear_user_page(void *page, unsigned long vaddr, struct page *pg) | ||
380 | { | ||
381 | unsigned long flags; | ||
382 | |||
383 | purge_kernel_dcache_page((unsigned long)page); | ||
384 | purge_tlb_start(flags); | ||
385 | pdtlb_kernel(page); | ||
386 | purge_tlb_end(flags); | ||
387 | clear_user_page_asm(page, vaddr); | ||
388 | } | ||
389 | EXPORT_SYMBOL(clear_user_page); | ||
390 | 368 | ||
391 | void flush_kernel_dcache_page_addr(void *addr) | 369 | void flush_kernel_dcache_page_addr(void *addr) |
392 | { | 370 | { |
@@ -399,11 +377,26 @@ void flush_kernel_dcache_page_addr(void *addr) | |||
399 | } | 377 | } |
400 | EXPORT_SYMBOL(flush_kernel_dcache_page_addr); | 378 | EXPORT_SYMBOL(flush_kernel_dcache_page_addr); |
401 | 379 | ||
380 | void clear_user_page(void *vto, unsigned long vaddr, struct page *page) | ||
381 | { | ||
382 | clear_page_asm(vto); | ||
383 | if (!parisc_requires_coherency()) | ||
384 | flush_kernel_dcache_page_asm(vto); | ||
385 | } | ||
386 | EXPORT_SYMBOL(clear_user_page); | ||
387 | |||
402 | void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, | 388 | void copy_user_page(void *vto, void *vfrom, unsigned long vaddr, |
403 | struct page *pg) | 389 | struct page *pg) |
404 | { | 390 | { |
405 | /* no coherency needed (all in kmap/kunmap) */ | 391 | /* Copy using kernel mapping. No coherency is needed |
406 | copy_user_page_asm(vto, vfrom); | 392 | (all in kmap/kunmap) on machines that don't support |
393 | non-equivalent aliasing. However, the `from' page | ||
394 | needs to be flushed before it can be accessed through | ||
395 | the kernel mapping. */ | ||
396 | preempt_disable(); | ||
397 | flush_dcache_page_asm(__pa(vfrom), vaddr); | ||
398 | preempt_enable(); | ||
399 | copy_page_asm(vto, vfrom); | ||
407 | if (!parisc_requires_coherency()) | 400 | if (!parisc_requires_coherency()) |
408 | flush_kernel_dcache_page_asm(vto); | 401 | flush_kernel_dcache_page_asm(vto); |
409 | } | 402 | } |
diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c index ceec85de6290..6795dc6c995f 100644 --- a/arch/parisc/kernel/parisc_ksyms.c +++ b/arch/parisc/kernel/parisc_ksyms.c | |||
@@ -157,5 +157,6 @@ extern void _mcount(void); | |||
157 | EXPORT_SYMBOL(_mcount); | 157 | EXPORT_SYMBOL(_mcount); |
158 | #endif | 158 | #endif |
159 | 159 | ||
160 | /* from pacache.S -- needed for copy_page */ | 160 | /* from pacache.S -- needed for clear/copy_page */ |
161 | EXPORT_SYMBOL(copy_user_page_asm); | 161 | EXPORT_SYMBOL(clear_page_asm); |
162 | EXPORT_SYMBOL(copy_page_asm); | ||