cobalt/drvlib: Prefault io memory again
PATCH 1/1 cobalt/drvlib: Prefault io memory again
This issue was fixed a long time ago by03d5b0b0083c ("cobalt/rtdm: fix caching and page fault issues with rtdm_iomap_to_user()"), later with commit c8e9e166b ("cobalt/rtdm: introduce mmap() support")
iomap code lost again the call to cobalt_machine.prefault().
I have no idea why this took so longer to come up again.
Last week, while upgrading an aarch32 setup from Xenomai 2 to Xenomai 3, the application failed due to massive latencies caused by page faults after writing to io memory.
--- kernel/cobalt/rtdm/drvlib.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
kernel/cobalt/rtdm/drvlib.c +12 -2
@@ -1761,6 +1761,7 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa) {pgprot_t prot =PAGE_SHARED ;unsigned long len; +int ret; len = vma->vm_end - vma->vm_start;#ifndef CONFIG_MMU
@@ -1774,8 +1775,17 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)#endif vma->vm_page_prot =pgprot_noncached (prot); -return remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , - len, vma->vm_page_prot); + ret =remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , + len, vma->vm_page_prot); +if (ret) +return ret; + +#ifdef CONFIG_MMU +if (cobalt_machine.prefault) + cobalt_machine.prefault (vma); +#endif + +return 0 ; }static int mmap_buffer_helper (struct rtdm_fd *fd,struct vm_area_struct *vma)
Signature · 1 line
2.35.3
Quoted 36 lines · Richard Weinberger
This issue was fixed a long time ago by
03d5b0b0083c("cobalt/rtdm: fix caching and page fault issues withrtdm_iomap_to_user()"), later with commitc8e9e166b("cobalt/rtdm: introducemmap()support")
iomap code lost again the call tocobalt_machine.prefault().I have no idea why this took so longer to come up again.
Last week, while upgrading an aarch32 setup from Xenomai 2 to Xenomai 3, the application failed due to massive latencies caused by page faults after writing to io memory.Signed-off-by Richard Weinberger <[email protected]>--- kernel/cobalt/rtdm/drvlib.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)kernel/cobalt/rtdm/drvlib.c +5
-2@@ -1761,6 +1761,7 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa) {pgprot_t prot =PAGE_SHARED ;unsigned long len; +int ret; len = vma->vm_end - vma->vm_start;#ifndef CONFIG_MMU @@ -1774,8 +1775,17 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)#endif vma->vm_page_prot =pgprot_noncached (prot); -return remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , - len, vma->vm_page_prot); + ret =remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , + len, vma->vm_page_prot); +if (ret) +return ret;
kernel/cobalt/rtdm/drvlib.c static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa) · line 1791
Quoted 10 lines
kernel/cobalt/rtdm/drvlib.c +7
-0+ +#ifdef CONFIG_MMU +if (cobalt_machine.prefault) + cobalt_machine.prefault (vma); +#endif + +return 0 ; }static int mmap_buffer_helper (struct rtdm_fd *fd,struct vm_area_struct *vma)
This makes sense to me, specifically as c8e9e166bce43 didn't provide any reason nor even mentioned the fact that it didn't add prefault to the iomem_helper. Philippe, was there a reason? Are we side-effect-free /wrt actual IO memory accesses when pre-faulting?
Jan
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
----- Ursprüngliche Mail -----
Quoted 57 lines
Von: "Jan Kiszka" <[email protected]>
An: "richard" <[email protected]>, "xenomai" <[email protected]>, "Philippe Gerum" <[email protected]>
CC: [email protected]
Gesendet: Donnerstag, 7. Dezember 2023 10:12:27
Betreff: Re: [PATCH] cobalt/drvlib: Prefault io memory againQuoted 50 lines · Richard Weinberger
This issue was fixed a long time ago by
03d5b0b0083c("cobalt/rtdm: fix caching and page fault issues withrtdm_iomap_to_user()"),
later with commitc8e9e166b("cobalt/rtdm: introducemmap()support") iomap code lost again the call tocobalt_machine.prefault().I have no idea why this took so longer to come up again.
Last week, while upgrading an aarch32 setup from Xenomai 2 to Xenomai 3, the application
failed due to massive latencies caused by page faults after writing to io memory.Signed-off-by Richard Weinberger <[email protected]>--- kernel/cobalt/rtdm/drvlib.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)kernel/cobalt/rtdm/drvlib.c +1
-0@@ -1761,6 +1761,7 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa) {pgprot_t prot =PAGE_SHARED ;unsigned long len; +int ret; len = vma->vm_end - vma->vm_start;#ifndef
CONFIG_MMUkernel/cobalt/rtdm/drvlib.c +11
-2@@ -1774,8 +1775,17 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)#endif vma->vm_page_prot =pgprot_noncached (prot); -return remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , - len, vma->vm_page_prot); + ret =remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , + len, vma->vm_page_prot); +if (ret) +return ret; + +#ifdef CONFIG_MMU +if (cobalt_machine.prefault) + cobalt_machine.prefault (vma); +#endif + +return 0 ; }
Quoted 6 lines
Quoted 1 line
static int
mmap_buffer_helper(struct rtdm_fd *fd, struct vm_area_struct *vma)This makes sense to me, specifically as
c8e9e166bce43didn't provide any reason nor even mentioned the fact that it didn't add prefault to theiomem_helper. Philippe, was there a reason? Are we side-effect-free /wrt actual IO memory accesses when pre-faulting?
*friendly ping*
Thanks,
//richard
Quoted 65 lines · Richard Weinberger
----- Ursprüngliche Mail -----
Quoted 57 lines
Von: "Jan Kiszka" <[email protected]>
An: "richard" <[email protected]>, "xenomai" <[email protected]>, "Philippe Gerum" <[email protected]>
CC: [email protected]
Gesendet: Donnerstag, 7. Dezember 2023 10:12:27
Betreff: Re: [PATCH] cobalt/drvlib: Prefault io memory againQuoted 50 lines · Richard Weinberger
This issue was fixed a long time ago by
03d5b0b0083c("cobalt/rtdm: fix caching and page fault issues withrtdm_iomap_to_user()"),
later with commitc8e9e166b("cobalt/rtdm: introducemmap()support") iomap code lost again the call tocobalt_machine.prefault().I have no idea why this took so longer to come up again.
Last week, while upgrading an aarch32 setup from Xenomai 2 to Xenomai 3, the application
failed due to massive latencies caused by page faults after writing to io memory.Signed-off-by Richard Weinberger <[email protected]>--- kernel/cobalt/rtdm/drvlib.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)kernel/cobalt/rtdm/drvlib.c +1
-0@@ -1761,6 +1761,7 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa) {pgprot_t prot =PAGE_SHARED ;unsigned long len; +int ret; len = vma->vm_end - vma->vm_start;#ifndef
CONFIG_MMUkernel/cobalt/rtdm/drvlib.c +11
-2@@ -1774,8 +1775,17 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)#endif vma->vm_page_prot =pgprot_noncached (prot); -return remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , - len, vma->vm_page_prot); + ret =remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , + len, vma->vm_page_prot); +if (ret) +return ret; + +#ifdef CONFIG_MMU +if (cobalt_machine.prefault) + cobalt_machine.prefault (vma); +#endif + +return 0 ; }Quoted 6 lines
Quoted 1 line
static int
mmap_buffer_helper(struct rtdm_fd *fd, struct vm_area_struct *vma)This makes sense to me, specifically as
c8e9e166bce43didn't provide any reason nor even mentioned the fact that it didn't add prefault to theiomem_helper. Philippe, was there a reason? Are we side-effect-free /wrt actual IO memory accesses when pre-faulting?
Quoted 4 lines
*friendly ping*
Thanks,
//richard
It appears reading the patch that prefaulting may not have been willingly removed from the new iomem helper that was just introduced, but most likely overlooked when splitting the code from the kmem helper. Call this a bug. I don't expect any side-effect of running the generic mm fault handler for the MMIO area, there is no reason justifying that such range would be actually touched.
Sidenote: Dovetail has the per-arch arch_advertise_page_mapping() hook we could use for this purpose at some point. Only implemented for x86 so far in order to export all mappings to the global (init) address space, so that faulting-in vmalloc mem upon first access is disabled. For the time being, xenomai3 should stick with its own prefault handlers though.
Signature · 1 line
Philippe.
Quoted 36 lines · Richard Weinberger
This issue was fixed a long time ago by
03d5b0b0083c("cobalt/rtdm: fix caching and page fault issues withrtdm_iomap_to_user()"), later with commitc8e9e166b("cobalt/rtdm: introducemmap()support")
iomap code lost again the call tocobalt_machine.prefault().I have no idea why this took so longer to come up again.
Last week, while upgrading an aarch32 setup from Xenomai 2 to Xenomai 3, the application failed due to massive latencies caused by page faults after writing to io memory.Signed-off-by Richard Weinberger <[email protected]>--- kernel/cobalt/rtdm/drvlib.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)kernel/cobalt/rtdm/drvlib.c +5
-2@@ -1761,6 +1761,7 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa) {pgprot_t prot =PAGE_SHARED ;unsigned long len; +int ret; len = vma->vm_end - vma->vm_start;#ifndef CONFIG_MMU @@ -1774,8 +1775,17 @@ static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)#endif vma->vm_page_prot =pgprot_noncached (prot); -return remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , - len, vma->vm_page_prot); + ret =remap_pfn_range (vma, vma->vm_start, pa >>PAGE_SHIFT , + len, vma->vm_page_prot); +if (ret) +return ret;
kernel/cobalt/rtdm/drvlib.c static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa) · line 1791
Quoted 10 lines
kernel/cobalt/rtdm/drvlib.c +7
-0+ +#ifdef CONFIG_MMU +if (cobalt_machine.prefault) + cobalt_machine.prefault (vma); +#endif + +return 0 ; }static int mmap_buffer_helper (struct rtdm_fd *fd,struct vm_area_struct *vma)
Thanks, finally applied.
I suppose we also want this in stable versions...
Jan
Signature · 2 lines
Siemens AG, Technology Linux Expert Center