From: Sasha Levin Date: Mon, 6 Mar 2023 13:06:24 +0000 (-0500) Subject: Fix up backport of rdma-siw-fix-user-page-pinning-accounting.patch X-Git-Tag: v6.2.3~86^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=21d14ec566d7cb5861bde30876726122ce8d9480;p=thirdparty%2Fkernel%2Fstable-queue.git Fix up backport of rdma-siw-fix-user-page-pinning-accounting.patch --- diff --git a/queue-5.15/rdma-siw-fix-user-page-pinning-accounting.patch b/queue-5.15/rdma-siw-fix-user-page-pinning-accounting.patch index 7c9773f9e42..6b6ead70d28 100644 --- a/queue-5.15/rdma-siw-fix-user-page-pinning-accounting.patch +++ b/queue-5.15/rdma-siw-fix-user-page-pinning-accounting.patch @@ -1,4 +1,4 @@ -From bd3e40b047e7434cefcce43165bac16403389b0d Mon Sep 17 00:00:00 2001 +From 39ffffa04354c33bbc53e1e2d9d9755920746e5d Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 2 Feb 2023 11:10:00 +0100 Subject: RDMA/siw: Fix user page pinning accounting @@ -23,7 +23,7 @@ Signed-off-by: Sasha Levin 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_mem.c b/drivers/infiniband/sw/siw/siw_mem.c -index b2b33dd3b4fa1..f51ab2ccf1511 100644 +index 61c17db70d658..bf69566e2eb63 100644 --- a/drivers/infiniband/sw/siw/siw_mem.c +++ b/drivers/infiniband/sw/siw/siw_mem.c @@ -398,7 +398,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) @@ -35,7 +35,7 @@ index b2b33dd3b4fa1..f51ab2ccf1511 100644 rv = -ENOMEM; goto out_sem_up; } -@@ -411,30 +411,27 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) +@@ -411,18 +411,16 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) goto out_sem_up; } for (i = 0; num_pages; i++) { @@ -56,9 +56,10 @@ index b2b33dd3b4fa1..f51ab2ccf1511 100644 while (nents) { - struct page **plist = &umem->page_chunk[i].plist[got]; - - rv = pin_user_pages(first_page_va, nents, foll_flags, + rv = pin_user_pages(first_page_va, nents, + foll_flags | FOLL_LONGTERM, plist, NULL); - if (rv < 0) +@@ -430,12 +428,11 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) goto out_sem_up; umem->num_pages += rv; @@ -73,7 +74,7 @@ index b2b33dd3b4fa1..f51ab2ccf1511 100644 } out_sem_up: mmap_read_unlock(mm_s); -@@ -442,6 +439,10 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) +@@ -443,6 +440,10 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) if (rv > 0) return umem; diff --git a/queue-5.15/rdma-siw-remove-foll_force-usage.patch b/queue-5.15/rdma-siw-remove-foll_force-usage.patch deleted file mode 100644 index 96cd0ee3b40..00000000000 --- a/queue-5.15/rdma-siw-remove-foll_force-usage.patch +++ /dev/null @@ -1,68 +0,0 @@ -From dba305c6ba7aebc95f1023375438ad7d70353453 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Wed, 16 Nov 2022 11:26:51 +0100 -Subject: RDMA/siw: remove FOLL_FORCE usage - -From: David Hildenbrand - -[ Upstream commit 129e636fe9837fcfea68bfd368a07548d9880726 ] - -GUP now supports reliable R/O long-term pinning in COW mappings, such -that we break COW early. MAP_SHARED VMAs only use the shared zeropage so -far in one corner case (DAXFS file with holes), which can be ignored -because GUP does not support long-term pinning in fsdax (see -check_vma_flags()). - -Consequently, FOLL_FORCE | FOLL_WRITE | FOLL_LONGTERM is no longer required -for reliable R/O long-term pinning: FOLL_LONGTERM is sufficient. So stop -using FOLL_FORCE, which is really only for ptrace access. - -Link: https://lkml.kernel.org/r/20221116102659.70287-13-david@redhat.com -Signed-off-by: David Hildenbrand -Reviewed-by: Jason Gunthorpe -Cc: Bernard Metzler -Cc: Leon Romanovsky -Signed-off-by: Andrew Morton -Stable-dep-of: 65a8fc30fb67 ("RDMA/siw: Fix user page pinning accounting") -Signed-off-by: Sasha Levin ---- - drivers/infiniband/sw/siw/siw_mem.c | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/drivers/infiniband/sw/siw/siw_mem.c b/drivers/infiniband/sw/siw/siw_mem.c -index 61c17db70d658..b2b33dd3b4fa1 100644 ---- a/drivers/infiniband/sw/siw/siw_mem.c -+++ b/drivers/infiniband/sw/siw/siw_mem.c -@@ -368,7 +368,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) - struct mm_struct *mm_s; - u64 first_page_va; - unsigned long mlock_limit; -- unsigned int foll_flags = FOLL_WRITE; -+ unsigned int foll_flags = FOLL_LONGTERM; - int num_pages, num_chunks, i, rv = 0; - - if (!can_do_mlock()) -@@ -391,8 +391,8 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) - - mmgrab(mm_s); - -- if (!writable) -- foll_flags |= FOLL_FORCE; -+ if (writable) -+ foll_flags |= FOLL_WRITE; - - mmap_read_lock(mm_s); - -@@ -423,8 +423,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) - while (nents) { - struct page **plist = &umem->page_chunk[i].plist[got]; - -- rv = pin_user_pages(first_page_va, nents, -- foll_flags | FOLL_LONGTERM, -+ rv = pin_user_pages(first_page_va, nents, foll_flags, - plist, NULL); - if (rv < 0) - goto out_sem_up; --- -2.39.2 - diff --git a/queue-5.15/series b/queue-5.15/series index 7c9cd5b6c1e..1c70f3ba84a 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -321,8 +321,6 @@ usb-gadget-configfs-remove-using-list-iterator-after.patch usb-gadget-configfs-restrict-symlink-creation-is-udc.patch iommu-vt-d-set-no-execute-enable-bit-in-pasid-table-.patch power-supply-remove-faulty-cooling-logic.patch -rdma-siw-remove-foll_force-usage.patch -rdma-siw-fix-user-page-pinning-accounting.patch rdma-cxgb4-fix-potential-null-ptr-deref-in-pass_esta.patch usb-max-3421-fix-setting-of-i-o-pins.patch rdma-irdma-cap-msix-used-to-online-cpus-1.patch @@ -444,3 +442,4 @@ locking-rwsem-prevent-non-first-waiter-from-spinning-in-down_write-slowpath.patc ksmbd-fix-wrong-data-area-length-for-smb2-lock-request.patch ksmbd-do-not-allow-the-actual-frame-length-to-be-smaller-than-the-rfc1002-length.patch arm-dts-exynos-correct-hdmi-phy-compatible-in-exynos4.patch +rdma-siw-fix-user-page-pinning-accounting.patch diff --git a/queue-6.1/rdma-siw-fix-user-page-pinning-accounting.patch b/queue-6.1/rdma-siw-fix-user-page-pinning-accounting.patch index 69f4aff3c76..290fd41f29c 100644 --- a/queue-6.1/rdma-siw-fix-user-page-pinning-accounting.patch +++ b/queue-6.1/rdma-siw-fix-user-page-pinning-accounting.patch @@ -1,4 +1,4 @@ -From ef581c2bef34611eb7f5fc9cdbfb6c7041f1db11 Mon Sep 17 00:00:00 2001 +From 383e7bbc7f5b2a2a004a262505f5a342fbc8af55 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 2 Feb 2023 11:10:00 +0100 Subject: RDMA/siw: Fix user page pinning accounting @@ -23,7 +23,7 @@ Signed-off-by: Sasha Levin 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_mem.c b/drivers/infiniband/sw/siw/siw_mem.c -index b2b33dd3b4fa1..f51ab2ccf1511 100644 +index 61c17db70d658..bf69566e2eb63 100644 --- a/drivers/infiniband/sw/siw/siw_mem.c +++ b/drivers/infiniband/sw/siw/siw_mem.c @@ -398,7 +398,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) @@ -35,7 +35,7 @@ index b2b33dd3b4fa1..f51ab2ccf1511 100644 rv = -ENOMEM; goto out_sem_up; } -@@ -411,30 +411,27 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) +@@ -411,18 +411,16 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) goto out_sem_up; } for (i = 0; num_pages; i++) { @@ -56,9 +56,10 @@ index b2b33dd3b4fa1..f51ab2ccf1511 100644 while (nents) { - struct page **plist = &umem->page_chunk[i].plist[got]; - - rv = pin_user_pages(first_page_va, nents, foll_flags, + rv = pin_user_pages(first_page_va, nents, + foll_flags | FOLL_LONGTERM, plist, NULL); - if (rv < 0) +@@ -430,12 +428,11 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) goto out_sem_up; umem->num_pages += rv; @@ -73,7 +74,7 @@ index b2b33dd3b4fa1..f51ab2ccf1511 100644 } out_sem_up: mmap_read_unlock(mm_s); -@@ -442,6 +439,10 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) +@@ -443,6 +440,10 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) if (rv > 0) return umem; diff --git a/queue-6.1/rdma-siw-remove-foll_force-usage.patch b/queue-6.1/rdma-siw-remove-foll_force-usage.patch deleted file mode 100644 index 378ff3d927e..00000000000 --- a/queue-6.1/rdma-siw-remove-foll_force-usage.patch +++ /dev/null @@ -1,68 +0,0 @@ -From b23a5e3e2aa263bd4f85aef180f613d86e31b452 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Wed, 16 Nov 2022 11:26:51 +0100 -Subject: RDMA/siw: remove FOLL_FORCE usage - -From: David Hildenbrand - -[ Upstream commit 129e636fe9837fcfea68bfd368a07548d9880726 ] - -GUP now supports reliable R/O long-term pinning in COW mappings, such -that we break COW early. MAP_SHARED VMAs only use the shared zeropage so -far in one corner case (DAXFS file with holes), which can be ignored -because GUP does not support long-term pinning in fsdax (see -check_vma_flags()). - -Consequently, FOLL_FORCE | FOLL_WRITE | FOLL_LONGTERM is no longer required -for reliable R/O long-term pinning: FOLL_LONGTERM is sufficient. So stop -using FOLL_FORCE, which is really only for ptrace access. - -Link: https://lkml.kernel.org/r/20221116102659.70287-13-david@redhat.com -Signed-off-by: David Hildenbrand -Reviewed-by: Jason Gunthorpe -Cc: Bernard Metzler -Cc: Leon Romanovsky -Signed-off-by: Andrew Morton -Stable-dep-of: 65a8fc30fb67 ("RDMA/siw: Fix user page pinning accounting") -Signed-off-by: Sasha Levin ---- - drivers/infiniband/sw/siw/siw_mem.c | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/drivers/infiniband/sw/siw/siw_mem.c b/drivers/infiniband/sw/siw/siw_mem.c -index 61c17db70d658..b2b33dd3b4fa1 100644 ---- a/drivers/infiniband/sw/siw/siw_mem.c -+++ b/drivers/infiniband/sw/siw/siw_mem.c -@@ -368,7 +368,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) - struct mm_struct *mm_s; - u64 first_page_va; - unsigned long mlock_limit; -- unsigned int foll_flags = FOLL_WRITE; -+ unsigned int foll_flags = FOLL_LONGTERM; - int num_pages, num_chunks, i, rv = 0; - - if (!can_do_mlock()) -@@ -391,8 +391,8 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) - - mmgrab(mm_s); - -- if (!writable) -- foll_flags |= FOLL_FORCE; -+ if (writable) -+ foll_flags |= FOLL_WRITE; - - mmap_read_lock(mm_s); - -@@ -423,8 +423,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable) - while (nents) { - struct page **plist = &umem->page_chunk[i].plist[got]; - -- rv = pin_user_pages(first_page_va, nents, -- foll_flags | FOLL_LONGTERM, -+ rv = pin_user_pages(first_page_va, nents, foll_flags, - plist, NULL); - if (rv < 0) - goto out_sem_up; --- -2.39.2 - diff --git a/queue-6.1/series b/queue-6.1/series index 577d72f4f16..49121d5f2e6 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -461,8 +461,6 @@ iommu-dart-support-64-stream-ids.patch iommu-dart-fix-apple_dart_device_group-for-pci-group.patch iommu-vt-d-set-no-execute-enable-bit-in-pasid-table-.patch power-supply-remove-faulty-cooling-logic.patch -rdma-siw-remove-foll_force-usage.patch -rdma-siw-fix-user-page-pinning-accounting.patch rdma-cxgb4-fix-potential-null-ptr-deref-in-pass_esta.patch usb-max-3421-fix-setting-of-i-o-pins.patch rdma-irdma-cap-msix-used-to-online-cpus-1.patch @@ -690,3 +688,4 @@ ksmbd-fix-possible-memory-leak-in-smb2_lock.patch torture-fix-hang-during-kthread-shutdown-phase.patch arm-dts-exynos-correct-hdmi-phy-compatible-in-exynos4.patch io_uring-mark-task-task_running-before-handling-resume-task-work.patch +rdma-siw-fix-user-page-pinning-accounting.patch