All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: David Howells <dhowells@redhat.com>, Eric Sandeen <sandeen@redhat.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Lukas Schauer <lukas@schauer.dev>
Subject: Re: [RFC PATCH 2/2] watch_queue: Fix pipe accounting
Date: Fri, 14 Feb 2025 11:36:08 -0600	[thread overview]
Message-ID: <9dd45f32-e8a5-42bc-a9d7-d6dd9e351eea@sandeen.net> (raw)
In-Reply-To: <0a3f44cb-46f1-4ffe-ba8e-ce7f0cee1bc1@sandeen.net>

On 2/14/25 10:58 AM, Eric Sandeen wrote:
> On 2/14/25 10:49 AM, David Howells wrote:
>> Eric Sandeen <sandeen@redhat.com> wrote:
>>
>>> -	if (!pipe_has_watch_queue(pipe)) {
>>> -		pipe->max_usage = nr_slots;
>>> -		pipe->nr_accounted = nr_slots;
>>> -	}
>>> +	pipe->max_usage = nr_slots;
>>> +	pipe->nr_accounted = nr_slots;
>>
>> Hmmm...   The pipe ring is supposed to have some spare capacity when used as a
>> watch queue so that you can bung at least a few messages into it.
> 
> If the pipe has an original number of buffers on it, and
> then watch_queue_set_size adjusts that number - where does
> the spare capacity come from? Who adds it / where?

If that was resizing the ring to nr_notes not nr_pages, then ... I guess we
could keep the pipe_has_watch_queue() test as above, skip updating nr_accounted
there, and set it manually to the user-charged number in watch_queue_set_size()?

Something like this? I'm not sure about max_usage, maybe it should be set
as well.

diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index 5267adeaa403..07a161ecc8a8 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -269,6 +269,14 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
 	if (ret < 0)
 		goto error;
 
+	/*
+	 * pipe_resize_ring does not update nr_accounted for watch_queue pipes,
+	 * because the above vastly overprovisions. Set nr_accounted on
+	 * this pipe to the number that was charged to the user above
+	 * here manually.
+	 */
+	pipe->nr_accounted = nr_pages;
+
 	ret = -ENOMEM;
 	pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
 	if (!pages)




> Thanks,
> -Eric
> 
>> David
>>
>>
> 
> 


  reply	other threads:[~2025-02-14 17:36 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 ` [RFC PATCH 1/2] watch_queue: Fix pipe buffer allocation Eric Sandeen
2025-02-14 15:38 ` [RFC PATCH 2/2] watch_queue: Fix pipe accounting Eric Sandeen
2025-02-14 16:49   ` David Howells
2025-02-14 16:58     ` Eric Sandeen
2025-02-14 17:36       ` Eric Sandeen [this message]
2025-02-14 16:28 ` [RFC PATCH 0/2] watch_queue: Fix pipe allocation and accounting 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=9dd45f32-e8a5-42bc-a9d7-d6dd9e351eea@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=lukas@schauer.dev \
    --cc=sandeen@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.