From: Philippe Gerum <rpm@xenomai.org>
To: xenomai@xenomai.org
Subject: [Xenomai-help] COW-disable patch
Date: Wed, 27 Dec 2006 18:32:05 +0100 [thread overview]
Message-ID: <1167240725.32420.37.camel@domain.hid> (raw)
In-Reply-To: <45923BEE.6020302@domain.hid>
On Wed, 2006-12-27 at 10:25 +0100, Gilles Chanteperdrix wrote:
> M. Koehrer wrote:
> > Hi Philippe,
> >
> > I agree. To fix the root cause is actually the very best to do!
> > This eases the life of users and developers.
> >
> > Regards
> >
> > Mathias
>
> Hi Mathias,
>
> here comes a workaround for the COW issue on Linux 2.6.19. The patch
> relies on a new VM_NOCOW flag which should be set for real-time
> application if you use Xenomai trunk.
>
> It would be nice if you could test it.
>
Here is the same patch backported to 2.6.14 for the ppc people who
experienced the same kind of issues. When enabling the nucleus debug
option (full, with queue checks), no more warning should appear in the
kernel log about threads being switched to secondary mode while the
latency test runs. The last patch is to be applied against a Xenomai
2.3.x tree to activate the feature. Feedback highly recommended if you
want this patch to be merged in. TIA,
--- 2.6.14/include/linux/mm.h 2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-ipipe/include/linux/mm.h 2006-12-26 19:38:10.000000000 +0100
@@ -162,6 +162,7 @@
#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
#define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
#define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */
+#define VM_NOCOW 0x10000000 /* Disable COW mapping for the vma */
#ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */
#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
--- 2.6.14/mm/memory.c 2006-12-26 19:46:40.000000000 +0100
+++ 2.6.14-ipipe/mm/memory.c 2006-12-26 19:46:54.000000000 +0100
@@ -341,10 +341,10 @@
* but may be dropped within p[mg]d_alloc() and pte_alloc_map().
*/
-static inline void
+static inline int
copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
- pte_t *dst_pte, pte_t *src_pte, unsigned long vm_flags,
- unsigned long addr)
+ pte_t *dst_pte, pte_t *src_pte, unsigned long vm_flags,
+ unsigned long addr, struct vm_area_struct *vma)
{
pte_t pte = *src_pte;
struct page *page;
@@ -362,7 +362,7 @@
}
}
set_pte_at(dst_mm, addr, dst_pte, pte);
- return;
+ return 0;
}
pfn = pte_pfn(pte);
@@ -377,7 +377,7 @@
if (!page || PageReserved(page)) {
set_pte_at(dst_mm, addr, dst_pte, pte);
- return;
+ return 0;
}
/*
@@ -385,6 +385,27 @@
* in the parent and the child
*/
if ((vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE) {
+#ifdef CONFIG_IPIPE
+ if (((vm_flags|src_mm->def_flags) & (VM_NOCOW|VM_LOCKED)) == (VM_NOCOW|VM_LOCKED)) {
+ struct page *old_page = page;
+ page = alloc_page_vma(GFP_HIGHUSER, vma, addr);
+ if (!page)
+ return -ENOMEM;
+
+ copy_user_highpage(page, old_page, addr);
+ pte = mk_pte(page, vma->vm_page_prot);
+
+ if (vm_flags & VM_SHARED)
+ pte = pte_mkclean(pte);
+ pte = pte_mkold(pte);
+ inc_mm_counter(dst_mm, rss);
+ if (PageAnon(page))
+ inc_mm_counter(dst_mm, anon_rss);
+ set_pte_at(dst_mm, addr, dst_pte, pte);
+ page_dup_rmap(page);
+ return 0;
+ }
+#endif /* CONFIG_IPIPE */
ptep_set_wrprotect(src_mm, addr, src_pte);
pte = *src_pte;
}
@@ -402,6 +423,8 @@
inc_mm_counter(dst_mm, anon_rss);
set_pte_at(dst_mm, addr, dst_pte, pte);
page_dup_rmap(page);
+
+ return 0;
}
static int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
@@ -433,7 +456,8 @@
progress++;
continue;
}
- copy_one_pte(dst_mm, src_mm, dst_pte, src_pte, vm_flags, addr);
+ if (copy_one_pte(dst_mm, src_mm, dst_pte, src_pte, vm_flags, addr, vma))
+ return -ENOMEM;
progress += 8;
} while (dst_pte++, src_pte++, addr += PAGE_SIZE, addr != end);
spin_unlock(&src_mm->page_table_lock);
--- ksrc/nucleus/shadow.c.orig 2006-12-27 11:42:50.000000000 +0100
+++ ksrc/nucleus/shadow.c 2006-12-27 11:42:55.000000000 +0100
@@ -839,6 +839,8 @@
#ifdef CONFIG_MMU
if (!(current->mm->def_flags & VM_LOCKED))
send_sig(SIGXCPU, current, 1);
+ else
+ current->mm->def_flags |= VM_NOCOW;
#endif /* CONFIG_MMU */
current->cap_effective |=
--
Philippe.
next prev parent reply other threads:[~2006-12-27 17:32 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-19 7:54 [Xenomai-help] NMI watchdog: Loading of xeno_native leads to reboot of PC M. Koehrer
2006-12-19 8:08 ` Jan Kiszka
2006-12-19 8:14 ` Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads to M. Koehrer
2006-12-19 8:29 ` Jan Kiszka
2006-12-19 8:59 ` Aw: " M. Koehrer
2006-12-19 9:26 ` [Xenomai-help] NMI watchdog: Loading of xeno_native leads M. Koehrer
2006-12-19 9:36 ` Jan Kiszka
2006-12-19 12:04 ` Aw: " M. Koehrer
2006-12-19 13:05 ` Gilles Chanteperdrix
2006-12-19 13:07 ` Jan Kiszka
2006-12-19 14:13 ` Aw: " M. Koehrer
2006-12-20 13:25 ` [Xenomai-help] A fairly small rtnet/Xenomai application that freezes the PC M. Koehrer
2006-12-20 13:58 ` [Xenomai-help] " Jan Kiszka
2006-12-20 14:11 ` [Xenomai-help] Aw: " M. Koehrer
2006-12-21 8:48 ` [Xenomai-help] Re: Re: A fairly small rtnet/Xenomai application that freezes the M. Koehrer
2006-12-21 9:03 ` [Xenomai-help] " Jan Kiszka
2006-12-21 10:21 ` M. Koehrer
2006-12-21 10:45 ` Dmitry Adamushko
2006-12-21 11:19 ` [Xenomai-help] " M. Koehrer
2006-12-21 11:28 ` Philippe Gerum
2006-12-21 11:51 ` [Xenomai-help] Re: Re: Re: A fairly small rtnet/Xenomai M. Koehrer
2006-12-21 13:09 ` Dmitry Adamushko
2006-12-21 13:36 ` [Xenomai-help] " M. Koehrer
2006-12-21 14:13 ` Philippe Gerum
2006-12-21 15:00 ` [Xenomai-help] " M. Koehrer
2006-12-21 15:17 ` Dmitry Adamushko
2006-12-21 15:36 ` [Xenomai-help] " M. Koehrer
2006-12-21 15:43 ` Dmitry Adamushko
2006-12-21 18:18 ` [Xenomai-help] " Gilles Chanteperdrix
2006-12-22 9:06 ` [Xenomai-help] " M. Koehrer
2006-12-22 9:24 ` Dmitry Adamushko
2006-12-22 9:24 ` [Xenomai-help] " Gilles Chanteperdrix
2006-12-22 9:38 ` [Xenomai-help] " M. Koehrer
2006-12-22 9:40 ` [Xenomai-help] " Dmitry Adamushko
2006-12-22 10:15 ` Gilles Chanteperdrix
2006-12-22 10:27 ` [Xenomai-help] " M. Koehrer
2006-12-22 10:42 ` Dmitry Adamushko
2006-12-22 11:20 ` Philippe Gerum
2006-12-22 11:40 ` [Xenomai-help] " M. Koehrer
2006-12-22 12:09 ` Philippe Gerum
2006-12-27 9:25 ` [Xenomai-help] " Gilles Chanteperdrix
2006-12-27 9:29 ` [Xenomai-help] Aw: " M. Koehrer
2006-12-27 10:44 ` [Xenomai-help] " Philippe Gerum
2007-01-02 8:23 ` M. Koehrer
2007-01-02 9:53 ` Philippe Gerum
2007-01-02 14:09 ` Niklaus Giger
2007-01-04 20:57 ` Niklaus Giger
2007-01-05 10:57 ` Philippe Gerum
2006-12-27 17:32 ` Philippe Gerum [this message]
2006-12-22 11:03 ` Jan Kiszka
2006-12-21 15:19 ` [Xenomai-help] Re: Re: Re: " M. Koehrer
2006-12-21 16:50 ` Jan Kiszka
2006-12-21 16:54 ` Philippe Gerum
2006-12-21 17:13 ` [Xenomai-help] " Jan Kiszka
2006-12-21 17:47 ` Jan Kiszka
2006-12-21 10:53 ` [Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the Gilles Chanteperdrix
2006-12-21 11:35 ` [Xenomai-help] " M. Koehrer
2006-12-21 12:14 ` M. Koehrer
2006-12-21 11:35 ` [Xenomai-help] " Jan Kiszka
2006-12-21 12:50 ` Dmitry Adamushko
2006-12-21 13:26 ` Gilles Chanteperdrix
2006-12-21 14:45 ` Gilles Chanteperdrix
2006-12-21 15:12 ` Dmitry Adamushko
2006-12-22 9:19 ` Gilles Chanteperdrix
2006-12-21 12:48 ` Jan Kiszka
2006-12-19 9:26 ` Aw: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads to Jan Kiszka
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=1167240725.32420.37.camel@domain.hid \
--to=rpm@xenomai.org \
--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.