* [PATCH 1/2] introduce debug_kmap_atomic
@ 2009-03-12 15:16 Akinobu Mita
2009-03-12 15:19 ` [PATCH 2/2] use debug_kmap_atomic Akinobu Mita
0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2009-03-12 15:16 UTC (permalink / raw)
To: linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-arch, akpm
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 <akinobu.mita@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <x86@kernel.org>
Cc: <linux-arch@vger.kernel.org>
---
arch/x86/mm/highmem_32.c | 45 +--------------------------------------------
include/linux/highmem.h | 12 ++++++++++++
mm/highmem.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 44 deletions(-)
Index: 2.6-mmotm/arch/x86/mm/highmem_32.c
===================================================================
--- 2.6-mmotm.orig/arch/x86/mm/highmem_32.c
+++ 2.6-mmotm/arch/x86/mm/highmem_32.c
@@ -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 *page
if (!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);
Index: 2.6-mmotm/include/linux/highmem.h
===================================================================
--- 2.6-mmotm.orig/include/linux/highmem.h
+++ 2.6-mmotm/include/linux/highmem.h
@@ -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 */
Index: 2.6-mmotm/mm/highmem.c
===================================================================
--- 2.6-mmotm.orig/mm/highmem.c
+++ 2.6-mmotm/mm/highmem.c
@@ -373,3 +373,48 @@ void __init page_address_init(void)
}
#endif /* defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL) */
+
+#if defined(CONFIG_DEBUG_HIGHMEM) && defined(CONFIG_TRACE_IRQFLAGS_SUPPORT)
+
+void debug_kmap_atomic(enum km_type type)
+{
+ 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
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 2/2] use debug_kmap_atomic 2009-03-12 15:16 [PATCH 1/2] introduce debug_kmap_atomic Akinobu Mita @ 2009-03-12 15:19 ` Akinobu Mita 0 siblings, 0 replies; 2+ messages in thread From: Akinobu Mita @ 2009-03-12 15:19 UTC (permalink / raw) To: linux-kernel Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-arch, akpm Use debug_kmap_atomic in kmap_atomic, kmap_atomic_pfn, and iomap_atomic_prot_pfn. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: <x86@kernel.org> Cc: <linux-arch@vger.kernel.org> --- 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(+) Index: 2.6-mmotm/arch/x86/mm/highmem_32.c =================================================================== --- 2.6-mmotm.orig/arch/x86/mm/highmem_32.c +++ 2.6-mmotm/arch/x86/mm/highmem_32.c @@ -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)); Index: 2.6-mmotm/arch/x86/mm/iomap_32.c =================================================================== --- 2.6-mmotm.orig/arch/x86/mm/iomap_32.c +++ 2.6-mmotm/arch/x86/mm/iomap_32.c @@ -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 Index: 2.6-mmotm/arch/mips/mm/highmem.c =================================================================== --- 2.6-mmotm.orig/arch/mips/mm/highmem.c +++ 2.6-mmotm/arch/mips/mm/highmem.c @@ -43,6 +43,7 @@ void *__kmap_atomic(struct page *page, e if (!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)); Index: 2.6-mmotm/arch/powerpc/include/asm/highmem.h =================================================================== --- 2.6-mmotm.orig/arch/powerpc/include/asm/highmem.h +++ 2.6-mmotm/arch/powerpc/include/asm/highmem.h @@ -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(str if (!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 Index: 2.6-mmotm/arch/sparc/mm/highmem.c =================================================================== --- 2.6-mmotm.orig/arch/sparc/mm/highmem.c +++ 2.6-mmotm/arch/sparc/mm/highmem.c @@ -39,6 +39,7 @@ void *kmap_atomic(struct page *page, enu if (!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); Index: 2.6-mmotm/include/asm-frv/highmem.h =================================================================== --- 2.6-mmotm.orig/include/asm-frv/highmem.h +++ 2.6-mmotm/include/asm-frv/highmem.h @@ -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 p unsigned long paddr; pagefault_disable(); + debug_kmap_atomic(type); paddr = page_to_phys(page); switch (type) { Index: 2.6-mmotm/include/asm-mn10300/highmem.h =================================================================== --- 2.6-mmotm.orig/include/asm-mn10300/highmem.h +++ 2.6-mmotm/include/asm-mn10300/highmem.h @@ -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 ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-12 15:20 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-03-12 15:16 [PATCH 1/2] introduce debug_kmap_atomic Akinobu Mita 2009-03-12 15:19 ` [PATCH 2/2] use debug_kmap_atomic Akinobu Mita
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome