Skip to contentSkip to conversation

fs/io_uring.c: convert put_page() to put_user_page*()

PATCH In review [email protected] 4 participants 5 messages Aug 5, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/io_uring.c: convert put_page() to put_user_page*()

From: John Hubbard <[email protected]>

For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page() or release_pages().

This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions").

---
 fs/io_uring.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/io_uring.c +3 -5
index d542f1cf4428..8a1de5ab9c6d 100644
@@ -2815,7 +2815,7 @@ static int io_sqe_buffer_unregister(struct io_ring_ctx *ctx)
 		struct io_mapped_ubuf *imu = &ctx->user_bufs[i];
 
 		for (j = 0; j < imu->nr_bvecs; j++)
-			put_page(imu->bvec[j].bv_page);
+			put_user_page(imu->bvec[j].bv_page);
 
 		if (ctx->account_mem)
 			io_unaccount_mem(ctx->user, imu->nr_bvecs);
@@ -2959,10 +2959,8 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
 			 * if we did partial map, or found file backed vmas,
 			 * release any pages we did get
 			 */
-			if (pret > 0) {
-				for (j = 0; j < pret; j++)
-					put_page(pages[j]);
-			}
+			if (pret > 0)
+				put_user_pages(pages, pret);
 			if (ctx->account_mem)
 				io_unaccount_mem(ctx->user, nr_pages);
 			kvfree(imu->bvec);
Signature · 1 line
2.22.0
maintainer
#1 lore raw
Quoted 8 lines · On 8/4/19 7:32 PM, [email protected] wrote:

From: John Hubbard <[email protected]>

For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page() or release_pages().

This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions").

Applied for 5.4, thanks.

Signature · 1 line
Jens Axboe
#2 lore raw
In reply to [email protected]
Quoted 6 lines · On Sun, Aug 04, 2019 at 07:32:06PM -0700, [email protected] wrote:

From: John Hubbard <[email protected]>

For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page() or release_pages().

Quoted 8 lines

This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions").

Quoted 33 lines
---
 fs/io_uring.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/io_uring.c +3 -5
index d542f1cf4428..8a1de5ab9c6d 100644
@@ -2815,7 +2815,7 @@ static int io_sqe_buffer_unregister(struct io_ring_ctx *ctx)
 		struct io_mapped_ubuf *imu = &ctx->user_bufs[i];
 
 		for (j = 0; j < imu->nr_bvecs; j++)
-			put_page(imu->bvec[j].bv_page);
+			put_user_page(imu->bvec[j].bv_page);
 
 		if (ctx->account_mem)
 			io_unaccount_mem(ctx->user, imu->nr_bvecs);
@@ -2959,10 +2959,8 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
 			 * if we did partial map, or found file backed vmas,
 			 * release any pages we did get
 			 */
-			if (pret > 0) {
-				for (j = 0; j < pret; j++)
-					put_page(pages[j]);
-			}
+			if (pret > 0)
+				put_user_pages(pages, pret);
 			if (ctx->account_mem)
 				io_unaccount_mem(ctx->user, nr_pages);
 			kvfree(imu->bvec);
Signature · 1 line
2.22.0
Reviewed-by
#3 lore raw
Quoted 10 lines · Ira Weiny
Quoted 9 lines · On Sun, Aug 04, 2019 at 07:32:06PM -0700, [email protected] wrote:

From: John Hubbard <[email protected]>

For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page() or release_pages().

This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions").

Quoted 7 lines
Quoted 5 lines

<sigh>

I meant to say I wrote the same patch ... For this one...

Quoted 34 lines
Quoted 34 lines
---
 fs/io_uring.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/io_uring.c +3 -5
index d542f1cf4428..8a1de5ab9c6d 100644
@@ -2815,7 +2815,7 @@ static int io_sqe_buffer_unregister(struct io_ring_ctx *ctx)
 		struct io_mapped_ubuf *imu = &ctx->user_bufs[i];
 
 		for (j = 0; j < imu->nr_bvecs; j++)
-			put_page(imu->bvec[j].bv_page);
+			put_user_page(imu->bvec[j].bv_page);
 
 		if (ctx->account_mem)
 			io_unaccount_mem(ctx->user, imu->nr_bvecs);
@@ -2959,10 +2959,8 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
 			 * if we did partial map, or found file backed vmas,
 			 * release any pages we did get
 			 */
-			if (pret > 0) {
-				for (j = 0; j < pret; j++)
-					put_page(pages[j]);
-			}
+			if (pret > 0)
+				put_user_pages(pages, pret);
 			if (ctx->account_mem)
 				io_unaccount_mem(ctx->user, nr_pages);
 			kvfree(imu->bvec);
Signature · 1 line
2.22.0
#4 lore raw
Quoted 17 lines · Ira Weiny
Quoted 16 lines · Ira Weiny
Quoted 14 lines · On Sun, Aug 04, 2019 at 07:32:06PM -0700, [email protected] wrote:

From: John Hubbard <[email protected]>

For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page() or release_pages().

This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions").

Quoted 8 lines
Quoted 1 line

<sigh>

I meant to say I wrote the same patch ... For this one...

Hi Ira,

Say, in case you or anyone else is up for it: there are still about two thirds of the 34 patches that could use a reviewed-by, in this series:

https://lore.kernel.org/r/[email protected]

...and even reviewing one or two quick ones would help--no need to look at all of them, especially if several people each look at a few.

Also note that I'm keeping the gup_dma_core branch tracking the latest linux.git, and it seems to be working pretty well, aside from one warning that I haven't yet figured out (as per the latest commit):

[email protected]:johnhubbard/linux.git

thanks,

Signature · 2 lines
John Hubbard
NVIDIA