Nocow patch.
Subsystems (7)
Hi,
I continued working on the idea of nocow patch, here is a beefed up version. When setting the NOCOW flag for the first time:
- it faults any COW mapping of the target process, this is to handle the case where a process would call fork (for example, in order to become a daemon) before shadowing any thread;
- all vmalloc and ioremap areas are added to the target process vm.
A list of the mm structs of the processes which have the NOCOW flag is maintained and used when calling vmalloc or ioremap to update only the mapping of the processes in this list. This allows firstly to workaround vmalloc and ioremap faults on architectures that do not have pgd_list, and secondly should improve the overhead added by the I-pipe patch to the ioremap and vmalloc calls.
Since the VM_NOCOW flag now really means "no page fault", the NOCOW flag was renamed "NOFAULT".
This was run on x86, but need further testing before inclusion.
Signature · 1 line
Gilles Chanteperdrix
arch/i386/mm/fault.c +16 -0
@@ -654,3 +654,19 @@ void vmalloc_sync_all(void) } }#endif + +#ifdef CONFIG_IPIPE +int ipipe_arch_map_vm_area_to_mm (struct mm_struct *mm, +unsigned long start, +unsigned long end) +{ +unsigned long next, addr = start; + +do { + next =pgd_addr_end (addr, end); +vmalloc_sync_one (mm->pgd, addr); + }while (addr = next, addr != end); + +return 0 ; +} +#endif /* CONFIG_IPIPE */
include/asm-i386/pgalloc.h +0 -23
@@ -46,27 +46,4 @@ static inline void pte_free(struct page#define check_pgt_cache () do { } while (0) -static inline void set_pgdir (unsigned long address,pgd_t entry) -{ -#ifdef CONFIG_IPIPE -struct task_struct * p; -struct page *page; -pgd_t *pgd; - -read_lock (&tasklist_lock); - -for_each_process (p) { -if (p->mm) - *pgd_offset (p->mm,address) = entry; - } - -read_unlock (&tasklist_lock); - -for (page = pgd_list; page; page = (struct page *)page->index) { - pgd = (pgd_t *)page_address (page); - pgd[address >>PGDIR_SHIFT ] = entry; - } -#endif /* CONFIG_IPIPE */ -} -#endif /* _I386_PGALLOC_H */
include/linux/mm.h +1 -0
@@ -166,6 +166,7 @@ extern unsigned int kobjsize(const void#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_INSERTPAGE 0x02000000/* The vma has had "vm_insert_page()" done on it */ +#define VM_NOFAULT 0x10000000/* Disable faults for the vma */ #ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
include/linux/sched.h +4 -0
@@ -363,6 +363,10 @@ struct mm_struct {/* aio bits */ rwlock_t ioctx_list_lock;struct kioctx *ioctx_list; + +#if CONFIG_IPIPE +struct list_head nofault; +#endif /* CONFIG_IPIPE */ };struct sighand_struct {
kernel/fork.c +1 -0
@@ -385,6 +385,7 @@ void mmput(struct mm_struct *mm)if (atomic_dec_and_test (&mm->mm_users)) {ipipe_cleanup_notify (mm); +ipipe_destroy_nofault_mm (mm);exit_aio (mm);exit_mmap (mm);if (!list_empty (&mm->mmlist)) {
lib/ioremap.c +3 -2
@@ -85,9 +85,10 @@ int ioremap_page_range(unsigned long add err =ioremap_pud_range (pgd, addr, next, phys_addr+addr, prot);if (err)break ; -set_pgdir (addr, *pgd); }while (pgd++, addr = next, addr != end); - +#ifdef CONFIG_IPIPE +ipipe_update_nofault_mms (start, end); +#endif /* CONFIG_IPIPE */ flush_cache_vmap (start, end);return err;
mm/memory.c +215 -30
290 lines not on this page · raw message
mm/vmalloc.c +3 -4
@@ -152,15 +152,14 @@ int map_vm_area(struct vm_struct *area,BUG_ON (addr >= end); pgd =pgd_offset_k (addr);do { -pgd_t oldpgd; -memcpy (&oldpgd,pgd,sizeof (pgd_t)); next =pgd_addr_end (addr, end); err =vmap_pud_range (pgd, addr, next, prot, pages);if (err)break ; -if (pgd_val (oldpgd) !=pgd_val (*pgd)) -set_pgdir (addr, *pgd); }while (pgd++, addr = next, addr != end); +#ifdef CONFIG_IPIPE +ipipe_update_nofault_mms ((unsigned long ) area->addr, end); +#endif /* CONFIG_IPIPE */ flush_cache_vmap ((unsigned long ) area->addr, end);return err; }
Am Mittwoch, 10. Januar 2007 19:05 schrieb Gilles Chanteperdrix:
Quoted 1 line
Hi,
<..>
Quoted 1 line
This was run on x86, but need further testing before inclusion.
I wanted to give it a try on my PPC board. But trying to apply it (on a Linxu 2.6.19.1 kernel patched with ksrc/arch/powerpc/patches/adeos-ipipe-2.6.19-ppc-1.5-01.patch gave me the error
Quoted 3 lines
Hunk #1 succeeded at 652 (offset -2 lines).
patching fileinclude/asm-i386/pgalloc.h
Reversed (or previously applied) patch detected! Assume -R? [n]
Same problem with ioremap.c.
Is there a problem or did I apply it against the wrong kernel?
Best regards
Signature · 1 line
Niklaus Giger
Quoted 13 lines · Niklaus Giger
Am Mittwoch, 10. Januar 2007 19:05 schrieb Gilles Chanteperdrix:
Quoted 1 line
Hi,
<..>
Quoted 1 line
This was run on x86, but need further testing before inclusion.
I wanted to give it a try on my PPC board. But trying to apply it (on a Linxu 2.6.19.1 kernel patched with
ksrc/arch/powerpc/patches/adeos-ipipe-2.6.19-ppc-1.5-01.patchgave me the error
Quoted 6 lines
Quoted 3 lines
Hunk #1 succeeded at 652 (offset -2 lines).
patching fileinclude/asm-i386/pgalloc.h
Reversed (or previously applied) patch detected! Assume -R? [n]Same problem with
ioremap.c.
Is there a problem or did I apply it against the wrong kernel?
It is a patch for x86 only for now, other architectures will be implemented when it is stable on x86.
Signature · 1 line
Gilles Chanteperdrix
Quoted 2 lines · Gilles Chanteperdrix
It is a patch for x86 only for now, other architectures will be implemented when it is stable on x86.
By the way, I could not find where the page faults for vmalloc/ioremap areas are handled on ppc, does anybody have a clue ?
Signature · 1 line
Gilles Chanteperdrix
Quoted 1 line · Gilles Chanteperdrix
This was run on x86, but need further testing before inclusion.
Here is a new version, after testing. It appears to run fine. I tested forking in real-time applications both before and after calling rt_task_shadow, and vmallocing areas of 256 Mo, and memseting them both from a non-realtime or real-time context and it works.
The next step is to clean up the patch, but I have to admit that I need some help: should I keep the functions in the files where I put them ? in what headers should I declare them ? Should I define an empty ipipe_update_nofault_mms when CONFIG_IPIPE is not set in order to avoid a few #ifdefs ?
Note that in order to use the patch, you have to call ipipe_disable_task_faults(current) in xnshadow_map instead of simply setting the VM_NOCOW flag.
I will now test the patch on ARM.
Signature · 1 line
Gilles Chanteperdrix
arch/i386/mm/fault.c +16 -0
@@ -654,3 +654,19 @@ void vmalloc_sync_all(void) } }#endif + +#ifdef CONFIG_IPIPE +int ipipe_arch_map_vm_area_to_mm (struct mm_struct *mm, +unsigned long start, +unsigned long end) +{ +unsigned long next, addr = start; + +do { + next =pgd_addr_end (addr, end); +vmalloc_sync_one (mm->pgd, addr); + }while (addr = next, addr != end); + +return 0 ; +} +#endif /* CONFIG_IPIPE */
include/asm-i386/pgalloc.h +0 -23
@@ -46,27 +46,4 @@ static inline void pte_free(struct page#define check_pgt_cache () do { } while (0) -static inline void set_pgdir (unsigned long address,pgd_t entry) -{ -#ifdef CONFIG_IPIPE -struct task_struct * p; -struct page *page; -pgd_t *pgd; - -read_lock (&tasklist_lock); - -for_each_process (p) { -if (p->mm) - *pgd_offset (p->mm,address) = entry; - } - -read_unlock (&tasklist_lock); - -for (page = pgd_list; page; page = (struct page *)page->index) { - pgd = (pgd_t *)page_address (page); - pgd[address >>PGDIR_SHIFT ] = entry; - } -#endif /* CONFIG_IPIPE */ -} -#endif /* _I386_PGALLOC_H */
include/linux/mm.h +1 -0
@@ -166,6 +166,7 @@ extern unsigned int kobjsize(const void#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_INSERTPAGE 0x02000000/* The vma has had "vm_insert_page()" done on it */ +#define VM_NOFAULT 0x10000000/* Disable faults for the vma */ #ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
include/linux/sched.h +4 -0
@@ -363,6 +363,10 @@ struct mm_struct {/* aio bits */ rwlock_t ioctx_list_lock;struct kioctx *ioctx_list; + +#if CONFIG_IPIPE +struct list_head nofault; +#endif /* CONFIG_IPIPE */ };struct sighand_struct {
kernel/fork.c +1 -0
@@ -385,6 +385,7 @@ void mmput(struct mm_struct *mm)if (atomic_dec_and_test (&mm->mm_users)) {ipipe_cleanup_notify (mm); +ipipe_destroy_nofault_mm (mm);exit_aio (mm);exit_mmap (mm);if (!list_empty (&mm->mmlist)) {
lib/ioremap.c +3 -2
@@ -85,9 +85,10 @@ int ioremap_page_range(unsigned long add err =ioremap_pud_range (pgd, addr, next, phys_addr+addr, prot);if (err)break ; -set_pgdir (addr, *pgd); }while (pgd++, addr = next, addr != end); - +#ifdef CONFIG_IPIPE +ipipe_update_nofault_mms (start, end); +#endif /* CONFIG_IPIPE */ flush_cache_vmap (start, end);return err;
mm/memory.c +202 -30
277 lines not on this page · raw message
mm/mlock.c +1 -1
@@ -166,7 +166,7 @@ static int do_mlockall(int flags)if (flags &MCL_FUTURE ) def_flags =VM_LOCKED ; - current->mm->def_flags = def_flags; + current->mm->def_flags |= def_flags;if (flags ==MCL_FUTURE ) goto out;
mm/vmalloc.c +3 -4
@@ -152,15 +152,14 @@ int map_vm_area(struct vm_struct *area,BUG_ON (addr >= end); pgd =pgd_offset_k (addr);do { -pgd_t oldpgd; -memcpy (&oldpgd,pgd,sizeof (pgd_t)); next =pgd_addr_end (addr, end); err =vmap_pud_range (pgd, addr, next, prot, pages);if (err)break ; -if (pgd_val (oldpgd) !=pgd_val (*pgd)) -set_pgdir (addr, *pgd); }while (pgd++, addr = next, addr != end); +#ifdef CONFIG_IPIPE +ipipe_update_nofault_mms ((unsigned long ) area->addr, end); +#endif /* CONFIG_IPIPE */ flush_cache_vmap ((unsigned long ) area->addr, end);return err; }
Quoted 18 lines · Gilles Chanteperdrix
Quoted 1 line · Gilles Chanteperdrix
This was run on x86, but need further testing before inclusion.
Here is a new version, after testing. It appears to run fine. I tested forking in real-time applications both before and after calling
rt_task_shadow, and vmallocing areas of 256 Mo, and memseting them both from a non-realtime or real-time context and it works.The next step is to clean up the patch, but I have to admit that I need some help: should I keep the functions in the files where I put them ? in what headers should I declare them ? Should I define an empty
ipipe_update_nofault_mmswhenCONFIG_IPIPEis not set in order to avoid a few #ifdefs ?diff -Naurdp -x '*~'
ipipe-2.6.19/arch/i386/mm/fault.cipipe-2.6.19-nocow/arch/i386/mm/fault.c
arch/i386/mm/fault.c void vmalloc_sync_all(void) · line 662
Quoted 9 lines
arch/i386/mm/fault.c +6
-0@@ -654,3 +654,19 @@ void vmalloc_sync_all(void) } }#endif + +#ifdef CONFIG_IPIPE +int ipipe_arch_map_vm_area_to_mm (struct mm_struct *mm, +unsigned long start, +unsigned long end) +{
__ipipe_pin_range_mapping() would better identify an internal routine which somehow wires the mapping of a virtual address range into a memory context.
[...]
arch/i386/mm/fault.c void vmalloc_sync_all(void) · line 665
Quoted 3 lines
arch/i386/mm/fault.c +3
-0+ +#if CONFIG_IPIPE +struct list_head nofault;
s,nofault,pinned, ? The point is that the NOFAULT feature does not really disable all faults, but only faults leading to lazy/ondemand mappings. E.g. pathological faults would still raise exceptions.
kernel/fork.c void mmput(struct mm_struct *mm) · line 388
Quoted 12 lines
arch/i386/mm/fault.c +1
-0+#endif /* CONFIG_IPIPE */ };struct sighand_struct {diff -Naurdp -x '*~'
ipipe-2.6.19/kernel/fork.cipipe-2.6.19-nocow/kernel/fork.ckernel/fork.c +1
-0@@ -385,6 +385,7 @@ void mmput(struct mm_struct *mm)if (atomic_dec_and_test (&mm->mm_users)) {ipipe_cleanup_notify (mm); +ipipe_destroy_nofault_mm (mm);
We may want to merge both into the notification trigger. Those nitty-gritty I-pipe details ought to be gathered; after all, removing the mm from the pinned mm queue is also a cleanup operation. This would also remove the need for adding a placeholder in the !CONFIG_IPIPE case.
[...]
kernel/fork.c void mmput(struct mm_struct *mm) · line 390
Quoted 3 lines
kernel/fork.c +2
-1- +#ifdef CONFIG_IPIPE +ipipe_update_nofault_mms (start, end);
I'd suggest something like __ipipe_update_all_pinned_mm().
[...]
kernel/fork.c void mmput(struct mm_struct *mm)
Quoted 3 lines
kernel/fork.c +3
-0+#ifdef CONFIG_IPIPE +#include <linux/vmalloc.h> /* For vmlist */ +#endif /* CONFIG_IPIPE */
No need for noisy conditional here. Including linux/vmalloc.h has no undesirable side-effect in the !CONFIG_IPIPE case anyway.
[...]
Quoted 8 lines
kernel/fork.c +8
-0+ +#ifdef CONFIG_IPIPE +static LIST_HEAD (nofault_mms); +static DEFINE_RWLOCK (nofault_mms_lock); + +static int ipipe_fault_pte_range (struct mm_struct *mm,pmd_t *pmd, +struct vm_area_struct *vma, + unsigned long addr, unsigned long
[...]
Quoted 3 lines
kernel/fork.c +3
-0+static int ipipe_fault_pmd_range (struct mm_struct *mm,pud_t *pud, +struct vm_area_struct *vma, +unsigned long addr,unsigned long end)
[...]
kernel/fork.c
Quoted 3 lines
kernel/fork.c +3
-0+static int ipipe_fault_pud_range (struct mm_struct *mm,pgd_t *pgd, +struct vm_area_struct *vma, +unsigned long addr,unsigned long end)
[...]
Those routines are good candidates for inlining.
kernel/fork.c
Quoted 2 lines
kernel/fork.c +2
-0+int ipipe_disable_task_faults (struct task_struct *tsk) +{
ipipe_disable_ondemand_mappings() would be more accurate.
[...]
kernel/fork.c
Quoted 3 lines
kernel/fork.c +3
-0+#ifdef CONFIG_IPIPE +ipipe_update_nofault_mms ((unsigned long ) area->addr, end); +#endif /* CONFIG_IPIPE */
Better define a nop placeholder for __ipipe_update_all_pinned_mm() in the !CONFIG_IPIPE case instead of the conditional.
Signature · 1 line
Philippe.
Quoted 134 lines · Philippe Gerum
Quoted 20 lines · Gilles Chanteperdrix
Quoted 1 line · Gilles Chanteperdrix
This was run on x86, but need further testing before inclusion.
Here is a new version, after testing. It appears to run fine. I tested forking in real-time applications both before and after calling
rt_task_shadow, and vmallocing areas of 256 Mo, and memseting them both from a non-realtime or real-time context and it works.The next step is to clean up the patch, but I have to admit that I need some help: should I keep the functions in the files where I put them ? in what headers should I declare them ? Should I define an empty
ipipe_update_nofault_mmswhenCONFIG_IPIPEis not set in order to avoid a few #ifdefs ?diff -Naurdp -x '*~'
ipipe-2.6.19/arch/i386/mm/fault.cipipe-2.6.19-nocow/arch/i386/mm/fault.carch/i386/mm/fault.c void vmalloc_sync_all(void) · line 662
Quoted 9 lines
arch/i386/mm/fault.c +6
-0@@ -654,3 +654,19 @@ void vmalloc_sync_all(void) } }#endif + +#ifdef CONFIG_IPIPE +int ipipe_arch_map_vm_area_to_mm (struct mm_struct *mm, +unsigned long start, +unsigned long end) +{
__ipipe_pin_range_mapping()would better identify an internal routine which somehow wires the mapping of a virtual address range into a memory context.[...]
arch/i386/mm/fault.c void vmalloc_sync_all(void) · line 665
Quoted 3 lines
arch/i386/mm/fault.c +3
-0+ +#if CONFIG_IPIPE +struct list_head nofault;s,nofault,pinned, ? The point is that the NOFAULT feature does not really disable all faults, but only faults leading to lazy/ondemand mappings. E.g. pathological faults would still raise exceptions.
kernel/fork.c void mmput(struct mm_struct *mm) · line 388
Quoted 12 lines
arch/i386/mm/fault.c +1
-0+#endif /* CONFIG_IPIPE */ };
struct
sighand_struct{
diff -Naurdp -x '*~'ipipe-2.6.19/kernel/fork.cipipe-2.6.19-nocow/kernel/fork.ckernel/fork.c +1
-0@@ -385,6 +385,7 @@ void mmput(struct mm_struct *mm)if (atomic_dec_and_test (&mm->mm_users)) {ipipe_cleanup_notify (mm); +ipipe_destroy_nofault_mm (mm);We may want to merge both into the notification trigger. Those nitty-gritty I-pipe details ought to be gathered; after all, removing the mm from the pinned mm queue is also a cleanup operation. This would also remove the need for adding a placeholder in the !CONFIG_IPIPE case.
[...]
kernel/fork.c void mmput(struct mm_struct *mm) · line 390
Quoted 3 lines
kernel/fork.c +2
-1- +#ifdef CONFIG_IPIPE +ipipe_update_nofault_mms (start, end);I'd suggest something like
__ipipe_update_all_pinned_mm().[...]
kernel/fork.c void mmput(struct mm_struct *mm)
Quoted 3 lines
kernel/fork.c +3
-0+#ifdef CONFIG_IPIPE +#include <linux/vmalloc.h> /* For vmlist */ +#endif /* CONFIG_IPIPE */ No need for noisy conditional here. Including
linux/vmalloc.hhas no undesirable side-effect in the !CONFIG_IPIPE case anyway.[...]
Quoted 8 lines
kernel/fork.c +8
-0+ +#ifdef CONFIG_IPIPE +static LIST_HEAD (nofault_mms); +static DEFINE_RWLOCK (nofault_mms_lock); + +static int ipipe_fault_pte_range (struct mm_struct *mm,pmd_t *pmd, +struct vm_area_struct *vma, + unsigned long addr, unsigned long[...]
Quoted 3 lines
kernel/fork.c +3
-0+static int ipipe_fault_pmd_range (struct mm_struct *mm,pud_t *pud, +struct vm_area_struct *vma, +unsigned long addr,unsigned long end)[...]
kernel/fork.c
Quoted 3 lines
kernel/fork.c +3
-0+static int ipipe_fault_pud_range (struct mm_struct *mm,pgd_t *pgd, +struct vm_area_struct *vma, +unsigned long addr,unsigned long end)[...]
Those routines are good candidates for inlining.
kernel/fork.c
Quoted 2 lines
kernel/fork.c +2
-0+int ipipe_disable_task_faults (struct task_struct *tsk) +{
ipipe_disable_ondemand_mappings()would be more accurate.[...]
Quoted 8 lines
kernel/fork.c
Quoted 3 lines
kernel/fork.c +3
-0+#ifdef CONFIG_IPIPE +ipipe_update_nofault_mms ((unsigned long ) area->addr, end); +#endif /* CONFIG_IPIPE */ Better define a nop placeholder for
__ipipe_update_all_pinned_mm()in the !CONFIG_IPIPE case instead of the conditional.
Here is an updated version, following your advices.
However, after looking at the ARM patch, I am not so sure __ipipe_update_all_pinned_mm() is the way to go on all architectures. The ARM I-pipe handles vmalloc and ioremap faults without causing a mode switch, I wonder if it is not better than having __ipipe_update_all_pinned_mm() updating page directories all over the place.
Signature · 1 line
Gilles Chanteperdrix
arch/i386/mm/fault.c +15 -0
@@ -654,3 +654,18 @@ void vmalloc_sync_all(void) } }#endif + +#ifdef CONFIG_IPIPE +int __ipipe_pin_range_mapping (struct mm_struct *mm, +unsigned long start,unsigned long end) +{ +unsigned long next, addr = start; + +do { + next =pgd_addr_end (addr, end); +vmalloc_sync_one (mm->pgd, addr); + }while (addr = next, addr != end); + +return 0 ; +} +#endif /* CONFIG_IPIPE */
include/asm-i386/pgalloc.h +0 -23
@@ -46,27 +46,4 @@ static inline void pte_free(struct page#define check_pgt_cache () do { } while (0) -static inline void set_pgdir (unsigned long address,pgd_t entry) -{ -#ifdef CONFIG_IPIPE -struct task_struct * p; -struct page *page; -pgd_t *pgd; - -read_lock (&tasklist_lock); - -for_each_process (p) { -if (p->mm) - *pgd_offset (p->mm,address) = entry; - } - -read_unlock (&tasklist_lock); - -for (page = pgd_list; page; page = (struct page *)page->index) { - pgd = (pgd_t *)page_address (page); - pgd[address >>PGDIR_SHIFT ] = entry; - } -#endif /* CONFIG_IPIPE */ -} -#endif /* _I386_PGALLOC_H */
include/linux/ipipe.h +13 -2
@@ -337,6 +337,15 @@ int fastcall __ipipe_dispatch_wired(stru void fastcall __ipipe_sync_stage(unsigned long syncmask); +int __ipipe_update_all_pinned_mm (unsigned long start,unsigned long end); + +struct mm_struct ; + +void __ipipe_unlink_pinned_mm (struct mm_struct *mm); + +int __ipipe_pin_range_mapping (struct mm_struct *mm, +unsigned long start,unsigned long end); +#ifndef __ipipe_sync_pipeline#define __ipipe_sync_pipeline (syncmask) __ipipe_sync_stage(syncmask)#endif
@@ -434,12 +443,11 @@ static inline void ipipe_init_notify(str__ipipe_dispatch_event (IPIPE_EVENT_INIT ,p); } -struct mm_struct ; -static inline void ipipe_cleanup_notify (struct mm_struct *mm) {if (__ipipe_event_monitored_p (IPIPE_EVENT_CLEANUP ))__ipipe_dispatch_event (IPIPE_EVENT_CLEANUP ,mm); +__ipipe_unlink_pinned_mm (mm); }/* Public interface */
@@ -643,6 +651,8 @@ int fastcall ipipe_set_ptd(int key, void fastcall *ipipe_get_ptd(int key); +int ipipe_disable_ondemand_mappings (struct task_struct *tsk); +#define local_irq_enable_hw_cond () local_irq_enable_hw()#define local_irq_disable_hw_cond () local_irq_disable_hw()#define local_irq_save_hw_cond (flags) local_irq_save_hw(flags)
@@ -690,6 +700,7 @@ void fastcall *ipipe_get_ptd(int key);#define ipipe_cleanup_notify (mm) do { } while(0)#define ipipe_trap_notify (t,r) 0#define ipipe_init_proc () do { } while(0) +#define __ipipe_update_all_pinned_mm (start, end) 0#define local_irq_enable_hw_cond () do { } while(0)#define local_irq_disable_hw_cond () do { } while(0)
include/linux/mm.h +1 -0
@@ -166,6 +166,7 @@ extern unsigned int kobjsize(const void#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_INSERTPAGE 0x02000000/* The vma has had "vm_insert_page()" done on it */ +#define VM_PINNED 0x10000000/* Disable faults for the vma */ #ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
include/linux/sched.h +4 -0
@@ -363,6 +363,10 @@ struct mm_struct {/* aio bits */ rwlock_t ioctx_list_lock;struct kioctx *ioctx_list; + +#if CONFIG_IPIPE +struct list_head pinned; +#endif /* CONFIG_IPIPE */ };struct sighand_struct {
lib/ioremap.c +2 -3
@@ -85,10 +85,9 @@ int ioremap_page_range(unsigned long add err =ioremap_pud_range (pgd, addr, next, phys_addr+addr, prot);if (err)break ; -set_pgdir (addr, *pgd); }while (pgd++, addr = next, addr != end); - -flush_cache_vmap (start, end); +__ipipe_update_all_pinned_mm (start, end); +flush_cache_vmap (start, end);return err; }
mm/memory.c +200 -30
275 lines not on this page · raw message
mm/mlock.c +1 -1
@@ -166,7 +166,7 @@ static int do_mlockall(int flags)if (flags &MCL_FUTURE ) def_flags =VM_LOCKED ; - current->mm->def_flags = def_flags; + current->mm->def_flags |= def_flags;if (flags ==MCL_FUTURE ) goto out;
mm/vmalloc.c +1 -4
@@ -152,15 +152,12 @@ int map_vm_area(struct vm_struct *area,BUG_ON (addr >= end); pgd =pgd_offset_k (addr);do { -pgd_t oldpgd; -memcpy (&oldpgd,pgd,sizeof (pgd_t)); next =pgd_addr_end (addr, end); err =vmap_pud_range (pgd, addr, next, prot, pages);if (err)break ; -if (pgd_val (oldpgd) !=pgd_val (*pgd)) -set_pgdir (addr, *pgd); }while (pgd++, addr = next, addr != end); +__ipipe_update_all_pinned_mm ((unsigned long ) area->addr, end);flush_cache_vmap ((unsigned long ) area->addr, end);return err; }
Quoted 6 lines · Gilles Chanteperdrix
However, after looking at the ARM patch, I am not so sure
__ipipe_update_all_pinned_mm()is the way to go on all architectures. The ARM I-pipe handles vmalloc and ioremap faults without causing a mode switch, I wonder if it is not better than having__ipipe_update_all_pinned_mm()updating page directories all over the place.
I checked with the I-pipe tracer the overhead on an ARM of a fault on a vmalloced area: it costs around 5 us.
Signature · 1 line
Gilles Chanteperdrix
Quoted 11 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
However, after looking at the ARM patch, I am not so sure
__ipipe_update_all_pinned_mm()is the way to go on all architectures. The ARM I-pipe handles vmalloc and ioremap faults without causing a mode switch, I wonder if it is not better than having__ipipe_update_all_pinned_mm()updating page directories all over the place.I checked with the I-pipe tracer the overhead on an ARM of a fault on a vmalloced area: it costs around 5 us.
What is the average latency in user-space on this board for 1Khz and 10Khz periods?
Beyond that, we may want to keep both approaches at hand in the core infrastructure; running the same benchmark on, say an integrator, may give much higher latencies due to lousy cache issues. This still needs to be verified though.
Signature · 1 line
Philippe.
Quoted 11 lines · Philippe Gerum
Quoted 9 lines · Gilles Chanteperdrix
Quoted 6 lines · Gilles Chanteperdrix
However, after looking at the ARM patch, I am not so sure
__ipipe_update_all_pinned_mm()is the way to go on all architectures. The ARM I-pipe handles vmalloc and ioremap faults without causing a mode switch, I wonder if it is not better than having__ipipe_update_all_pinned_mm()updating page directories all over the place.
Quoted 7 lines
Quoted 3 lines
I checked with the I-pipe tracer the overhead on an ARM of a fault on a vmalloced area: it costs around 5 us.
What is the average latency in user-space on this board for 1Khz and 10Khz periods?
At 10 kHz we get a lockup. At 1 kHz, we get a worst case latency around 200 us, with an average latency around 150 us if running the cache calibrator in the background.
Quoted 5 lines
Beyond that, we may want to keep both approaches at hand in the core infrastructure; running the same benchmark on, say an integrator, may give much higher latencies due to lousy cache issues. This still needs to be verified though.
My original point was that the use of ipipe_disable_ondemand_mappings may be traumatic on cache. I am wondering if we should not add a nucleus syscall a bit like mlockall, to which we would pass some flags like COW_CURRENT, VMALLOC_CURRENT, VMALLOC_FUTURE, and depending on these flags, ipipe_disable_ondemand_mappings would only do parts of what it is currently doing.
Signature · 1 line
Gilles Chanteperdrix