mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] pipe: cache 2 pages instead of 1
Date: Thu, 27 Feb 2025 22:58:34 +0100	[thread overview]
Message-ID: <20250227215834.GE25639@redhat.com> (raw)
In-Reply-To: <20250227180407.111787-1-mjguzik@gmail.com>

I already had a lot of beer, can't read this patch, just one nit...

On 02/27, Mateusz Guzik wrote:
>
> User data is kept in a circular buffer backed by pages allocated as
> needed. Only having space for one spare is still prone to having to
> resort to allocation / freeing.
>
> In my testing this decreases page allocs by 60% during a -j 20 kernel
> build.

So this is performance improvement?

> +static struct page *anon_pipe_get_page(struct pipe_inode_info *pipe)
> +{
> +	struct page *page;
> +
> +	if (pipe->tmp_page[0]) {
> +		page = pipe->tmp_page[0];
> +		pipe->tmp_page[0] = NULL;
> +	} else if (pipe->tmp_page[1]) {
> +		page = pipe->tmp_page[1];
> +		pipe->tmp_page[1] = NULL;
> +	} else {
> +		page = alloc_page(GFP_HIGHUSER | __GFP_ACCOUNT);
> +	}
> +
> +	return page;
> +}

Perhaps something like

	for (i = 0; i < ARRAY_SIZE(pipe->tmp_page); i++) {
		if (pipe->tmp_page[i]) {
			struct page *page = pipe->tmp_page[i];
			pipe->tmp_page[i] = NULL;
			return page;
		}
	}

	return alloc_page(GFP_HIGHUSER | __GFP_ACCOUNT);
?

Same for anon_pipe_put_page() and free_pipe_info().

This avoids the code duplication and allows to change the size of
pipe->tmp_page[] array without other changes.

Oleg.


  reply	other threads:[~2025-02-27 21:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 18:04 Mateusz Guzik
2025-02-27 21:58 ` Oleg Nesterov [this message]
2025-02-27 22:07   ` Mateusz Guzik
2025-02-28 10:16     ` Christian Brauner

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=20250227215834.GE25639@redhat.com \
    --to=oleg@redhat.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®