introduce debug_kmap_atomic
Subsystems (8)
PATCH 1/2 introduce debug_kmap_atomic
x86 has debug_kmap_atomic_prot() which is error checking function for kmap_atomic. It is usefull for the other architectures, although it needs CONFIG_TRACE_IRQFLAGS_SUPPORT.
This patch exposes it to the other architectures.
Signed-off-by Akinobu Mita <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc <[email protected]>
Cc <[email protected]>
--- arch/x86/mm/highmem_32.c | 45 +-------------------------------------------- include/linux/highmem.h | 12 ++++++++++++ mm/highmem.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 44 deletions(-)
arch/x86/mm/highmem_32.c +1 -44
@@ -19,49 +19,6 @@ void kunmap(struct page *page)kunmap_high (page); } -static void debug_kmap_atomic_prot (enum km_type type) -{ -#ifdef CONFIG_DEBUG_HIGHMEM -static unsigned warn_count =10 ; - -if (unlikely (warn_count ==0 )) -return ; - -if (unlikely (in_interrupt ())) { -if (in_irq ()) { -if (type !=KM_IRQ0 && type !=KM_IRQ1 && - type !=KM_BIO_SRC_IRQ && type !=KM_BIO_DST_IRQ && - type !=KM_BOUNCE_READ ) { -WARN_ON (1 ); - warn_count--; - } - }else if (!irqs_disabled ()) {/* softirq */ -if (type !=KM_IRQ0 && type !=KM_IRQ1 && - type !=KM_SOFTIRQ0 && type !=KM_SOFTIRQ1 && - type !=KM_SKB_SUNRPC_DATA && - type !=KM_SKB_DATA_SOFTIRQ && - type !=KM_BOUNCE_READ ) { -WARN_ON (1 ); - warn_count--; - } - } - } - -if (type ==KM_IRQ0 || type ==KM_IRQ1 || type ==KM_BOUNCE_READ || - type ==KM_BIO_SRC_IRQ || type ==KM_BIO_DST_IRQ ) { -if (!irqs_disabled ()) { -WARN_ON (1 ); - warn_count--; - } - }else if (type ==KM_SOFTIRQ0 || type ==KM_SOFTIRQ1 ) { -if (irq_count () ==0 && !irqs_disabled ()) { -WARN_ON (1 ); - warn_count--; - } - } -#endif -} -/* * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because * no global lock is needed and because the kmap code must perform a global TLB
@@ -81,7 +38,7 @@ void *kmap_atomic_prot(struct page *pageif (!PageHighMem (page))return page_address (page); -debug_kmap_atomic_prot (type); +debug_kmap_atomic (type); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);
include/linux/highmem.h +12 -0
@@ -187,4 +187,16 @@ static inline void copy_highpage(struct kunmap_atomic(vto, KM_USER1); } +#if defined(CONFIG_DEBUG_HIGHMEM ) && defined(CONFIG_TRACE_IRQFLAGS_SUPPORT ) + +void debug_kmap_atomic (enum km_type type); + +#else + +static inline void debug_kmap_atomic (enum km_type type) +{ +} + +#endif +#endif /* _LINUX_HIGHMEM_H */
mm/highmem.c +45 -0
48 lines not on this page · raw message
PATCH 2/2 use debug_kmap_atomic
Use debug_kmap_atomic in kmap_atomic, kmap_atomic_pfn, and iomap_atomic_prot_pfn.
Signed-off-by Akinobu Mita <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc <[email protected]>
Cc <[email protected]>
--- arch/mips/mm/highmem.c | 2 ++ arch/powerpc/include/asm/highmem.h | 2 ++ arch/sparc/mm/highmem.c | 1 + arch/x86/mm/highmem_32.c | 1 + arch/x86/mm/iomap_32.c | 2 ++ include/asm-frv/highmem.h | 2 ++ include/asm-mn10300/highmem.h | 2 ++ 7 files changed, 12 insertions(+)
arch/x86/mm/highmem_32.c +1 -0
@@ -88,6 +88,7 @@ void *kmap_atomic_pfn(unsigned long pfn,pagefault_disable (); +debug_kmap_atomic (type); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);set_pte (kmap_pte-idx,pfn_pte (pfn, kmap_prot));
arch/x86/mm/iomap_32.c +2 -0
@@ -19,6 +19,7 @@#include <asm/iomap.h> #include <asm/pat.h> #include <linux/module.h> +#include <linux/highmem.h> int is_io_mapping_possible (resource_size_t base,unsigned long size) {
@@ -41,6 +42,7 @@ iomap_atomic_prot_pfn(unsigned long pfn,pagefault_disable (); +debug_kmap_atomic (type);/* * For non-PAT systems, promote PAGE_KERNEL_WC to PAGE_KERNEL_UC_MINUS. * PAGE_KERNEL_WC maps to PWT, which translates to uncached if the
arch/mips/mm/highmem.c +2 -0
@@ -43,6 +43,7 @@ void *__kmap_atomic(struct page *page, eif (!PageHighMem (page))return page_address (page); +debug_kmap_atomic (type); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#ifdef CONFIG_DEBUG_HIGHMEM
@@ -91,6 +92,7 @@ void *kmap_atomic_pfn(unsigned long pfn,pagefault_disable (); +debug_kmap_atomic (type); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);set_pte (kmap_pte-idx,pfn_pte (pfn, kmap_prot));
arch/powerpc/include/asm/highmem.h +2 -0
@@ -24,6 +24,7 @@#include <linux/init.h> #include <linux/interrupt.h> +#include <linux/highmem.h> #include <asm/kmap_types.h> #include <asm/tlbflush.h> #include <asm/page.h>
@@ -94,6 +95,7 @@ static inline void *kmap_atomic_prot(strif (!PageHighMem (page))return page_address (page); +debug_kmap_atomic (type); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#ifdef CONFIG_DEBUG_HIGHMEM
arch/sparc/mm/highmem.c +1 -0
@@ -39,6 +39,7 @@ void *kmap_atomic(struct page *page, enuif (!PageHighMem (page))return page_address (page); +debug_kmap_atomic (type); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);
include/asm-frv/highmem.h +2 -0
@@ -18,6 +18,7 @@#ifdef __KERNEL__#include <linux/init.h> +#include <linux/highmem.h> #include <asm/mem-layout.h> #include <asm/spr-regs.h> #include <asm/mb-regs.h>
@@ -116,6 +117,7 @@ static inline void *kmap_atomic(struct punsigned long paddr;pagefault_disable (); +debug_kmap_atomic (type); paddr =page_to_phys (page);switch (type) {
include/asm-mn10300/highmem.h +2 -0
@@ -16,6 +16,7 @@#include <linux/init.h> #include <linux/interrupt.h> +#include <linux/highmem.h> #include <asm/kmap_types.h> #include <asm/pgtable.h>
@@ -77,6 +78,7 @@ static inline unsigned long kmap_atomic(if (page < highmem_start_page)return page_address (page); +debug_kmap_atomic (type); idx = type +KM_TYPE_NR *smp_processor_id (); vaddr =__fix_to_virt (FIX_KMAP_BEGIN + idx);#if HIGHMEM_DEBUG