🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14533

Re: [PATCH v4] libcxgb: use raw_cpu_ptr() in ppm_get_cpu_entries()

#14533
From: Sebastian Andrzej Siewior
Date: Wed, 11 Nov 2026 12:17
53 lines
11530 bytes
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
Technical Details
Message-ID: <20261111121757.021rVvhs@linutronix.de>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361048-linux-kernel-netdev=dewy.ru
References: <179241614797.5916.13928836073297916808@whr> <CANZ3JQQrrntu0TefPZC79pKSmsOfwAngRJyuaVm81DYaJNFHFQ@mail.gmail.com> <20261109180748.33682-1-haoranwangsec@gmail.com> <20261109200332.52e2fc0e@pumpkin> <20261110165742.1204-1-haoranwangsec@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361048-linux-kernel-netdev=dewy.ru
From: bigeasy@linutronix.de (Sebastian Andrzej Siewior)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v4] libcxgb: use raw_cpu_ptr() in ppm_get_cpu_entries()
Date: Wed, 11 Nov 2026 13:17:57 +0100
Organization: Usenet Network
Message-ID: <20261111121757.021rVvhs@linutronix.de>
References: <179241614797.5916.13928836073297916808@whr>
 <CANZ3JQQrrntu0TefPZC79pKSmsOfwAngRJyuaVm81DYaJNFHFQ@mail.gmail.com>
 <20261109180748.33682-1-haoranwangsec@gmail.com>
 <20261109200332.52e2fc0e@pumpkin>
 <20261110165742.1204-1-haoranwangsec@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="849192"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CsgFcavExxwmadLSVSLaXd6Dr1s= sha256:A7EAQR0feBwhpUG9N1aCzgvRC0JsQI+N3dQfgU9+t2A=
	sha1:isxGsc+REit905U5u2Ez3U30sYE= sha256:wGz1FHDg/FSs/ZAxSpHp+Nl8pa8oT/wCnQNYut3itAQ=
Content-Disposition: inline
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 A54B4113EDE; Wed, 11 Nov 2026 15:27:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 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, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=linutronix.de header.b=OX+h45CA; dkim=neutral
	reason="invalid (unsupported algorithm ed25519-sha256)"
	header.d=linutronix.de header.b=UuhFVMyk
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 KzZb8AYv6G-R;
	Wed, 11 Nov 2026 15:27:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-361048-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linutronix.de
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 2A50E113ED0; Wed, 11 Nov 2026 15:27:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 8003DE06AA; Wed, 11 Nov 2026 12:18:05 +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=1794399482;
	b=mFQ7MLUgKGn5rbWPe7p7iJSbs0FiEeecSTYRLflMfq7MX41uL53Sw5seV9MUCkbBJBim
	 4dsz11Wd1rmeY39Y1ESpgIQj1H3UgRCB0lpBHCu/wLsroVXhQb46g5LK9DELKQIwGFcAp
	 x1nn2Ssopwz+JB0xfeQubio2zH6lTeK9AGqGmDWL75GTTo2WcECyIhFNLtxizgkQUWpiL
	 2119GpQgi4MfzUUsYGG4Ul/IQ2CjC1hxWqZJ+X1bk/Npq2V7PydJrFT2LLJyR+Uc7KlXf
	 Mn3es7QjkrTCdp5xKSnPBwihxYZdQ4z9CkA2jEXdyVY1JGoSs/oXRvaqTRqFJrRNwtg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794399482;
	h=X-Original-To:Received:DMARC-Filter:Date:DKIM-Signature:
	 DKIM-Signature:From:To:Cc:Subject:Message-ID:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Disposition:In-Reply-To;
	bh=twxWWdz/L84GLIkfOlZIXyjFtna9wieu1jiumFBv8x8=;
	b=lXXtvh8zbgwSR8AEFycl/lo9nOKHI1XjjO/UQhR3y9T3mjIPaYy/lgsx4BYBR5/oyI9a
	 pNXflbCMi0k2mwtBNCvOg9R7F08uSbzfVh4dk3J3ZlIXdIebz0nyPFFKwzK7DrN3NWu+V
	 lYOxaFLPVaJJrnfOQutOIxpukz95RObxeT09CbUPW1lbU1p5ciOex9knqnxJauu5SlvQj
	 Aj5VKNOy6fFcycokPi+eaYULn+YitXNnFfQtbwpVDWyVVf6Taxbq6iOJdywLNaEoy0LQu
	 shBGlhSG4DIO1iy66o+PskDv/Qydsn1RfP/yb8CKWRYTEXcugWvAKZ58eZ8ZI4NH5iA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=OX+h45CA;
	dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=UuhFVMyk;
	dmarc=pass header.from=linutronix.de;
	spf=pass smtp.mailfrom=linutronix.de;
	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 C532E606A32D;
	Wed, 11 Nov 2026 12:18:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=OX+h45CA;
	dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=UuhFVMyk
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794399482;
	b=ZVg91DZLSRrk+HLqhW4HhDiZ/IFUrywF0i/5QuYplG6+SULwo8oC2MRSuX0p/7rg13hq
	 iIAHcxzQDRKJ82pBGA4BYTlnsZatl2kvUML78fWKVqfeze4S6s3thAwf+/AYFcvkfNpF7
	 kX7cAtQylKalRmxOPt4EytStvzcIkMbaRGwk1TPA+c8Y2flccSlnU4EBxCCdSAgZ/D0eI
	 pxFeDYzvTqXmMxLrsNOOXOw9N1utdA5ZSJXfmXr1Rnt3L2FsMo1k3SUr9QQyJ3s4Zxqcc
	 JCN2oHn2njCNc9mNO2/DSWSwpjZKQvxIDt/JwJFlcKuuPln4b27KaxnVSP1xwWZt5mA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794399482;
	h=DMARC-Filter:Date:DKIM-Signature:DKIM-Signature:From:To:Cc:Subject:
	 Message-ID:References:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To;
	bh=twxWWdz/L84GLIkfOlZIXyjFtna9wieu1jiumFBv8x8=;
	b=IHNyxfnY3BcrmCtvROaCbpXgtsQ7O3lNppu9B2StvqjMfozv9AsbFnESZ62tfF6WTyBO
	 Q1AeET+n4atd/fK8BEMbBOQdg5Q8FmMmt4NW0/82vPK1TozKyKLkc7G5Dwnqda8DMgcQe
	 G7eSchOOwFaq5ZLe7Iq3o4MLNZHCUGp8fnpl4nMCyS+JF9mPZSGeh/u/0rSsbJ9j2Nezk
	 dBkeVDy57sN4sWwKTzJsEWdGApNyp8P4tKwl+bB8uo50qch+7euks832ZPrELm2UTf5uZ
	 nnrd88aTsObrLwk2WETwuhDQ/ZjCZXzZaZFppngpX6lI9BNSf1e+tgJn9P1xk5WVXdg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linutronix.de;
	spf=pass smtp.mailfrom=linutronix.de;
	dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=OX+h45CA;
	dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=UuhFVMyk;
	arc=none smtp.remote-ip=193.142.43.55
X-Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ADCE606A324;
	Wed, 11 Nov 2026 12:18:01 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5ADCE606A324
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de;
	s=2020; t=1794399479;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=twxWWdz/L84GLIkfOlZIXyjFtna9wieu1jiumFBv8x8=;
	b=OX+h45CAhtBxpWJ6Dl1w/YTYPEN9A+IwrPeF2gJvtq7MOKI5YTLz1dZBRJs3dVqhtE5Btk
	dIHSmpFfKqBbz2vQy+ecDGYz9RQ6GHQoFdHQuMgkVRPrdBB2tsebGhY/k/vk01r6tp9CSv
	dFn2cTtQRwKyY1y15IFxUUAyvT13INgbH331fKDsP3qy+92NmzJmLsVtcW2SgTeYbcCRqt
	wPlLk3q5TD80e/EM1oyQ6rryNANlOed8W15i3iwIR6x4XMTotH/98CALd+mFTKksaWYLMy
	6n6qR+HiRSLo9EXkfk4YV5ycZs04a1nwtjN5PfMsYgaJziQY5oV3uKCm+QarwA==
X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de;
	s=2020e; t=1794399479;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=twxWWdz/L84GLIkfOlZIXyjFtna9wieu1jiumFBv8x8=;
	b=UuhFVMyklXOaR+noxK6+6dtCrUiKb/OOI0hlJFUZjGXC9FndfepSHpZwT1/7VlLsL+VW6H
	z77A7WlPt90FdiDw==
X-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
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-In-Reply-To: <20261110165742.1204-1-haoranwangsec@gmail.com>