public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: John Ousterhout <ouster@cs.stanford.edu>
Cc: horms@kernel.org, netdev@vger.kernel.org, kuba@kernel.org,
	edumazet@google.com
Subject: Re: [net-next,v17,08/14] net: homa: create homa_rpc.h and homa_rpc.c
Date: Tue, 24 Mar 2026 09:55:18 +0100	[thread overview]
Message-ID: <6fb603dd-7bc2-4b60-bf93-7247d05f3250@redhat.com> (raw)
In-Reply-To: <CAGXJAmy7=A+Jc+iJ6jwddWs6x0z4pOudRs31Q41m9HMZ4yTWnw@mail.gmail.com>

On 3/23/26 11:43 PM, John Ousterhout wrote:
> On Wed, Mar 18, 2026 at 12:21 AM Paolo Abeni <pabeni@redhat.com> wrote:
>> This approach would allow lockless RCU lookups and faster reclamation. Paolo
>> referenced tcp established socket lookup as an example:
>>
>>   "Have a look at tcp established socket lookup and the SLAB_TYPESAFE_BY_RCU
>>    flag usage for slab-based allocations. A combo of such flag for RPC
>>    allocation (using a dedicated kmem_cache) and RCU lookup should improve
>>    consistently the performances, with a consolidate code layout and no
>>    unmanageable problems with large number of objects waiting for the grace
>>    period."
>>
>> The current code still uses plain kzalloc/kfree without a dedicated cache.
>> Would it make sense to implement this optimization?
>>
>> Reference: https://lore.kernel.org/netdev/9209dfbb-ca3a-4fb7-a2fb-0567394f8cda@redhat.com/
> 
> I tried using a kmem_cache, but it made performance slightly worse:
> average allocation time for a struct homa_rpc increased from about 380
> cycles to about 400 cycles in my benchmarks. Since there is no
> performance advantage to using kmem_cache I removed it.

So kzalloc/kfree is faster than kmem_cache?!? That is quite unexpected,
possibly the kmem_cache pointer ends up on a contended cacheline?!? I
guess it would be useful to understand the extra overhead, as kmalloc is
basically another layer on top of kmem_cache.

> I'm surprised how long allocation takes: 400 cycles seems like a *lot*
> if there are per-cpu caches of the right size. Presumably no
> synchronization is needed and all the function has to do in the normal
> case is pull the top entry off a list.
> 
>>
>>> +     if (!srpc) {
>>> +             err = -ENOMEM;
>>> +             goto error;
>>> +     }
>>
>> [ ... ]
>>
>>> +error:
>>> +     homa_bucket_unlock(bucket, id);
>>> +     if (srpc && srpc->peer)
>>> +             homa_peer_release(srpc->peer);
>>> +     kfree(srpc);
>>> +     return ERR_PTR(err);
>>> +}
>>
>> [ ... ]
>>
>> In the v6 review thread, Paolo and Eric raised concerns about SKB freeing
>> costs and suggested optimizations. Eric noted that proper software GRO
>> significantly reduces SKB count using napi_get_frags() and napi_reuse_skb().
> 
> Unfortunately napi_reuse_skb is not currently exported. My
> understanding is that I need to wait until Homa GRO is upstreamed
> before I can request that it be exported. Once that happens I'll be
> happy to use napi_reuse_skb.

Ok

>> Paolo also suggested using deferred SKB freeing (skb_attempt_defer_free) to
>> reduce the cost. While you mentioned that GRO is implemented in the full
>> Homa but was left out of the initial patch series, would it be beneficial to
>> include at least some of these optimizations in this initial submission?
>>
>> Reference: https://lore.kernel.org/netdev/9209dfbb-ca3a-4fb7-a2fb-0567394f8cda@redhat.com/
> 
> When I asked ChatGPT about homa_attempt_defer_free it said that it
> only works if the skb has no dst, no destructor, and no skb_nfct. I'm
> a bit unsure how to proceed. Is homa_attempt_defer_free only intended
> for incoming packets? If so, then presumably there is no dst? But what
> about the other fields? Do I need to do something to clean them up
> before calling homa_attempt_defer_free?
skb_attempt_defer_free() usage is intended for the RX path only.

Incoming packets get state (dst, extensions, ct...) attached in the rx
path before reaching the socket. You should free/release the state, if
possible, before inserting the skb into the receive queue, so that you
could defer free them after read.

/P


  reply	other threads:[~2026-03-24  8:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 22:32 [PATCH net-next v17 00/14] Begin upstreaming Homa transport protocol John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 01/14] net: homa: define user-visible API for Homa John Ousterhout
2026-03-17 10:10   ` kernel test robot
2026-03-17 18:40   ` kernel test robot
2026-03-16 22:32 ` [PATCH net-next v17 02/14] net: homa: create homa_wire.h John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 03/14] net: homa: create shared Homa header files John Ousterhout
2026-03-18  7:20   ` [net-next,v17,03/14] " Paolo Abeni
2026-03-19 20:37     ` John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 04/14] net: homa: create homa_pool.h and homa_pool.c John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 05/14] net: homa: create homa_peer.h and homa_peer.c John Ousterhout
2026-03-18  7:21   ` [net-next,v17,05/14] " Paolo Abeni
2026-03-20 17:13     ` John Ousterhout
2026-03-20 17:20       ` Paolo Abeni
2026-03-16 22:32 ` [PATCH net-next v17 06/14] net: homa: create homa_sock.h and homa_sock.c John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 07/14] net: homa: create homa_interest.h and homa_interest.c John Ousterhout
2026-03-18  7:21   ` [net-next,v17,07/14] " Paolo Abeni
2026-03-16 22:32 ` [PATCH net-next v17 08/14] net: homa: create homa_rpc.h and homa_rpc.c John Ousterhout
2026-03-18  7:21   ` [net-next,v17,08/14] " Paolo Abeni
2026-03-23 22:43     ` John Ousterhout
2026-03-24  8:55       ` Paolo Abeni [this message]
2026-03-16 22:32 ` [PATCH net-next v17 09/14] net: homa: create homa_outgoing.c John Ousterhout
2026-03-18  7:21   ` [net-next,v17,09/14] " Paolo Abeni
2026-03-20 18:21     ` John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 10/14] net: homa: create homa_utils.c John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 11/14] net: homa: create homa_incoming.c John Ousterhout
2026-03-18  7:21   ` [net-next,v17,11/14] " Paolo Abeni
2026-03-20 20:51     ` John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 12/14] net: homa: create homa_timer.c John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 13/14] net: homa: create homa_plumbing.c John Ousterhout
2026-03-18  7:21   ` [net-next,v17,13/14] " Paolo Abeni
2026-03-20 21:49     ` John Ousterhout
2026-03-16 22:32 ` [PATCH net-next v17 14/14] net: homa: create Makefile and Kconfig John Ousterhout
2026-03-17 18:51   ` kernel test robot
2026-03-17 19:26   ` kernel test robot

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=6fb603dd-7bc2-4b60-bf93-7247d05f3250@redhat.com \
    --to=pabeni@redhat.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ouster@cs.stanford.edu \
    /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