mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Haoran Wang <haoranwangsec@gmail.com>
Cc: David Laight <david.laight.linux@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rt-devel@lists.linux.dev, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, rostedt@goodmis.org
Subject: Re: [PATCH v4] libcxgb: use raw_cpu_ptr() in ppm_get_cpu_entries()
Date: Wed, 11 Nov 2026 13:17:57 +0100	[thread overview]
Message-ID: <20261111121757.021rVvhs@linutronix.de> (raw)
In-Reply-To: <20261110165742.1204-1-haoranwangsec@gmail.com>

On 2026-11-10 16:57:51 [+0800], Haoran Wang wrote:
> ppm_get_cpu_entries() must not acquire a sleeping lock while preemption
> is disabled: get_cpu() raises preempt_count and spin_lock_bh() may sleep

I would say "disables preemption" rather than "raises preempt_count".

> on PREEMPT_RT kernels.  Read the current CPU with raw_cpu_ptr() instead,
> which keeps the per-CPU accessor stable without disabling preemption.

That is not what is happening. raw_cpu_ptr() obtains the per-CPU
pointer of ppm->pool of the current CPU. I don't know what means
"accessor stable" and the following. Without disabled preemption the
scheduler can migrate the task to a different CPU. The access is still
stable but if the "locking" of the data structure is based on "the
data structure can only be accessed from the local CPU" then it is no
longer valid.

> Using the pool of a CPU the thread has since migrated away from is
> harmless: the per-CPU pools are shards of the global ppod index space,

ppod?

> and the free path ppm_unmark_entries() derives the owning pool from the
> index instead of from the running CPU, so any thread can service any
> shard.  Derive the global index base from pool->base so it always
> matches the pool that was locked.

The important part is that ppm_find_unused_entries() acquires slots
(read-modify-write operation on the structure) and it happens under the
lock therefore cross-CPU access does not matter. Does it always happen
under the lock? Then it is safe - otherwise it is not.

> Signed-off-by: Haoran Wang <haoranwangsec@gmail.com>
> 
> 
> thanks for the comments.  v4 below:
> 
> - pr_debug() now labels the pool's owner as "pool cpu" and also prints
>   the running CPU, so a thread servicing a foreign shard is visible in
>   the log.

Was this asked for? The pool CPU might be interesting to know so you
have which CPU's pool is serving the request. But the current CPU is
probably less useful.

The changes below look reasonable and I *think* it is unchanged from the
last time I looked at them

Please look at Documentation/process/maintainer-netdev.rst for the
subject prefix, fixes tag and "Resending after review".

Sebastian

  parent reply	other threads:[~2026-11-11 12:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 13:22 [PATCH] " Haoran Wang
2026-10-19 13:29 ` netdev-bot+sinfo
2026-10-19 13:29 ` Sebastian Andrzej Siewior
2026-10-20 13:22 ` sashiko-bot
2026-10-22  7:25 ` netdev-bot+sashiko
     [not found] ` <CANZ3JQQrrntu0TefPZC79pKSmsOfwAngRJyuaVm81DYaJNFHFQ@mail.gmail.com>
2026-11-09 10:07   ` [PATCH v3] " Haoran Wang
2026-11-09 10:11     ` netdev-bot+sinfo
2026-11-09 20:03     ` David Laight
2026-11-10  8:57       ` [PATCH v4] " Haoran Wang
2026-11-10  9:02         ` netdev-bot+sinfo
2026-11-11  8:58         ` sashiko-bot
2026-11-11 12:17         ` Sebastian Andrzej Siewior [this message]
2026-11-10 10:08     ` [PATCH v3] " sashiko-bot

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=20261111121757.021rVvhs@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=david.laight.linux@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=haoranwangsec@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rostedt@goodmis.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 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®