netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: John Ousterhout <ouster@cs.stanford.edu>
Cc: netdev@vger.kernel.org, edumazet@google.com, horms@kernel.org,
	kuba@kernel.org
Subject: Re: [PATCH net-next v6 04/12] net: homa: create homa_pool.h and homa_pool.c
Date: Mon, 27 Jan 2025 10:41:13 +0100	[thread overview]
Message-ID: <4e43078f-a41e-4953-9ee9-de579bd92914@redhat.com> (raw)
In-Reply-To: <CAGXJAmw95dDUxUFNa7UjV3XRd66vQRByAP5T_zra6KWdavr2Pg@mail.gmail.com>

On 1/25/25 12:53 AM, John Ousterhout wrote:
> On Thu, Jan 23, 2025 at 4:06 AM Paolo Abeni <pabeni@redhat.com> wrote:
> ...
>>> +     pool->descriptors = kmalloc_array(pool->num_bpages,
>>> +                                       sizeof(struct homa_bpage),
>>> +                                       GFP_ATOMIC);
>>
>> Possibly wort adding '| __GFP_ZERO' and avoid zeroing some fields later.
> 
> I prefer to do all the initialization explicitly (this makes it
> totally clear that a zero value is intended, as opposed to accidental
> omission of an initializer). If you still think I should use
> __GFP_ZERO, let me know and I'll add it.

Indeed the __GFP_ZERO flag is the preferred for such allocation, as it
at very least reduce the generated code size.

>>> +int homa_pool_get_pages(struct homa_pool *pool, int num_pages, __u32 *pages,
>>> +                     int set_owner)
>>> +{
>>> +     int core_num = raw_smp_processor_id();
>>
>> Why the 'raw' variant? If this code is pre-emptible it means another
>> process could be scheduled on the same core...
> 
> My understanding is that raw_smp_processor_id is faster.
> homa_pool_get_pages is invoked with a spinlock held, so there is no
> risk of a core switch while it is executing. Is there some other
> problem I have missed?

raw_* variants, alike __* ones, fall under the 'use at your own risk'
category.

In this specific case raw_smp_processor_id() is supposed to be used if
you don't care the process being move on other cores while using the
'id' value.

Using raw_smp_processor_id() and building with the CONFIG_DEBUG_PREEMPT
knob, the generated code will miss run-time check for preemption being
actually disabled at invocation time. Such check will be added while
using smp_processor_id(), with no performance cost for non debug build.

>>> +struct homa_bpage {
>>> +     union {
>>> +             /**
>>> +              * @cache_line: Ensures that each homa_bpage object
>>> +              * is exactly one cache line long.
>>> +              */
>>> +             char cache_line[L1_CACHE_BYTES];
>>> +             struct {
>>> +                     /** @lock: to synchronize shared access. */
>>> +                     spinlock_t lock;
>>> +
>>> +                     /**
>>> +                      * @refs: Counts number of distinct uses of this
>>> +                      * bpage (1 tick for each message that is using
>>> +                      * this page, plus an additional tick if the @owner
>>> +                      * field is set).
>>> +                      */
>>> +                     atomic_t refs;
>>> +
>>> +                     /**
>>> +                      * @owner: kernel core that currently owns this page
>>> +                      * (< 0 if none).
>>> +                      */
>>> +                     int owner;
>>> +
>>> +                     /**
>>> +                      * @expiration: time (in sched_clock() units) after
>>> +                      * which it's OK to steal this page from its current
>>> +                      * owner (if @refs is 1).
>>> +                      */
>>> +                     __u64 expiration;
>>> +             };
>>
>> ____cacheline_aligned instead of inserting the struct into an union
>> should suffice.
> 
> Done (but now that alloc_percpu_gfp is being used I'm not sure this is
> needed to ensure alignment?).

Yep, cacheline alignment should not be needed for percpu data.

/P


  parent reply	other threads:[~2025-01-27  9:41 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15 18:59 [PATCH net-next v6 00/12] Begin upstreaming Homa transport protocol John Ousterhout
2025-01-15 18:59 ` [PATCH net-next v6 01/12] net: homa: define user-visible API for Homa John Ousterhout
2025-01-15 18:59 ` [PATCH net-next v6 02/12] net: homa: create homa_wire.h John Ousterhout
2025-01-15 18:59 ` [PATCH net-next v6 03/12] net: homa: create shared Homa header files John Ousterhout
2025-01-23 11:01   ` Paolo Abeni
2025-01-24 21:21     ` John Ousterhout
2025-01-27  9:05       ` Paolo Abeni
2025-01-27 17:04         ` John Ousterhout
2025-01-15 18:59 ` [PATCH net-next v6 04/12] net: homa: create homa_pool.h and homa_pool.c John Ousterhout
2025-01-23 12:06   ` Paolo Abeni
2025-01-24 23:53     ` John Ousterhout
2025-01-25  0:46       ` Andrew Lunn
2025-01-26  5:33         ` John Ousterhout
2025-01-27  9:41       ` Paolo Abeni [this message]
2025-01-27 17:34         ` John Ousterhout
2025-01-27 18:28           ` Paolo Abeni
2025-01-27 19:12             ` John Ousterhout
2025-01-28  8:27               ` Paolo Abeni
2025-01-15 18:59 ` [PATCH net-next v6 05/12] net: homa: create homa_rpc.h and homa_rpc.c John Ousterhout
2025-01-23 14:29   ` Paolo Abeni
2025-01-27  5:22     ` John Ousterhout
2025-01-27 10:01       ` Paolo Abeni
2025-01-27 18:03         ` John Ousterhout
2025-01-28  8:19           ` Paolo Abeni
2025-01-29  1:23             ` John Ousterhout
     [not found]               ` <13345e2a-849d-4bd8-a95e-9cd7f287c7df@redhat.com>
2025-01-29 16:43                 ` John Ousterhout
2025-01-29 16:49                   ` Eric Dumazet
2025-01-29 16:54                     ` John Ousterhout
2025-01-29 17:04                       ` Eric Dumazet
2025-01-29 20:27                         ` John Ousterhout
2025-01-29 20:40                           ` Eric Dumazet
2025-01-29 21:08                             ` John Ousterhout
2025-01-15 18:59 ` [PATCH net-next v6 06/12] net: homa: create homa_peer.h and homa_peer.c John Ousterhout
2025-01-23 17:45   ` Paolo Abeni
2025-01-28  0:06     ` John Ousterhout
2025-01-28  0:32       ` Jason Xing
2025-01-15 18:59 ` [PATCH net-next v6 07/12] net: homa: create homa_sock.h and homa_sock.c John Ousterhout
2025-01-23 19:01   ` Paolo Abeni
2025-01-28  0:40     ` John Ousterhout
2025-01-28  4:26       ` John Ousterhout
2025-01-28 15:10       ` Eric Dumazet
2025-01-28 17:04         ` John Ousterhout
2025-01-24  7:33   ` Paolo Abeni
2025-01-15 18:59 ` [PATCH net-next v6 08/12] net: homa: create homa_incoming.c John Ousterhout
2025-01-24  8:31   ` Paolo Abeni
2025-01-30  0:41     ` John Ousterhout
     [not found]       ` <991b5ad9-57cf-4e1d-8e01-9d0639fa4e49@redhat.com>
2025-01-31 22:48         ` John Ousterhout
2025-02-03  9:12           ` Paolo Abeni
2025-02-03 23:33             ` John Ousterhout
2025-02-04  8:50               ` Paolo Abeni
2025-02-04 16:30                 ` John Ousterhout
2025-02-04 19:41                   ` Andrew Lunn
2025-02-04 21:20                     ` John Ousterhout
2025-01-27 10:19   ` Paolo Abeni
2025-01-30  0:48     ` John Ousterhout
2025-01-30  9:57       ` Paolo Abeni
2025-01-31 22:51         ` John Ousterhout
     [not found]         ` <CAGXJAmxLqnjnWr8sjooJRRyQ2-5BqPCQL8gnn0gzYoZ0MMoBSw@mail.gmail.com>
2025-02-03  9:17           ` Paolo Abeni
2025-02-03 17:33             ` John Ousterhout
2025-02-03 17:58               ` Andrew Lunn
2025-02-05 23:56                 ` John Ousterhout
2025-02-06  1:49                   ` Andrew Lunn
2025-01-15 18:59 ` [PATCH net-next v6 09/12] net: homa: create homa_outgoing.c John Ousterhout
2025-01-15 18:59 ` [PATCH net-next v6 10/12] net: homa: create homa_timer.c John Ousterhout
2025-01-15 18:59 ` [PATCH net-next v6 11/12] net: homa: create homa_plumbing.c and homa_utils.c John Ousterhout
2025-01-15 18:59 ` [PATCH net-next v6 12/12] net: homa: create Makefile and Kconfig John Ousterhout
2025-01-24  8:55 ` [PATCH net-next v6 00/12] Begin upstreaming Homa transport protocol Paolo Abeni
2025-02-10 19:19   ` John Ousterhout

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=4e43078f-a41e-4953-9ee9-de579bd92914@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;
as well as URLs for NNTP newsgroup(s).