Skip to content

Commit 5474760

Browse files
kudureranganathbrauner
authored andcommitted
kernel/watch_queue: Use pipe_buf() to retrieve the pipe buffer
Use pipe_buf() helper to retrieve the pipe buffer in post_one_notification() replacing the open-coded the logic. Suggested-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com> Link: https://lore.kernel.org/r/20250307052919.34542-3-kprateek.nayak@amd.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent cf3d0c5 commit 5474760

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

kernel/watch_queue.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,11 @@ static bool post_one_notification(struct watch_queue *wqueue,
101101
struct pipe_inode_info *pipe = wqueue->pipe;
102102
struct pipe_buffer *buf;
103103
struct page *page;
104-
unsigned int head, tail, mask, note, offset, len;
104+
unsigned int head, tail, note, offset, len;
105105
bool done = false;
106106

107107
spin_lock_irq(&pipe->rd_wait.lock);
108108

109-
mask = pipe->ring_size - 1;
110109
head = pipe->head;
111110
tail = pipe->tail;
112111
if (pipe_full(head, tail, pipe->ring_size))
@@ -124,7 +123,7 @@ static bool post_one_notification(struct watch_queue *wqueue,
124123
memcpy(p + offset, n, len);
125124
kunmap_atomic(p);
126125

127-
buf = &pipe->bufs[head & mask];
126+
buf = pipe_buf(pipe, head);
128127
buf->page = page;
129128
buf->private = (unsigned long)wqueue;
130129
buf->ops = &watch_queue_pipe_buf_ops;
@@ -147,7 +146,7 @@ static bool post_one_notification(struct watch_queue *wqueue,
147146
return done;
148147

149148
lost:
150-
buf = &pipe->bufs[(head - 1) & mask];
149+
buf = pipe_buf(pipe, head - 1);
151150
buf->flags |= PIPE_BUF_FLAG_LOSS;
152151
goto out;
153152
}

0 commit comments

Comments
 (0)