s390/gmap: return proper error code on ksm unsharing
PATCH 1/1 s390/gmap: return proper error code on ksm unsharing
If a signal is pending we might return -ENOMEM instead of -EINTR. We should propagate the proper error during KSM unsharing.
--- arch/s390/mm/gmap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/s390/mm/gmap.c +6 -5
@@ -2552,15 +2552,16 @@ int gmap_mark_unmergeable(void) {struct mm_struct *mm = current->mm;struct vm_area_struct *vma; +int ret =0 ;for (vma = mm->mmap; vma; vma = vma->vm_next) { -if (ksm_madvise (vma, vma->vm_start, vma->vm_end, -MADV_UNMERGEABLE , &vma->vm_flags)) { -return -ENOMEM ; - } + ret =ksm_madvise (vma, vma->vm_start, vma->vm_end, +MADV_UNMERGEABLE , &vma->vm_flags); +if (ret) +return ret; } mm->def_flags &= ~VM_MERGEABLE ; -return 0 ; +return ret; }EXPORT_SYMBOL_GPL (gmap_mark_unmergeable);
Signature · 1 line
2.25.1
Quoted 14 lines · Christian Borntraeger
If a signal is pending we might return
-ENOMEMinstead of-EINTR. We should propagate the proper error during KSM unsharing.Fixes 3ac8e38015d4 ("s390/mm: disable KSM for storage key enabled pages")Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/mm/gmap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)arch/s390/mm/gmap.c +0
-0
arch/s390/mm/gmap.c int gmap_mark_unmergeable(void) · line 2556
Quoted 5 lines
arch/s390/mm/gmap.c +1
-0@@ -2552,15 +2552,16 @@ int gmap_mark_unmergeable(void) {struct mm_struct *mm = current->mm;struct vm_area_struct *vma; +int ret =0 ;
extra whitespace
Quoted 17 lines
arch/s390/mm/gmap.c +5
-5for (vma = mm->mmap; vma; vma = vma->vm_next) { -if (ksm_madvise (vma, vma->vm_start, vma->vm_end, -MADV_UNMERGEABLE , &vma->vm_flags)) { -return -ENOMEM ; - } + ret =ksm_madvise (vma, vma->vm_start, vma->vm_end, +MADV_UNMERGEABLE , &vma->vm_flags); +if (ret) +return ret; } mm->def_flags &= ~VM_MERGEABLE ; -return 0 ; +return ret; }EXPORT_SYMBOL_GPL (gmap_mark_unmergeable);
Quoted 22 lines · Christian Borntraeger
If a signal is pending we might return
-ENOMEMinstead of-EINTR. We should propagate the proper error during KSM unsharing.Fixes 3ac8e38015d4 ("s390/mm: disable KSM for storage key enabled pages")Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/mm/gmap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)arch/s390/mm/gmap.c +1
-2@@ -2552,15 +2552,16 @@ int gmap_mark_unmergeable(void) {struct mm_struct *mm = current->mm;struct vm_area_struct *vma; +int ret =0 ;for (vma = mm->mmap; vma; vma = vma->vm_next) { -if (ksm_madvise (vma, vma->vm_start, vma->vm_end, -MADV_UNMERGEABLE , &vma->vm_flags)) {
arch/s390/mm/gmap.c int gmap_mark_unmergeable(void) · line 2564
Quoted 10 lines
arch/s390/mm/gmap.c +5
-3-return -ENOMEM ; - } + ret =ksm_madvise (vma, vma->vm_start, vma->vm_end, +MADV_UNMERGEABLE , &vma->vm_flags); +if (ret) +return ret; } mm->def_flags &= ~VM_MERGEABLE ; -return 0 ; +return ret;
How can this ever be !0 ?
Also, once removed, no need to initialize ret to 0.
Quoted 4 lines
arch/s390/mm/gmap.c +0
-0}EXPORT_SYMBOL_GPL (gmap_mark_unmergeable);
Signature · 3 lines
Thanks, David / dhildenb
Quoted 36 lines · David Hildenbrand
Quoted 22 lines · Christian Borntraeger
If a signal is pending we might return
-ENOMEMinstead of-EINTR. We should propagate the proper error during KSM unsharing.Fixes 3ac8e38015d4 ("s390/mm: disable KSM for storage key enabled pages")Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/mm/gmap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)arch/s390/mm/gmap.c +1
-2@@ -2552,15 +2552,16 @@ int gmap_mark_unmergeable(void) {struct mm_struct *mm = current->mm;struct vm_area_struct *vma; +int ret =0 ;for (vma = mm->mmap; vma; vma = vma->vm_next) { -if (ksm_madvise (vma, vma->vm_start, vma->vm_end, -MADV_UNMERGEABLE , &vma->vm_flags)) {arch/s390/mm/gmap.c int gmap_mark_unmergeable(void) · line 2564
Quoted 10 lines
arch/s390/mm/gmap.c +5
-3-return -ENOMEM ; - } + ret =ksm_madvise (vma, vma->vm_start, vma->vm_end, +MADV_UNMERGEABLE , &vma->vm_flags); +if (ret) +return ret; } mm->def_flags &= ~VM_MERGEABLE ; -return 0 ; +return ret;How can this ever be !0 ?
Quoted 1 line
Also, once removed, no need to initialize ret to 0.
Right, I can make the patch smaller by keeping the return 0;
Quoted 7 lines
Quoted 5 lines
arch/s390/mm/gmap.c +0
-0}EXPORT_SYMBOL_GPL (gmap_mark_unmergeable);
Quoted 5 lines · Christian Borntraeger
If a signal is pending we might return
-ENOMEMinstead of-EINTR. We should propagate the proper error during KSM unsharing.Fixes 3ac8e38015d4 ("s390/mm: disable KSM for storage key enabled pages")Signed-off-by Christian Borntraeger <[email protected]>
Quoted 17 lines
--- arch/s390/mm/gmap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)arch/s390/mm/gmap.c +1
-2@@ -2552,15 +2552,16 @@ int gmap_mark_unmergeable(void) {struct mm_struct *mm = current->mm;struct vm_area_struct *vma; +int ret =0 ;for (vma = mm->mmap; vma; vma = vma->vm_next) { -if (ksm_madvise (vma, vma->vm_start, vma->vm_end, -MADV_UNMERGEABLE , &vma->vm_flags)) {
arch/s390/mm/gmap.c int gmap_mark_unmergeable(void) · line 2564
Quoted 10 lines
arch/s390/mm/gmap.c +5
-3-return -ENOMEM ; - } + ret =ksm_madvise (vma, vma->vm_start, vma->vm_end, +MADV_UNMERGEABLE , &vma->vm_flags); +if (ret) +return ret; } mm->def_flags &= ~VM_MERGEABLE ; -return 0 ; +return ret;
That part is not really necessary but also doesn't hurt.
Quoted 3 lines
arch/s390/mm/gmap.c +0
-0}EXPORT_SYMBOL_GPL (gmap_mark_unmergeable);