Re: [PATCH] watch_queue: use page_private() accessors

From: Bradley Morgan

Date: Tue Nov 24 2026 - 02:45:54 EST


On 24 November 2026 03:37:40 GMT, Nilay Vaish <nilayvaish@xxxxxxxxxx>
wrote:
>watch_queue records the number of the first note of each buffer page in
>page->private, reading and writing the field directly.
>
>struct page is being shrunk as part of the memdesc work, and its private
>field is one of those that will move. Direct users have to go through
>the accessors before that can happen.
>
>Use page_private() and set_page_private() instead, like the rest of the
>kernel, so that the code no longer depends on where struct page keeps
>the field.
>
>No functional change.

Cool!

I like this, makes sense.


Reviewed-by: Bradley Morgan <bradley.morgan@xxxxxxxxx>


>
>Signed-off-by: Nilay Vaish <nilayvaish@xxxxxxxxxx>
>---
>
>Notes:
> This patch was written with the help of an AI coding assistant (Gemini).
>
> Based on next-20261123.
>
> kernel/watch_queue.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
>index e2bdd5fb0db1..eeb7fb9bc0fd 100644
>--- a/kernel/watch_queue.c
>+++ b/kernel/watch_queue.c
>@@ -71,7 +71,7 @@ static void watch_queue_pipe_buf_release(struct pipe_inode_info *pipe,
> bit /= WATCH_QUEUE_NOTE_SIZE;
>
> page = buf->page;
>- bit += page->private;
>+ bit += page_private(page);
>
> set_bit(bit, wqueue->notes_bitmap);
> generic_pipe_buf_release(pipe, buf);
>@@ -284,7 +284,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
> pages[i] = alloc_page(GFP_KERNEL);
> if (!pages[i])
> goto error_p;
>- pages[i]->private = i * WATCH_QUEUE_NOTES_PER_PAGE;
>+ set_page_private(pages[i], i * WATCH_QUEUE_NOTES_PER_PAGE);
> }
>
> bitmap = bitmap_alloc(nr_notes, GFP_KERNEL);
>
>base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5
>prerequisite-patch-id: d52d42a2ec9ddc2b12b3412ec0d07254b417e60f
>prerequisite-patch-id: d8338f943ba7ae297eefbb26dabc3bcfe7994461
>prerequisite-patch-id: 3d99b53c242296b89d7f7b41f1995188f5a02369
>

--- Thanks!