🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13156

Re: [PATCH net-next] ptp: ocp: replace __get_free_page() with kmalloc()

#13156
From: Vadim Fedorenko
Date: Mon, 09 Nov 2026 12:12
77 lines
10861 bytes
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>
Technical Details
Message-ID: <b2d2255f-c9f4-4c94-a739-b80f9bc49323@linux.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359261-linux-kernel-netdev=dewy.ru
References: <20261108-b4-ptp-v1-1-71160700886f@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359261-linux-kernel-netdev=dewy.ru
From: vadim.fedorenko@linux.dev (Vadim Fedorenko)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] ptp: ocp: replace __get_free_page() with
 kmalloc()
Date: Mon, 9 Nov 2026 12:12:47 +0000
Organization: Usenet Network
Message-ID: <b2d2255f-c9f4-4c94-a739-b80f9bc49323@linux.dev>
References: <20261108-b4-ptp-v1-1-71160700886f@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="348216"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:eqnK/KV2occ8JlQxCgmIOxZ48ns= sha256:y1A3DGiOk3A4v6tyV6bmEFIXY8+y2tw/HL+vGGke09Q=
	sha1:tmRnUo6bducoPMESfPQ8rjuUR3o= sha256:WV7FwZu30QPMGStGJ7CQlAid987R4HqcluuiKmJV2fg=
Content-Language: en-US
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 0B7381137C0; Mon,  9 Nov 2026 15:14:56 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id mAnGdrC7U2fT;
	Mon,  9 Nov 2026 15:14:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359261-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 341991137BC; Mon,  9 Nov 2026 15:14:42 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id C64D31013E0; Mon,  9 Nov 2026 12:12:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794226373;
	b=Je26x4dEnzKO/dBcVORnl6oV7fXEdGB3cn7qAHURmIKQnZmGxA482A5+1schxro4LJzE
	 fX4eg8TNL47YRLnmcoWPOtvV7lmpvstAHZpYSQF7EFK/W2Tuf099r6hx4aNPNG3mALnwR
	 bbO1Q/nZgu2NWnkTwwJ6+Ms4TgNuAa3/+0xnM+T464/b9ZzGgqX7pys7uhYOc0mkZWyxK
	 VtJ0bp8+UhzNEiWGGQnppmbXibtYK+btVdBsgYixoLNQVqIbIqtLiNtGj9Fr8OBm4RXD4
	 4ni7wA8PoNgZMt3mPHpDbtsfGc0lyuO/L3pxbob3DEVcBLD9nTaBVfV04lCVricCEYg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794226373;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent:
	 Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=dYz5XasKnN4TugzUWfM3/cMdAY/x2jzfHlfhQ+galWM=;
	b=hltGRCBEEXuYruHuZRgQEDsFrxQb9pUKpQSOxkUcrsf/bDXN2/M+xAwPXeamMudQCGBt
	 ZTPimoaqc9DEhnGJhAWFVqGPEaDOqiUlE61/jqV/eooP27/3BCpKla0jzPMn093xsm2/t
	 DHS4W33w3ASOc6gPNXN1RFSvKwBGDvzwQp6M/fseCV/pM03ReXOMSE9n3KQIW1EfYlVfO
	 VdPuQ9skMWxRS1zV5QwncCJO3al8up3qvR83bQ+wZYqMUhtNLyktSn4sEc0ypnFrHDhIe
	 UtlTdMekpIgRoVclyq79dC7VhSAbOuCx3jP8ncpqq0tPnyzswpzS9gH30fwHR8W+3gQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ZHCnSDpN;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EF64606A332;
	Mon,  9 Nov 2026 12:12:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ZHCnSDpN
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.170
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794226372;
	b=dcdrfs/kyDF+3WhAkhcIO7WZwhyoyQbOBiVTQ5/kgmAC7HIS6NPhjM4X649lRnT7pNlh
	 swTt+33zSUJFzBAKcE3vSmnVAeYpswjnOjUQWIVOd+SFXO7oBJOFygI8iavMBhdH2BHIF
	 a+Hap6SKeASfuHnImZEhmb8GddAlZ8XwJ58MqqwLufB3pVIPrj+mM5X9e7BeL9pT7NDek
	 BLlU+VhG06KwXEKpdgdFL9zJuHFupPjvqfcwtvgmEdYRTAKBNBCdGOEpt3AqgdnJDSH0i
	 PQuSasqgXw3/3hZ5zeEkc34Mipkpe5G1vDzVVd8P+ToKG0GPOOjnJXOrCgFQ2+rbhEg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794226372;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent:
	 Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=dYz5XasKnN4TugzUWfM3/cMdAY/x2jzfHlfhQ+galWM=;
	b=AZxEp+DPD+unjDrVytiuPyfyBvJMemWyLvK4BJqJn3xYttwReJxT5zXbA8nRWayUfKwm
	 MNkWkySKjhwtXv4pDh99TNxm84NXp+ErxmvCdjf6JIPRg0/kAy0LF8zwZiCT7cy44mV1M
	 y4vAb4Np1XeHzTZVvSnQHuwsNaAAHSf+RXdr6JWIqjJWU2ViZJbVp9bUtJ+vKH15b60Cn
	 RArV20zMly9o/0KdhCSBwflHEMVrYUmfo7/Hyc1QoqRkmXidzfC9PFDPA9xpGMGqzwUef
	 YqLvqrlmmtwrkzRQY+/+vI/nQqScOOtmGHNB5J7OkglfbwPMCo1gp9fKMcOkkwUuD6g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ZHCnSDpN;
	arc=none smtp.remote-ip=91.218.175.170
X-Received: from mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DC2606A31C
	for <netdev@vger.kernel.org>; Mon,  9 Nov 2026 12:12:50 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 86DC2606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=OUZK1hzYgJtzU4nG/ylLO2w+RnFmaiBPq0yD7tkY4Ik=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1794226368; v=1; x=1794831168;
 b=ZHCnSDpNkPq3NM5T6edR1zp/xB7qZJSfbdE8sV6x9s6+F6gMapAVhQb8vrotPpnBD7QpADkY
 WTDu/1vlU/NAeAbMgHSb/JWlgZKrNLoD5WgTPisGLTBOMXWXkGpqqnnIybhgzxReRESxBteMwZa
 yFsNK1ZMXAJwN7gJ12G0ML2c=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 84c5a36d145168ef;
	Mon, 09 Nov 2026 12:12:47 +0000
X-Mizu-Trace-ID: 84c5a36d145168ef
X-Migadu-Flow: FLOW_OUT
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Cc: David Hildenbrand <david@kernel.org>, Vlastimil Babka
 <vbabka@kernel.org>, linux-mm@kvack.org, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261108-b4-ptp-v1-1-71160700886f@kernel.org>