Skip to contentSkip to conversation

2.5.59 & mmap_sem

Discontig-devel Andrew Morton 2 participants 4 messages Feb 18, 2003 – Mar 3, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw
Quoted 8 lines · William Lee Irwin III
Quoted 5 lines · Xavier Bru

Thanks for your answers.
You are right, we do not need a page structure for mapping /dev/mem in IO space (I am not a mm expert :-).
Here after a possible patch that allows the Xserver running on the NUMA platform. (We had the same problem on Azusa).

Quoted 6 lines

Looks perfectly reasonable to me. Other discontig/NUMA implementations are likely to run into the same issue.

You might want to send this on to lkml and cc: akpm, he's pretty much the final destination wrt. VM patches and 2.5.

I'd prefer to do this at the vma level if poss. Given that mmap_mem() has set VM_RESERVED against the VMA, it should be sufficient to do

mm/memory.c renamed from mm/memory.c~a +3 -0
diff -puN mm/memory.c~a mm/memory.c
@@ -211,6 +211,9 @@ int copy_page_range(struct mm_struct *ds
 	unsigned long cow;
 	struct pte_chain *pte_chain = NULL;
 
+	if (vma->vm_flags & (VM_RESERVED|VM_IO))
+		return 0;
+
 	if (is_vm_hugetlb_page(vma))
 		return copy_hugetlb_page_range(dst, src, vma);
 
fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~a +1 -1
diff -puN fs/hugetlbfs/inode.c~a fs/hugetlbfs/inode.c
@@ -63,7 +63,7 @@ static int hugetlbfs_file_mmap(struct fi
 	down(&inode->i_sem);
 
 	UPDATE_ATIME(inode);
-	vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
+	vma->vm_flags |= VM_HUGETLB;
 	vma->vm_ops = &hugetlb_vm_ops;
 	ret = hugetlb_prefault(mapping, vma);
 	len = (loff_t)(vma->vm_end - vma->vm_start) +

_

The semantics (and usage!) of the VM_foo flags are rather vague. It needs definiton, and an audit.

#1 lore raw

Works OK for us.
Thanks

Signature · 8 lines
 Sincères salutations.
_____________________________________________________________________
 
Xavier BRU                 BULL ISD/R&D/INTEL office:     FREC B1-422
tel : +33 (0)4 76 29 77 45                    http://www-frec.bull.fr
fax : +33 (0)4 76 29 77 70                 mailto:[email protected]
addr: BULL, 1 rue de Provence, BP 208, 38432 Echirolles Cedex, FRANCE
_____________________________________________________________________
Quoted 51 lines · Andrew Morton
Quoted 8 lines · William Lee Irwin III
Quoted 5 lines · Xavier Bru

Thanks for your answers.
You are right, we do not need a page structure for mapping /dev/mem in IO space (I am not a mm expert :-).
Here after a possible patch that allows the Xserver running on the NUMA platform. (We had the same problem on Azusa).

Quoted 6 lines

Looks perfectly reasonable to me. Other discontig/NUMA implementations are likely to run into the same issue.

You might want to send this on to lkml and cc: akpm, he's pretty much the final destination wrt. VM patches and 2.5.

I'd prefer to do this at the vma level if poss. Given that mmap_mem() has set VM_RESERVED against the VMA, it should be sufficient to do

diff -puN mm/memory.c~a mm/memory.c

mm/memory.c renamed from mm/memory.c~a +3 -0
@@ -211,6 +211,9 @@ int copy_page_range(struct mm_struct *ds
 	unsigned long cow;
 	struct pte_chain *pte_chain = NULL;
 
+	if (vma->vm_flags & (VM_RESERVED|VM_IO))
+		return 0;
+
 	if (is_vm_hugetlb_page(vma))
 		return copy_hugetlb_page_range(dst, src, vma);
 

diff -puN fs/hugetlbfs/inode.c~a fs/hugetlbfs/inode.c

fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~a +1 -1
@@ -63,7 +63,7 @@ static int hugetlbfs_file_mmap(struct fi
 	down(&inode->i_sem);
 
 	UPDATE_ATIME(inode);
-	vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
+	vma->vm_flags |= VM_HUGETLB;
 	vma->vm_ops = &hugetlb_vm_ops;
 	ret = hugetlb_prefault(mapping, vma);
 	len = (loff_t)(vma->vm_end - vma->vm_start) +

_

The semantics (and usage!) of the VM_foo flags are rather vague. It needs definiton, and an audit.

#2 lore raw
In reply to Andrew Morton

On reflection, I think your approach is best - there is (some) value in being able to inherit a /dev/mem mapping across fork(), and ceasing to do so may break applications.

I recast your patch a little. Saves a few instructions and prevents a bogus uninitialised variable warning.

mm/memory.c renamed from mm/memory.c~copy_page_range-invalid-page-fix +4 -2
diff -puN mm/memory.c~copy_page_range-invalid-page-fix mm/memory.c
@@ -286,9 +286,11 @@ skip_copy_pte_range:
 					goto cont_copy_pte_range_noset;
 				}
 				pfn = pte_pfn(pte);
+				if (!pfn_valid(pfn)) {
+					set_pte(dst_pte, pte);
+					goto cont_copy_pte_range_noset;
+				}
 				page = pfn_to_page(pfn);
-				if (!pfn_valid(pfn))
-					goto cont_copy_pte_range;
 				if (PageReserved(page))
 					goto cont_copy_pte_range;
 

_

Quoted 76 lines · Xavier Bru

Works OK for us.
Thanks

Signature · 7 lines
_____________________________________________________________________
 
Xavier BRU                 BULL ISD/R&D/INTEL office:     FREC B1-422
tel : +33 (0)4 76 29 77 45                    http://www-frec.bull.fr
fax : +33 (0)4 76 29 77 70                 mailto:[email protected]
addr: BULL, 1 rue de Provence, BP 208, 38432 Echirolles Cedex, FRANCE
_____________________________________________________________________
Quoted 45 lines · Andrew Morton
Quoted 8 lines · William Lee Irwin III
Quoted 5 lines · Xavier Bru

Thanks for your answers.
You are right, we do not need a page structure for mapping /dev/mem in IO space (I am not a mm expert :-).
Here after a possible patch that allows the Xserver running on the NUMA platform. (We had the same problem on Azusa).

Quoted 6 lines

Looks perfectly reasonable to me. Other discontig/NUMA implementations are likely to run into the same issue.

You might want to send this on to lkml and cc: akpm, he's pretty much the final destination wrt. VM patches and 2.5.

I'd prefer to do this at the vma level if poss. Given that mmap_mem() has set VM_RESERVED against the VMA, it should be sufficient to do

diff -puN mm/memory.c~a mm/memory.c

mm/memory.c renamed from mm/memory.c~a +3 -0
@@ -211,6 +211,9 @@ int copy_page_range(struct mm_struct *ds
 	unsigned long cow;
 	struct pte_chain *pte_chain = NULL;
 
+	if (vma->vm_flags & (VM_RESERVED|VM_IO))
+		return 0;
+
 	if (is_vm_hugetlb_page(vma))
 		return copy_hugetlb_page_range(dst, src, vma);
 

diff -puN fs/hugetlbfs/inode.c~a fs/hugetlbfs/inode.c

fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~a +1 -1
@@ -63,7 +63,7 @@ static int hugetlbfs_file_mmap(struct fi
 	down(&inode->i_sem);
 
 	UPDATE_ATIME(inode);
-	vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
+	vma->vm_flags |= VM_HUGETLB;
 	vma->vm_ops = &hugetlb_vm_ops;
 	ret = hugetlb_prefault(mapping, vma);
 	len = (loff_t)(vma->vm_end - vma->vm_start) +
Quoted 6 lines

_

The semantics (and usage!) of the VM_foo flags are rather vague. It needs definiton, and an audit.

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Discontig-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/discontig-devel

#3 lore raw
In reply to Andrew Morton

I tested this one OK on 2.5.60.
Thanks.
Xavier

Signature · 8 lines
 Sincères salutations.
_____________________________________________________________________
 
Xavier BRU                 BULL ISD/R&D/INTEL office:     FREC B1-422
tel : +33 (0)4 76 29 77 45                    http://www-frec.bull.fr
fax : +33 (0)4 76 29 77 70                 mailto:[email protected]
addr: BULL, 1 rue de Provence, BP 208, 38432 Echirolles Cedex, FRANCE
_____________________________________________________________________
Quoted 106 lines · Andrew Morton

On reflection, I think your approach is best - there is (some) value in being able to inherit a /dev/mem mapping across fork(), and ceasing to do so may break applications.

I recast your patch a little. Saves a few instructions and prevents a bogus uninitialised variable warning.

diff -puN mm/memory.c~copy_page_range-invalid-page-fix mm/memory.c

mm/memory.c renamed from mm/memory.c~copy_page_range-invalid-page-fix +4 -2
@@ -286,9 +286,11 @@ skip_copy_pte_range:
 					goto cont_copy_pte_range_noset;
 				}
 				pfn = pte_pfn(pte);
+				if (!pfn_valid(pfn)) {
+					set_pte(dst_pte, pte);
+					goto cont_copy_pte_range_noset;
+				}
 				page = pfn_to_page(pfn);
-				if (!pfn_valid(pfn))
-					goto cont_copy_pte_range;
 				if (PageReserved(page))
 					goto cont_copy_pte_range;
 

_

Quoted 76 lines · Xavier Bru

Works OK for us.
Thanks

Signature · 7 lines
_____________________________________________________________________
 
Xavier BRU                 BULL ISD/R&D/INTEL office:     FREC B1-422
tel : +33 (0)4 76 29 77 45                    http://www-frec.bull.fr
fax : +33 (0)4 76 29 77 70                 mailto:[email protected]
addr: BULL, 1 rue de Provence, BP 208, 38432 Echirolles Cedex, FRANCE
_____________________________________________________________________
Quoted 45 lines · Andrew Morton
Quoted 8 lines · William Lee Irwin III
Quoted 5 lines · Xavier Bru

Thanks for your answers.
You are right, we do not need a page structure for mapping /dev/mem in IO space (I am not a mm expert :-).
Here after a possible patch that allows the Xserver running on the NUMA platform. (We had the same problem on Azusa).

Quoted 6 lines

Looks perfectly reasonable to me. Other discontig/NUMA implementations are likely to run into the same issue.

You might want to send this on to lkml and cc: akpm, he's pretty much the final destination wrt. VM patches and 2.5.

I'd prefer to do this at the vma level if poss. Given that mmap_mem() has set VM_RESERVED against the VMA, it should be sufficient to do

diff -puN mm/memory.c~a mm/memory.c

mm/memory.c renamed from mm/memory.c~a +3 -0
@@ -211,6 +211,9 @@ int copy_page_range(struct mm_struct *ds
 	unsigned long cow;
 	struct pte_chain *pte_chain = NULL;
 
+	if (vma->vm_flags & (VM_RESERVED|VM_IO))
+		return 0;
+
 	if (is_vm_hugetlb_page(vma))
 		return copy_hugetlb_page_range(dst, src, vma);
 

diff -puN fs/hugetlbfs/inode.c~a fs/hugetlbfs/inode.c

fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~a +1 -1
@@ -63,7 +63,7 @@ static int hugetlbfs_file_mmap(struct fi
 	down(&inode->i_sem);
 
 	UPDATE_ATIME(inode);
-	vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
+	vma->vm_flags |= VM_HUGETLB;
 	vma->vm_ops = &hugetlb_vm_ops;
 	ret = hugetlb_prefault(mapping, vma);
 	len = (loff_t)(vma->vm_end - vma->vm_start) +
Quoted 6 lines

_

The semantics (and usage!) of the VM_foo flags are rather vague. It needs definiton, and an audit.

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Discontig-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/discontig-devel