linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: linux-fsdevel <linux-fsdevel@vger.kernel.org>
Cc: David Howells <dhowells@redhat.com>, Lukas Schauer <lukas@schauer.dev>
Subject: [RFC PATCH 1/2] watch_queue: Fix pipe buffer allocation
Date: Fri, 14 Feb 2025 09:37:11 -0600	[thread overview]
Message-ID: <a9168241-1d8e-4e35-9594-f878a31eb8a9@redhat.com> (raw)
In-Reply-To: <b34d5d5f-f936-4781-82d3-6a69fdec9b61@redhat.com>

It seems that watch_queue_set_size() calls pipe_resize_ring() with the
number of notifications in play, not the number of pages required to
hold those notifications, as pipe_resize_ring() expects. Change from
nr_notes to nr_pages to fix this.

Fixes: c73be61cede58 ("pipe: Add general notification queue support")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index 5267adeaa403..10b4d311e930 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -254,6 +254,8 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
 
 	nr_pages = (nr_notes + WATCH_QUEUE_NOTES_PER_PAGE - 1);
 	nr_pages /= WATCH_QUEUE_NOTES_PER_PAGE;
+	/* Round nr_notes up to fill the pages */
+	nr_notes = nr_pages * WATCH_QUEUE_NOTES_PER_PAGE;
 	user_bufs = account_pipe_buffers(pipe->user, pipe->nr_accounted, nr_pages);
 
 	if (nr_pages > pipe->max_usage &&
@@ -264,8 +266,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
 		goto error;
 	}
 
-	nr_notes = nr_pages * WATCH_QUEUE_NOTES_PER_PAGE;
-	ret = pipe_resize_ring(pipe, roundup_pow_of_two(nr_notes));
+	ret = pipe_resize_ring(pipe, nr_pages);
 	if (ret < 0)
 		goto error;
 


  reply	other threads:[~2025-02-14 15:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14 15:34 [RFC PATCH 0/2] watch_queue: Fix pipe allocation and accounting Eric Sandeen
2025-02-14 15:37 ` Eric Sandeen [this message]
2025-02-14 15:38 ` [RFC PATCH 2/2] watch_queue: Fix pipe accounting Eric Sandeen
2025-02-14 16:28 ` [RFC PATCH 0/2] watch_queue: Fix pipe allocation and accounting Eric Sandeen
2025-02-14 16:49 ` [RFC PATCH 2/2] watch_queue: Fix pipe accounting David Howells
2025-02-14 16:58   ` Eric Sandeen
2025-02-14 17:36     ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9168241-1d8e-4e35-9594-f878a31eb8a9@redhat.com \
    --to=sandeen@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=lukas@schauer.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).