mm: Introduce new vm_insert_range API
Subsystems (5)
PATCH 1/9 mm: Introduce new vm_insert_range API
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking vm_insert_page() within a loop.
As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_range is the new API which will be used to map a range of kernel memory/pages to user vma.
--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)
include/linux/mm_types.h +3 -0
@@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,extern void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count); +static inline void init_tlb_flush_pending (struct mm_struct *mm) {atomic_set (&mm->tlb_flush_pending,0 );
mm/memory.c +28 -0
@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/** +* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma +* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. +*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; + +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret; + uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page
mm/nommu.c +7 -0
@@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL (vm_insert_page); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_insert_range); +/* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty
Signature · 1 line
1.9.1
Quoted 11 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.
Quoted 7 lines
Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)
Hi,
What is the opposite of vm_insert_range() or even of vm_insert_page()? or is there no need for that?
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1485
Quoted 13 lines
mm/memory.c +5
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/** +* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma
s/no./number/
Quoted 6 lines
mm/memory.c +6
-0+* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. +*/
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 10 lines
mm/memory.c +10
-0+int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; + +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;
For a non-trivial value of page_count:
Is it a problem if vm_insert_page() succeeds for several pages and then fails?
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1511
Quoted 10 lines
mm/memory.c +7
-0+ uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page
thanks.
Signature · 1 line
~Randy
Quoted 21 lines · Randy Dunlap
Quoted 11 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Quoted 7 lines
Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)
Quoted 4 lines
Hi,
What is the opposite of
vm_insert_range()or even ofvm_insert_page()? or is there no need for that?
There is no opposite function of vm_insert_range() / vm_insert_page(). My understanding is, in case of any error, mmap handlers will return the err to user process and user space will decide the next action. So next time when mmap handler is getting invoked it will map from the beginning. Correct me if I am wrong.
Quoted 9 lines
Quoted 9 lines
mm/memory.c +0
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }
Quoted 8 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1485
Quoted 6 lines
mm/memory.c +5
-0/** +* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma s/no./number/
I didn't get it ??
Quoted 13 lines
Quoted 13 lines
mm/memory.c +12
-0+* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. +*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; +
Quoted 8 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 4 lines
mm/memory.c +4
-0+for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;For a non-trivial value of
page_count:
Is it a problem ifvm_insert_page()succeeds for several pages and then fails?
No, it will be considered as total failure and mmap handler will return the err to user space.
Quoted 16 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1511
Quoted 11 lines
mm/memory.c +7
-0+ uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page thanks.
--
~Randy
Quoted 10 lines · Souptick Joarder
Quoted 3 lines · Randy Dunlap
On 11/15/18 7:45 AM, Souptick Joarder wrote:
What is the opposite ofvm_insert_range()or even ofvm_insert_page()? or is there no need for that?There is no opposite function of
vm_insert_range()/vm_insert_page(). My understanding is, in case of any error, mmap handlers will return the err to user process and user space will decide the next action. So next time when mmap handler is getting invoked it will map from the beginning. Correct me if I am wrong.
The opposite function, I suppose, is unmap_region().
Quoted 3 lines
Quoted 1 line
s/no./number/
I didn't get it ??
This is a 'sed' expression. 's' is the 'substitute' command; the / is a separator, 'no.' is what you wrote, and 'number' is what Randy is recommending instead.
Quoted 11 lines
Quoted 8 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 4 lines
mm/memory.c +4
-0+for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;For a non-trivial value of
page_count:
Is it a problem ifvm_insert_page()succeeds for several pages and then fails?No, it will be considered as total failure and mmap handler will return the err to user space.
I think what Randy means is "What happens to the inserted pages?" and the answer is that mmap_region() jumps to the 'unmap_and_free_vma' label, which is an accurate name.
Thanks for looking, Randy.
Quoted 15 lines · Matthew Wilcox
Quoted 10 lines · Souptick Joarder
Quoted 3 lines · Randy Dunlap
On 11/15/18 7:45 AM, Souptick Joarder wrote:
What is the opposite ofvm_insert_range()or even ofvm_insert_page()? or is there no need for that?There is no opposite function of
vm_insert_range()/vm_insert_page(). My understanding is, in case of any error, mmap handlers will return the err to user process and user space will decide the next action. So next time when mmap handler is getting invoked it will map from the beginning. Correct me if I am wrong.The opposite function, I suppose, is
unmap_region().
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
s/no./number/
I didn't get it ??
This is a 'sed' expression. 's' is the 'substitute' command; the / is a separator, 'no.' is what you wrote, and 'number' is what Randy is recommending instead.
Ok. Will change it in v2.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 5 lines
mm/memory.c +4
-0+for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;For a non-trivial value of
page_count:
Is it a problem ifvm_insert_page()succeeds for several pages and then fails?
Quoted 6 lines
Quoted 2 lines
No, it will be considered as total failure and mmap handler will return the err to user space.
I think what Randy means is "What happens to the inserted pages?" and the answer is that
mmap_region()jumps to the 'unmap_and_free_vma' label, which is an accurate name.
Sorry for incorrect understanding of the question.
Quoted 18 lines · Souptick Joarder
Quoted 17 lines · Matthew Wilcox
Quoted 10 lines · Souptick Joarder
Quoted 3 lines · Randy Dunlap
On 11/15/18 7:45 AM, Souptick Joarder wrote:
What is the opposite ofvm_insert_range()or even ofvm_insert_page()? or is there no need for that?There is no opposite function of
vm_insert_range()/vm_insert_page(). My understanding is, in case of any error, mmap handlers will return the err to user process and user space will decide the next action. So next time when mmap handler is getting invoked it will map from the beginning. Correct me if I am wrong.The opposite function, I suppose, is
unmap_region().Quoted 2 lines
Quoted 1 line
s/no./number/
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I didn't get it ??
This is a 'sed' expression. 's' is the 'substitute' command; the / is a separator, 'no.' is what you wrote, and 'number' is what Randy is recommending instead.
Ok. Will change it in v2.
Thanks.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 4 lines
mm/memory.c +4
-0+for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;For a non-trivial value of
page_count:
Is it a problem ifvm_insert_page()succeeds for several pages and then fails?
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
No, it will be considered as total failure and mmap handler will return the err to user space.
I think what Randy means is "What happens to the inserted pages?" and the answer is that
mmap_region()jumps to the 'unmap_and_free_vma' label, which is an accurate name.
which says:
/* Undo any partial mapping done by a device driver. */ unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
and that is what I was missing. Thanks.
Quoted 1 line
Sorry for incorrect understanding of the question.
No problem.
Signature · 1 line
~Randy
Quoted 18 lines · Souptick Joarder
Quoted 17 lines · Matthew Wilcox
Quoted 10 lines · Souptick Joarder
Quoted 3 lines · Randy Dunlap
On 11/15/18 7:45 AM, Souptick Joarder wrote:
What is the opposite ofvm_insert_range()or even ofvm_insert_page()? or is there no need for that?There is no opposite function of
vm_insert_range()/vm_insert_page(). My understanding is, in case of any error, mmap handlers will return the err to user process and user space will decide the next action. So next time when mmap handler is getting invoked it will map from the beginning. Correct me if I am wrong.The opposite function, I suppose, is
unmap_region().Quoted 2 lines
Quoted 1 line
s/no./number/
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I didn't get it ??
This is a 'sed' expression. 's' is the 'substitute' command; the / is a separator, 'no.' is what you wrote, and 'number' is what Randy is recommending instead.
Ok. Will change it in v2.
Thanks.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 4 lines
mm/memory.c +4
-0+for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;For a non-trivial value of
page_count:
Is it a problem ifvm_insert_page()succeeds for several pages and then fails?
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
No, it will be considered as total failure and mmap handler will return the err to user space.
I think what Randy means is "What happens to the inserted pages?" and the answer is that
mmap_region()jumps to the 'unmap_and_free_vma' label, which is an accurate name.
which says:
/* Undo any partial mapping done by a device driver. */ unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
and that is what I was missing. Thanks.
Quoted 1 line
Sorry for incorrect understanding of the question.
No problem.
Signature · 6 lines
~Randy _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 15 lines · Matthew Wilcox
Quoted 10 lines · Souptick Joarder
Quoted 3 lines · Randy Dunlap
On 11/15/18 7:45 AM, Souptick Joarder wrote:
What is the opposite ofvm_insert_range()or even ofvm_insert_page()? or is there no need for that?There is no opposite function of
vm_insert_range()/vm_insert_page(). My understanding is, in case of any error, mmap handlers will return the err to user process and user space will decide the next action. So next time when mmap handler is getting invoked it will map from the beginning. Correct me if I am wrong.The opposite function, I suppose, is
unmap_region().
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
s/no./number/
I didn't get it ??
This is a 'sed' expression. 's' is the 'substitute' command; the / is a separator, 'no.' is what you wrote, and 'number' is what Randy is recommending instead.
Ok. Will change it in v2.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 5 lines
mm/memory.c +4
-0+for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;For a non-trivial value of
page_count:
Is it a problem ifvm_insert_page()succeeds for several pages and then fails?
Quoted 6 lines
Quoted 2 lines
No, it will be considered as total failure and mmap handler will return the err to user space.
I think what Randy means is "What happens to the inserted pages?" and the answer is that
mmap_region()jumps to the 'unmap_and_free_vma' label, which is an accurate name.
Sorry for incorrect understanding of the question.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 10 lines · Souptick Joarder
Quoted 3 lines · Randy Dunlap
On 11/15/18 7:45 AM, Souptick Joarder wrote:
What is the opposite ofvm_insert_range()or even ofvm_insert_page()? or is there no need for that?There is no opposite function of
vm_insert_range()/vm_insert_page(). My understanding is, in case of any error, mmap handlers will return the err to user process and user space will decide the next action. So next time when mmap handler is getting invoked it will map from the beginning. Correct me if I am wrong.
The opposite function, I suppose, is unmap_region().
Quoted 3 lines
Quoted 1 line
s/no./number/
I didn't get it ??
This is a 'sed' expression. 's' is the 'substitute' command; the / is a separator, 'no.' is what you wrote, and 'number' is what Randy is recommending instead.
Quoted 11 lines
Quoted 8 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 4 lines
mm/memory.c +4
-0+for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;For a non-trivial value of
page_count:
Is it a problem ifvm_insert_page()succeeds for several pages and then fails?No, it will be considered as total failure and mmap handler will return the err to user space.
I think what Randy means is "What happens to the inserted pages?" and the answer is that mmap_region() jumps to the 'unmap_and_free_vma' label, which is an accurate name.
Thanks for looking, Randy.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 21 lines · Randy Dunlap
Quoted 11 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Quoted 7 lines
Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)
Quoted 4 lines
Hi,
What is the opposite of
vm_insert_range()or even ofvm_insert_page()? or is there no need for that?
There is no opposite function of vm_insert_range() / vm_insert_page(). My understanding is, in case of any error, mmap handlers will return the err to user process and user space will decide the next action. So next time when mmap handler is getting invoked it will map from the beginning. Correct me if I am wrong.
Quoted 9 lines
Quoted 9 lines
mm/memory.c +0
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }
Quoted 8 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1485
Quoted 6 lines
mm/memory.c +5
-0/** +* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma s/no./number/
I didn't get it ??
Quoted 13 lines
Quoted 13 lines
mm/memory.c +12
-0+* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. +*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; +
Quoted 8 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 4 lines
mm/memory.c +4
-0+for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;For a non-trivial value of
page_count:
Is it a problem ifvm_insert_page()succeeds for several pages and then fails?
No, it will be considered as total failure and mmap handler will return the err to user space.
Quoted 16 lines
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1511
Quoted 11 lines
mm/memory.c +7
-0+ uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page thanks.
--
~Randy
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.
Quoted 7 lines
Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)
Hi,
What is the opposite of vm_insert_range() or even of vm_insert_page()? or is there no need for that?
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1485
Quoted 13 lines
mm/memory.c +5
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/** +* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma
s/no./number/
Quoted 6 lines
mm/memory.c +6
-0+* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. +*/
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1501
Quoted 10 lines
mm/memory.c +10
-0+int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; + +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret;
For a non-trivial value of page_count:
Is it a problem if vm_insert_page() succeeds for several pages and then fails?
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1511
Quoted 10 lines
mm/memory.c +7
-0+ uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page
thanks.
Signature · 6 lines
~Randy _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 58 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)include/linux/mm_types.h +3
-0@@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,extern void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count); +static inline void init_tlb_flush_pending (struct mm_struct *mm) {atomic_set (&mm->tlb_flush_pending,0 );mm/memory.c +16
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/** +* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma +* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. +*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i;
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1506
Quoted 10 lines
mm/memory.c +10
-0+ +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret; + uaddr +=PAGE_SIZE ; + } + +return ret; +}
+ EXPORT_SYMBOL(vm_insert_range);
Quoted 26 lines
mm/memory.c +2
-0+ +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page mm/nommu.c +7
-1@@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL (vm_insert_page); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_insert_range); +/* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty -- 1.9.1
Quoted 58 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)include/linux/mm_types.h +3
-0@@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,extern void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count); +static inline void init_tlb_flush_pending (struct mm_struct *mm) {atomic_set (&mm->tlb_flush_pending,0 );mm/memory.c +16
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/** +* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma +* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. +*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i;
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1506
Quoted 10 lines
mm/memory.c +10
-0+ +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret; + uaddr +=PAGE_SIZE ; + } + +return ret; +}
+ EXPORT_SYMBOL(vm_insert_range);
Quoted 24 lines
mm/memory.c +2
-0+ +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page mm/nommu.c +7
-1@@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL (vm_insert_page); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_insert_range); +/* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty --
Quoted 2 lines
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 41 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)include/linux/mm_types.h +3
-0@@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,extern void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count); +static inline void init_tlb_flush_pending (struct mm_struct *mm) {atomic_set (&mm->tlb_flush_pending,0 );mm/memory.c +0
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/**
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1490
Quoted 10 lines
mm/memory.c +10
-0+* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma +* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma.
Please add the return value and context descriptions.
Quoted 42 lines
mm/memory.c +18
-0+*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; + +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret; + uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page mm/nommu.c +7
-0@@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL (vm_insert_page); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_insert_range); +/* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty Signature · 1 line
1.9.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 94 lines · Mike Rapoport
Quoted 41 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)include/linux/mm_types.h +3
-0@@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,extern void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count); +static inline void init_tlb_flush_pending (struct mm_struct *mm) {atomic_set (&mm->tlb_flush_pending,0 );mm/memory.c +0
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/** mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1490
Quoted 10 lines
mm/memory.c +10
-0+* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma +* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. Please add the return value and context descriptions.
Quoted 38 lines
mm/memory.c +18
-0+*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; + +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret; + uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page mm/nommu.c +7
-0@@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL (vm_insert_page); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_insert_range); +/* * sys_brk() for the most part doesn't need the global kernel
Quoted 9 lines
Quoted 4 lines
mm/nommu.c +0
-1* lock, except when an application is doing something nasty --1.9.1
--
Sincerely yours,
Mike.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
Any further feedback on driver changes as part of this patch series ?
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Hi Mike,
Quoted 14 lines · Matthew Wilcox
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Does this description looks good ?
/**
* vm_insert_range - insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context - Process context. Called by mmap handlers.
* Return - int error value
* 0 - OK * -EINVAL - Invalid argument * -ENOMEM - No memory * -EFAULT - Bad address * -EBUSY - Device or resource busy
*/
Quoted 28 lines · Souptick Joarder
Hi Mike,
Quoted 14 lines · Matthew Wilcox
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Does this description looks good ?
Quoted 13 lines
/**
*vm_insert_range- insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context - Process context. Called by mmap handlers.
Context:
Quoted 1 line
* Return - int error value
Return:
Quoted 5 lines
* 0 - OK * -EINVAL - Invalid argument * -ENOMEM - No memory * -EFAULT - Bad address * -EBUSY - Device or resource busy
I don't think that elaborate description of error values is needed, just "0 on success and error code otherwise" would be sufficient.
Quoted 2 lines
*/
Signature · 2 lines
Sincerely yours, Mike.
Quoted 50 lines · Mike Rapoport
Quoted 28 lines · Souptick Joarder
Hi Mike,
Quoted 14 lines · Matthew Wilcox
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Does this description looks good ?
Quoted 13 lines
/**
*vm_insert_range- insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context - Process context. Called by mmap handlers.Context:
Quoted 1 line
* Return - int error value
Return:
Quoted 8 lines
Quoted 5 lines
* 0 - OK * -EINVAL - Invalid argument * -ENOMEM - No memory * -EFAULT - Bad address * -EBUSY - Device or resource busyI don't think that elaborate description of error values is needed, just "0 on success and error code otherwise" would be sufficient.
/**
* vm_insert_range - insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context: Process context. Called by mmap handlers.
* Return: 0 on success and error code otherwise
*/
Quoted 60 lines · Souptick Joarder
Quoted 50 lines · Mike Rapoport
Quoted 28 lines · Souptick Joarder
Hi Mike,
Quoted 14 lines · Matthew Wilcox
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Does this description looks good ?
Quoted 13 lines
/**
*vm_insert_range- insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context - Process context. Called by mmap handlers.Context:
Quoted 1 line
* Return - int error value
Return:
Quoted 8 lines
Quoted 5 lines
* 0 - OK * -EINVAL - Invalid argument * -ENOMEM - No memory * -EFAULT - Bad address * -EBUSY - Device or resource busyI don't think that elaborate description of error values is needed, just "0 on success and error code otherwise" would be sufficient.
Quoted 15 lines
/**
*vm_insert_range- insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context: Process context. Called by mmap handlers.
* Return: 0 on success and error code otherwise
*/
Looks good to me.
Signature · 2 lines
Sincerely yours, Mike.
Quoted 60 lines · Souptick Joarder
Quoted 50 lines · Mike Rapoport
Quoted 28 lines · Souptick Joarder
Hi Mike,
Quoted 14 lines · Matthew Wilcox
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Does this description looks good ?
Quoted 13 lines
/**
*vm_insert_range- insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context - Process context. Called by mmap handlers.Context:
Quoted 1 line
* Return - int error value
Return:
Quoted 8 lines
Quoted 5 lines
* 0 - OK * -EINVAL - Invalid argument * -ENOMEM - No memory * -EFAULT - Bad address * -EBUSY - Device or resource busyI don't think that elaborate description of error values is needed, just "0 on success and error code otherwise" would be sufficient.
Quoted 15 lines
/**
*vm_insert_range- insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context: Process context. Called by mmap handlers.
* Return: 0 on success and error code otherwise
*/
Looks good to me.
Signature · 8 lines
Sincerely yours, Mike. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 50 lines · Mike Rapoport
Quoted 28 lines · Souptick Joarder
Hi Mike,
Quoted 14 lines · Matthew Wilcox
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Does this description looks good ?
Quoted 13 lines
/**
*vm_insert_range- insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context - Process context. Called by mmap handlers.Context:
Quoted 1 line
* Return - int error value
Return:
Quoted 8 lines
Quoted 5 lines
* 0 - OK * -EINVAL - Invalid argument * -ENOMEM - No memory * -EFAULT - Bad address * -EBUSY - Device or resource busyI don't think that elaborate description of error values is needed, just "0 on success and error code otherwise" would be sufficient.
/**
* vm_insert_range - insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context: Process context. Called by mmap handlers.
* Return: 0 on success and error code otherwise
*/
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 28 lines · Souptick Joarder
Hi Mike,
Quoted 14 lines · Matthew Wilcox
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Does this description looks good ?
Quoted 13 lines
/**
*vm_insert_range- insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context - Process context. Called by mmap handlers.
Context:
Quoted 1 line
* Return - int error value
Return:
Quoted 5 lines
* 0 - OK * -EINVAL - Invalid argument * -ENOMEM - No memory * -EFAULT - Bad address * -EBUSY - Device or resource busy
I don't think that elaborate description of error values is needed, just "0 on success and error code otherwise" would be sufficient.
Quoted 2 lines
*/
Signature · 8 lines
Sincerely yours, Mike. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Could you add a line to the description explicitly stating that a failure to insert any page in the range will fail the entire routine, something like:
Quoted 6 lines
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* A failure to insert any page in the range will fail the call as a whole.
It's obvious when reading the code, but it would be self-documenting to state it outright.
Thanks!
-- Bill
Quoted 11 lines · William Kucharski
Could you add a line to the description explicitly stating that a failure to insert any page in the range will fail the entire routine, something like:
Quoted 6 lines
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* A failure to insert any page in the range will fail the call as a whole.
Quoted 2 lines
It's obvious when reading the code, but it would be self-documenting to state it outright.
It's probably better to be more explicit and answer Randy's question:
* If we fail to insert any page into the vma, the function will return
* immediately leaving any previously-inserted pages present. Callers
* from the mmap handler may immediately return the error as their
* caller will destroy the vma, removing any successfully-inserted pages.
* Other callers should make their own arrangements for calling unmap_region().
Although unmap_region() is static so there clearly isn't any code in the kernel today other than in mmap handlers (or fault handlers) that needs to insert pages into a VMA.
Quoted 11 lines · Matthew Wilcox
It's probably better to be more explicit and answer Randy's question:
* If we fail to insert any page into the vma, the function will return
* immediately leaving any previously-inserted pages present. Callers
* from the mmap handler may immediately return the error as their
* caller will destroy the vma, removing any successfully-inserted pages.
* Other callers should make their own arrangements for callingunmap_region().
That works for me as well.
Quoted 11 lines · Matthew Wilcox
It's probably better to be more explicit and answer Randy's question:
* If we fail to insert any page into the vma, the function will return
* immediately leaving any previously-inserted pages present. Callers
* from the mmap handler may immediately return the error as their
* caller will destroy the vma, removing any successfully-inserted pages.
* Other callers should make their own arrangements for callingunmap_region().
That works for me as well.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · Matthew Wilcox
It's probably better to be more explicit and answer Randy's question:
* If we fail to insert any page into the vma, the function will return
* immediately leaving any previously-inserted pages present. Callers
* from the mmap handler may immediately return the error as their
* caller will destroy the vma, removing any successfully-inserted pages.
* Other callers should make their own arrangements for callingunmap_region().
That works for me as well.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · William Kucharski
Could you add a line to the description explicitly stating that a failure to insert any page in the range will fail the entire routine, something like:
Quoted 6 lines
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* A failure to insert any page in the range will fail the call as a whole.
Quoted 2 lines
It's obvious when reading the code, but it would be self-documenting to state it outright.
It's probably better to be more explicit and answer Randy's question:
* If we fail to insert any page into the vma, the function will return
* immediately leaving any previously-inserted pages present. Callers
* from the mmap handler may immediately return the error as their
* caller will destroy the vma, removing any successfully-inserted pages.
* Other callers should make their own arrangements for calling unmap_region().
Although unmap_region() is static so there clearly isn't any code in the kernel today other than in mmap handlers (or fault handlers) that needs to insert pages into a VMA.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Could you add a line to the description explicitly stating that a failure to insert any page in the range will fail the entire routine, something like:
Quoted 6 lines
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* A failure to insert any page in the range will fail the call as a whole.
It's obvious when reading the code, but it would be self-documenting to state it outright.
Thanks!
-- Bill
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Mike,
Quoted 14 lines · Matthew Wilcox
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
Does this description looks good ?
/**
* vm_insert_range - insert range of kernel pages into user vma
* @vma: user vma to map to
* @addr: target user address of this page
* @pages: pointer to array of source kernel pages
* @page_count: number of pages need to insert into user vma *
* This allows drivers to insert range of kernel pages they've allocated
* into a user vma. This is a generic function which drivers can use
* rather than using their own way of mapping range of kernel pages into
* user vma.
*
* Context - Process context. Called by mmap handlers.
* Return - int error value
* 0 - OK * -EINVAL - Invalid argument * -ENOMEM - No memory * -EFAULT - Bad address * -EBUSY - Device or resource busy
*/
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 12 lines · Souptick Joarder
Quoted 11 lines · Mike Rapoport
Quoted 10 lines
+ *
vm_insert_range- insert range of kernel pages into user vma
+ * @vma: user vma to map to
+ * @addr: target user address of this page
+ * @pages: pointer to array of source kernel pages
+ * @page_count: no. of pages need to insert into user vma
+ *
+ * This allows drivers to insert range of kernel pages they've allocated
+ * into a user vma. This is a generic function which drivers can use
+ * rather than using their own way of mapping range of kernel pages into
+ * user vma.
Quoted 5 lines
Quoted 2 lines
Please add the return value and context descriptions.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
You could send your proposed wording now which might remove the need for a v3 if we end up arguing about the wording.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 94 lines · Mike Rapoport
Quoted 41 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)include/linux/mm_types.h +3
-0@@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,extern void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count); +static inline void init_tlb_flush_pending (struct mm_struct *mm) {atomic_set (&mm->tlb_flush_pending,0 );mm/memory.c +0
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/** mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1490
Quoted 10 lines
mm/memory.c +10
-0+* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma +* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma. Please add the return value and context descriptions.
Quoted 38 lines
mm/memory.c +18
-0+*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; + +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret; + uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page mm/nommu.c +7
-0@@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL (vm_insert_page); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_insert_range); +/* * sys_brk() for the most part doesn't need the global kernel
Quoted 9 lines
Quoted 4 lines
mm/nommu.c +0
-1* lock, except when an application is doing something nasty --1.9.1
--
Sincerely yours,
Mike.
Sure I will wait for some time to get additional review comments and add all of those requested changes in v2.
Any further feedback on driver changes as part of this patch series ?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 41 lines · Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>--- include/linux/mm_types.h | 3 +++ mm/memory.c | 28 ++++++++++++++++++++++++++++ mm/nommu.c | 7 +++++++ 3 files changed, 38 insertions(+)include/linux/mm_types.h +3
-0@@ -523,6 +523,9 @@ extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,extern void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count); +static inline void init_tlb_flush_pending (struct mm_struct *mm) {atomic_set (&mm->tlb_flush_pending,0 );mm/memory.c +0
-0@@ -1478,6 +1478,34 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr, }/**
mm/memory.c static int insert_page(struct vm_area_struct *vma, unsigned long addr, · line 1490
Quoted 10 lines
mm/memory.c +10
-0+* vm_insert_range - insert range of kernel pages into user vma +* @vma: user vma to map to +* @addr: target user address of this page +* @pages: pointer to array of source kernel pages +* @page_count: no. of pages need to insert into user vma +* +* This allows drivers to insert range of kernel pages they've allocated +* into a user vma. This is a generic function which drivers can use +* rather than using their own way of mapping range of kernel pages into +* user vma.
Please add the return value and context descriptions.
Quoted 42 lines
mm/memory.c +18
-0+*/ +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +unsigned long uaddr = addr; +int ret =0 , i; + +for (i =0 ; i < page_count; i++) { + ret =vm_insert_page (vma, uaddr, pages[i]); +if (ret <0 ) +return ret; + uaddr +=PAGE_SIZE ; + } + +return ret; +} + +/** * vm_insert_page - insert single page into user vma * @vma: user vma to map to * @addr: target user address of this page mm/nommu.c +7
-0@@ -473,6 +473,13 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, }EXPORT_SYMBOL (vm_insert_page); +int vm_insert_range (struct vm_area_struct *vma,unsigned long addr, +struct page **pages,unsigned long page_count) +{ +return -EINVAL ; +} +EXPORT_SYMBOL (vm_insert_range); +/* * sys_brk() for the most part doesn't need the global kernel * lock, except when an application is doing something nasty Signature · 1 line
1.9.1
Signature · 8 lines
Sincerely yours, Mike. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Am Donnerstag, 15. November 2018, 16:45:30 CET schrieb Souptick Joarder:
Quoted 8 lines
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
Quoted 5 lines
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>
Except the missing EXPORT_SYMBOL for module builds this new API is supposed to run also within the Rockchip drm driver, so on rk3188, rk3288, rk3328 and rk3399 with graphics
Am Donnerstag, 15. November 2018, 16:45:30 CET schrieb Souptick Joarder:
Quoted 8 lines
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking
vm_insert_page()within a loop.As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.
Quoted 5 lines
vm_insert_rangeis the new API which will be used to map a range of kernel memory/pages to user vma.Signed-off-by Souptick Joarder <[email protected]>Reviewed-by Matthew Wilcox <[email protected]>
Except the missing EXPORT_SYMBOL for module builds this new API is supposed to run also within the Rockchip drm driver, so on rk3188, rk3288, rk3328 and rk3399 with graphics
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel