Re: [PATCH v17 03/14] shmem: Implement splice-read
From: David Howells
Date: Tue Mar 14 2023 - 17:51:10 EST
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> But please at least stop doing the
>
> get_page(buf->page);
>
> on the zero-page (which includes using no-op .get and .put functions
> in zero_pipe_buf_ops().
I'll make the attached change. It seems to work.
David
---
diff --git a/mm/shmem.c b/mm/shmem.c
index 3cbec1d56112..d9b60ab556fe 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2719,6 +2719,17 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
return retval ? retval : error;
}
+static bool zero_pipe_buf_get(struct pipe_inode_info *pipe,
+ struct pipe_buffer *buf)
+{
+ return true;
+}
+
+static void zero_pipe_buf_release(struct pipe_inode_info *pipe,
+ struct pipe_buffer *buf)
+{
+}
+
static bool zero_pipe_buf_try_steal(struct pipe_inode_info *pipe,
struct pipe_buffer *buf)
{
@@ -2726,9 +2737,9 @@ static bool zero_pipe_buf_try_steal(struct pipe_inode_info *pipe,
}
static const struct pipe_buf_operations zero_pipe_buf_ops = {
- .release = generic_pipe_buf_release,
+ .release = zero_pipe_buf_release,
.try_steal = zero_pipe_buf_try_steal,
- .get = generic_pipe_buf_get,
+ .get = zero_pipe_buf_get,
};
static size_t splice_zeropage_into_pipe(struct pipe_inode_info *pipe,