From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Tomas Kalibera <kalibera@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Kernel crash with Xenomai (caused by fork?)
Date: Mon, 31 Mar 2008 22:21:23 +0200 [thread overview]
Message-ID: <18417.18371.183857.809430@domain.hid> (raw)
In-Reply-To: <47F062DE.5000709@domain.hid>
[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 177 bytes --]
Tomas Kalibera wrote:
>
> Crashed on the very same line as before
> Tomas
Ok. Let us look for unbalanced kmap_atomics then. Try this patch instead.
--
Gilles.
[-- Attachment #2: ipipe-kmap_atomic-bug.2.diff --]
[-- Type: text/plain, Size: 3847 bytes --]
diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
index 1c3bf95..a78494e 100644
--- a/arch/x86/mm/highmem_32.c
+++ b/arch/x86/mm/highmem_32.c
@@ -1,6 +1,11 @@
#include <linux/highmem.h>
#include <linux/module.h>
+static struct {
+ const char *file;
+ unsigned line;
+} last_km_user0 [NR_CPUS];
+
void *kmap(struct page *page)
{
might_sleep();
@@ -26,7 +31,8 @@ void kunmap(struct page *page)
* However when holding an atomic kmap is is not legal to sleep, so atomic
* kmaps are appropriate for short, tight code paths only.
*/
-void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
+void *_kmap_atomic_prot(struct page *page, enum km_type type,
+ pgprot_t prot, const char *file, unsigned line)
{
enum fixed_addresses idx;
unsigned long vaddr;
@@ -39,7 +45,17 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
idx = type + KM_TYPE_NR*smp_processor_id();
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
- BUG_ON(!pte_none(*(kmap_pte-idx)));
+ if (!pte_none(*(kmap_pte-idx))) {
+ if (type == KM_USER0)
+ printk("KM_USER0 already mapped at %s:%d\n",
+ last_km_user0[smp_processor_id()].file,
+ last_km_user0[smp_processor_id()].line);
+ BUG();
+ } else if (type == KM_USER0) {
+ last_km_user0[smp_processor_id()].file = file;
+ last_km_user0[smp_processor_id()].line = line;
+ }
+
set_pte(kmap_pte-idx, mk_pte(page, prot));
arch_flush_lazy_mmu_mode();
@@ -70,6 +86,10 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
BUG_ON(vaddr >= (unsigned long)high_memory);
#endif
}
+ if (type == KM_USER0) {
+ last_km_user0[smp_processor_id()].file = NULL;
+ last_km_user0[smp_processor_id()].line = 0;
+ }
arch_flush_lazy_mmu_mode();
pagefault_enable();
@@ -78,7 +98,8 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
/* This is the same as kmap_atomic() but can map memory that doesn't
* have a struct page associated with it.
*/
-void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
+void *_kmap_atomic_pfn(unsigned long pfn, enum km_type type,
+ const char *file, unsigned line)
{
enum fixed_addresses idx;
unsigned long vaddr;
@@ -87,6 +108,16 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
idx = type + KM_TYPE_NR*smp_processor_id();
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+ if (!pte_none(*(kmap_pte-idx))) {
+ if (type == KM_USER0)
+ printk("KM_USER0 already mapped at %s:%d\n",
+ last_km_user0[smp_processor_id()].file,
+ last_km_user0[smp_processor_id()].line);
+ BUG();
+ } else if (type == KM_USER0) {
+ last_km_user0[smp_processor_id()].file = file;
+ last_km_user0[smp_processor_id()].line = line;
+ }
set_pte(kmap_pte-idx, pfn_pte(pfn, kmap_prot));
arch_flush_lazy_mmu_mode();
diff --git a/include/asm-x86/highmem.h b/include/asm-x86/highmem.h
index 13cdcd6..57b89f7 100644
--- a/include/asm-x86/highmem.h
+++ b/include/asm-x86/highmem.h
@@ -68,10 +68,16 @@ extern void FASTCALL(kunmap_high(struct page *page));
void *kmap(struct page *page);
void kunmap(struct page *page);
-void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot);
+void *_kmap_atomic_prot(struct page *page, enum km_type type,
+ pgprot_t prot, const char *file, unsigned line);
+#define kmap_atomic_prot(page, type, prot) \
+ _kmap_atomic_prot(page, type, prot, __FILE__, __LINE__)
void *kmap_atomic(struct page *page, enum km_type type);
void kunmap_atomic(void *kvaddr, enum km_type type);
-void *kmap_atomic_pfn(unsigned long pfn, enum km_type type);
+void *_kmap_atomic_pfn(unsigned long pfn, enum km_type type,
+ const char *file, unsigned line);
+#define kmap_atomic_pfn(pfn, type) \
+ _kmap_atomic_pfn(pfn, type, __FILE__, __LINE__)
struct page *kmap_atomic_to_page(void *ptr);
#ifndef CONFIG_PARAVIRT
next prev parent reply other threads:[~2008-03-31 20:21 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-28 21:06 [Xenomai-core] Kernel crash with Xenomai (caused by fork?) Tomas Kalibera
2008-03-28 23:25 ` Gilles Chanteperdrix
2008-03-29 0:08 ` Gilles Chanteperdrix
2008-03-29 1:36 ` Tomas Kalibera
2008-03-29 20:17 ` Gilles Chanteperdrix
2008-03-30 20:27 ` Gilles Chanteperdrix
2008-03-31 4:04 ` Tomas Kalibera
2008-03-31 20:21 ` Gilles Chanteperdrix [this message]
2008-03-31 20:30 ` Gilles Chanteperdrix
2008-04-01 0:00 ` Tomas Kalibera
2008-04-01 5:52 ` Gilles Chanteperdrix
2008-04-01 7:59 ` Gilles Chanteperdrix
2008-04-01 13:54 ` Tomas Kalibera
2008-04-01 14:03 ` Gilles Chanteperdrix
2008-04-01 15:45 ` Tomas Kalibera
2008-04-01 15:58 ` Gilles Chanteperdrix
2008-04-01 21:23 ` Tomas Kalibera
2008-04-02 8:42 ` Gilles Chanteperdrix
2008-04-02 15:02 ` Tomas Kalibera
2008-04-02 15:07 ` Gilles Chanteperdrix
2008-04-02 18:14 ` Tomas Kalibera
2008-04-02 19:38 ` Tomas Kalibera
2008-04-02 19:42 ` Bill Gatliff
2008-04-02 19:44 ` Gilles Chanteperdrix
2008-04-02 21:45 ` Tomas Kalibera
2008-04-02 22:34 ` Gilles Chanteperdrix
2008-04-02 22:53 ` Gilles Chanteperdrix
2008-04-03 17:31 ` Tomas Kalibera
2008-04-05 4:32 ` Tomas Kalibera
2008-04-05 9:10 ` Jan Kiszka
2008-04-02 23:46 ` Tomas Kalibera
2008-04-03 9:04 ` Gilles Chanteperdrix
2008-04-02 19:52 ` Gilles Chanteperdrix
2008-04-02 21:37 ` Tomas Kalibera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18417.18371.183857.809430@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=kalibera@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.