From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: "Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Richard Cochran <richardcochran@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: David Hildenbrand <david@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>,
linux-mm@kvack.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] ptp: ocp: replace __get_free_page() with kmalloc()
Date: Mon, 9 Nov 2026 12:12:47 +0000 [thread overview]
Message-ID: <b2d2255f-c9f4-4c94-a739-b80f9bc49323@linux.dev> (raw)
In-Reply-To: <20261108-b4-ptp-v1-1-71160700886f@kernel.org>
On 08/11/2026 08:40, Mike Rapoport (Microsoft) wrote:
> ptp_ocp_summary_show() allocates a temporary buffer for formatting
> PTP OCP device summary information.
>
> This buffer can be allocated with kmalloc() as there's nothing special
> about it to go directly to the page allocator.
>
> kmalloc() provides a better API that does not require ugly casts and
> kfree() does not need to know the size of the freed object.
>
> Performance difference between kmalloc() and __get_free_pages() is not
> measurable as both allocators take an object/page from a per-CPU list for
> fast path allocations.
>
> For the slow path the performance is anyway determined by the amount of
> reclaim involved rather than by what allocator is used.
>
> Replace use of __get_free_page() with kmalloc() and free_page() with
> kfree().
>
> Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> This is a (small) part of larger work of replacing page allocator calls
> with kmalloc.
>
> Largely, anything that doesn't need struct page (or a memdesc in the
> future) should just use kmalloc() or kvmalloc() to allocate memory.
> Removing needless calls to page allocator helps with memdesc (aka project
> folio) conversion and gives a nicer API without casts.
> ---
> drivers/ptp/ptp_ocp.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 625a85b2dc7e5..decc56892059b 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -18,6 +18,7 @@
> #include <linux/spi/spi.h>
> #include <linux/spi/xilinx_spi.h>
> #include <linux/spi/altera.h>
> +#include <linux/slab.h>
> #include <net/devlink.h>
> #include <linux/i2c.h>
> #include <linux/iopoll.h>
> @@ -5281,7 +5282,7 @@ ptp_ocp_summary_show(struct seq_file *s, void *data)
> bool on, map;
> int i;
>
> - buf = (char *)__get_free_page(GFP_KERNEL);
> + buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
> if (!buf)
> return -ENOMEM;
>
> @@ -5497,7 +5498,7 @@ ptp_ocp_summary_show(struct seq_file *s, void *data)
> post_ns - pre_ns);
> }
>
> - free_page((unsigned long)buf);
> + kfree(buf);
> return 0;
> }
> DEFINE_SHOW_ATTRIBUTE(ptp_ocp_summary);
>
> ---
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> change-id: 20260624-b4-ptp-ed56a38a6afd
>
> --
> Sincerely yours,
> Mike.
>
Thanks,
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
next prev parent reply other threads:[~2026-11-09 12:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 8:40 [PATCH net-next] ptp: ocp: replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-11-09 12:12 ` Vadim Fedorenko [this message]
2026-11-12 2:00 ` patchwork-bot+netdevbpf
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=b2d2255f-c9f4-4c94-a739-b80f9bc49323@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=david@kernel.org \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=rppt@kernel.org \
--cc=vbabka@kernel.org \
/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.