🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19113

Re: [PATCH net v4] ice: fix Tx hang dump using stale tx_buf[0].skb

#19113
From: Simon Horman
Date: Thu, 19 Nov 2026 11:24
116 lines
11838 bytes
On Thu, Nov 12, 2026 at 01:45:56PM -0500, Vincent Choiniere wrote:

...

> @@ -424,6 +429,78 @@ void ice_prep_tx_hang_report(struct ice_pf *pf, struct ice_tx_ring *tx_ring,
>  	buf->vsi_num = vsi_num;
>  	buf->head = head;
>  	buf->intr = intr;
> +	buf->queue = tx_ring->q_index;
> +	buf->next_to_clean = tx_ring->next_to_clean;
> +	buf->next_to_use = tx_ring->next_to_use;
> +}
> +
> +/**
> + * ice_tx_hang_snapshot - copy the timed-out queue's ring at report time
> + * @pf: PF on which the Tx hang was detected
> + * @tx_ring: ring saved by ice_tx_timeout(), possibly stale
> + * @ev: event to fill in
> + *
> + * The saved ring may have been freed or replaced since the timeout (e.g. by
> + * ethtool -G or -L), and a freed ring may be reused for another queue. Use it
> + * only if the timeout was on the PF VSI, that VSI is up and the timed-out
> + * queue still maps to it. Those paths, and the reset paths, replace or free
> + * the rings under RTNL or from the service task itself, so with RTNL held the
> + * accesses below are to live memory for them. The ring may still have been
> + * reset in place since the timeout (e.g. by ethtool -G or an MTU change); as
> + * before, its state is read when the report is generated. Driver removal and
> + * devlink reload tear the VSIs down before the service task is stopped and are
> + * not covered here. ice_clean_tx_irq() may still run and free the skb at
> + * next_to_clean at any time, so only the pointer value is recorded and the skb
> + * itself is never dereferenced.
> + */
> +static void ice_tx_hang_snapshot(struct ice_pf *pf, struct ice_tx_ring *tx_ring,
> +				 struct ice_tx_hang_event *ev)
> +{
> +	struct ice_vsi *vsi = ice_get_main_vsi(pf);
> +	struct ice_q_vector *q_vector;
> +	struct ice_tx_buf *tx_buf;
> +	u16 ntc, ntu;
> +	void *desc;
> +	u32 size;
> +
> +	ASSERT_RTNL();
> +
> +	if (!tx_ring || !vsi || !vsi->tx_rings ||
> +	    test_bit(ICE_VSI_DOWN, vsi->state))
> +		return;
> +
> +	if (ev->vsi_num != vsi->vsi_num || ev->queue >= vsi->num_txq ||
> +	    vsi->tx_rings[ev->queue] != tx_ring)
> +		return;
> +
> +	q_vector = tx_ring->q_vector;
> +	if (!q_vector || !tx_ring->desc || !tx_ring->tx_buf || !tx_ring->count)
> +		return;
> +
> +	size = tx_ring->count * sizeof(struct ice_tx_desc);
> +	desc = kvmalloc(size, GFP_KERNEL);
> +	if (!desc)
> +		return;
> +
> +	ntc = READ_ONCE(tx_ring->next_to_clean);
> +	ntu = READ_ONCE(tx_ring->next_to_use);
> +
> +	if (ntc < tx_ring->count) {

Sorry to nit-pick, but I wonder if it would be nicer to move the kvmalloc()
call and associated error checking be moved here...

> +		tx_buf = &tx_ring->tx_buf[ntc];
> +		if (tx_buf->type == ICE_TX_BUF_SKB)
> +			ev->skb_ptr = READ_ONCE(tx_buf->skb);
> +
> +		memcpy(desc, tx_ring->desc, size);
> +		ev->next_to_clean = ntc;
> +		ev->next_to_use = ntu;
> +		strscpy(ev->irq_name, q_vector->name);
> +		ev->desc_ptr = tx_ring->desc;
> +		ev->dma = tx_ring->dma;
> +		ev->desc_size = size;
> +		ev->desc = desc;
> +	} else {
> +		kvfree(desc);

... and remove the else arm of the condition.

> +	}
>  }

And further, the sense of the condition could be reversed, saving some
indentation:

	if (ntc >= tx_ring->count)
		return

	desc = kvmalloc(size, GFP_KERNEL);
	if (!desc)
		return;

	tx_buf = &tx_ring->tx_buf[ntc];
	if (tx_buf->type == ICE_TX_BUF_SKB)
		ev->skb_ptr = READ_ONCE(tx_buf->skb);

	memcpy(desc, tx_ring->desc, size);
	ev->next_to_clean = ntc;
	ev->next_to_use = ntu;
	strscpy(ev->irq_name, q_vector->name);
	ev->desc_ptr = tx_ring->desc;
	ev->dma = tx_ring->dma;
	ev->desc_size = size;
	ev->desc = desc;

Regardless, this looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID: <20261119112409.GU860048@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366964-linux-kernel-netdev=dewy.ru
References: <20261112-ice-tx-hang-dump-v4-1-9125f687669b@hydroquebec.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366964-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v4] ice: fix Tx hang dump using stale tx_buf[0].skb
Date: Thu, 19 Nov 2026 11:24:09 +0000
Organization: Usenet Network
Message-ID: <20261119112409.GU860048@horms.kernel.org>
References: <20261112-ice-tx-hang-dump-v4-1-9125f687669b@hydroquebec.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2858772"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:oye/hCzmuYj02pfZ5Cbks0aM7hQ= sha256:PdFNCXNaZmcgwwR+jOourt2K/HqjKNd/X83K3g7pzpU=
	sha1:WWOwAebt11HQGeJqCIZ37cm2kOk= sha256:yrVApUPpHb14uY7k+FMpmyihn6POoaf7trLnb+n31u8=
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 521691155DD; Thu, 19 Nov 2026 14:24:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 (2048-bit key)
	header.d=kernel.org
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 SrB-j8mvJE0F;
	Thu, 19 Nov 2026 14:24:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366964-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 941B61155BE; Thu, 19 Nov 2026 14:24:23 +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 B3C1A1A56A3; Thu, 19 Nov 2026 11:24:17 +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=1795087456;
	b=Z2YqGiLT3Z33dXyhl+Qkhpd25vBLpJj5KZuzn/lZcrVS4w0VZHzhMcB/NCqhxq162Tjs
	 KSbZn1BoF0/QSnP93TEMwfYbjCaQ6LjEuEaO4TNeVkjQ5OumOwlSM9bRu1j5cs4ChLYVQ
	 oV9jC2R0ffvRuKDW2y/VtZZV5B0IN9SJAUtfUOhPaSx7MOohQjvMUuomoqYDJNpSoneg7
	 ch4fP8iTUghd5n0SNyq/uhHoUan1vlp6duGVyrX/u4ajD91ZfIgYl17N7fyox+DgNHfMD
	 nFQuCDb2f3FMrODkPFjCMCxMApX61uet7XqNVsukobMd2KR+yz2qZCgwn5BQBKag57A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795087456;
	h=X-Original-To:Received:Received:DKIM-Signature:Date: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=PAbCKhxpRkBffJWgsRtKYvAYQkiZqg3MoFHOfafjj7I=;
	b=gZcuYi9ot2/ZjxgNtL5lFXFkgjqG8OsLjfTDvdpXRKmGzxF9SuVrEN6sQus+ZMJ5Wg30
	 slof9V7qspln+oH9IB6piuoVPqsmsHVNa19ViH0t0nao5X1Zq6GoqsBw0Z6uX45GtZEh3
	 +tkofoxJmydRo3kp8vAOJ+fLGMAiRU0wVJc0ABvs5PAn4Ji3tIdfpC+dFUicXtOKMbVI1
	 6LanCXdMhmSwD2DnxFbS43d6Y38I+yo8lw01pRPxsNKYR4QntiKVWf1IvjwK1qbjEp2vJ
	 xbVvcYB3C6HhRQ+X0z1Gb1NzbfqH9ypv70uDii84hBDCCUzgELzaSowcXiMoRPRe6FQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PQlFHyVn;
	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 C0F28606A320;
	Thu, 19 Nov 2026 11:24:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PQlFHyVn
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795087456;
	b=Pd7+fV/LpZdHwiDYwVQpsFPxj4Dopz/nM3nkYP2NZcGmWUWfOc5u+ANb6T03WJh0CDXd
	 sKEOY+9HoZaVHmIqBzE96KAktR+4jqYpul3cr+RKBckv/lpfB42FUhMqiSYxLNZZnPb3k
	 xAWO2okHXHQlA/aTlGrwrYfL1PLMH4pHG3kts5jebPzDBsumRjDebIuPIpg9U/l1kIka8
	 +60OwKRBtU/O0fvny8WjjphfCE2NZlyQvD79GMMIJz4yiEjJJPziCVnlqwHrdJhxVSfYh
	 n6hSpTsbDIdS3s55Ju5PxjG9vVEjTQKrfZDuhlAR40h6pT7ryHpAnIaDV5lATK22e+w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795087456;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=PAbCKhxpRkBffJWgsRtKYvAYQkiZqg3MoFHOfafjj7I=;
	b=mP7VnehN6+a5Qtxel0q+efgxHWtZESxmyUZWWZJ0zo+y4Tek4a4Bv1Z4FKxuTk8yC2ZI
	 GLJpgY9rgybE6hjgtXVx6hVqr7NzI3eTYlYPvWQdoV8uRvrdlXQk7PbDKre8ndj2Zq5Pb
	 Q0EVttlzuhWMEGaRMFk0LZDGZ+QBoi48KCKC74ifLbwyOhnC3Uc1EyGT9wpB2n37pQTjr
	 Ahga01hqBgHzSguswVWDdkLwkXvyUCRhOlPrpcB1mDT9/oHtpPBB2aCDhONGvkVIS22GU
	 uQp6SvqvaxdY7LTspQyqW97CwsI1bFbnXvTden/XGsVqPNT6YHoOGZkTNtk1KugsaBQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PQlFHyVn;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0773606A326;
	Thu, 19 Nov 2026 11:24:15 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DE071F000C5;
	Thu, 19 Nov 2026 11:24:12 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795087455;
	bh=PAbCKhxpRkBffJWgsRtKYvAYQkiZqg3MoFHOfafjj7I=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=PQlFHyVnL719LmbhVpx+mjI6xRk6OVIKiMmHw+GvFflDKHLBFnA6zci52jYLuOSzo
	 NR3pt0KAtun2FasVaOmNk9Goes6SYI/S3z11jEp131dN9pfVEj5G6+70AFwJR7/rC0
	 xL+MxScusFNHVhNp84bPq1FIcloF1DPuHrolJw79YJMHRPNGNaWC7gV8bzMu0qF8q4
	 4riiillfyhA9JZ9Pibu2KHH8MKff+15mr+Hon6kkW0dtC0Fi2F5pFh6Rrep+KlMk+R
	 FInoyKoua3H2uw37uIiL4n5VHQztII/f66agXZ4ex/FSw1XwrzW5MoF874KGpt85P/
	 +RrDtrl55zTDQ==
X-Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	intel-wired-lan@lists.osuosl.org,
	Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	Michal Kubiak <michal.kubiak@intel.com>,
	Wojciech Drewek <wojciech.drewek@intel.com>,
	Mateusz Polchlopek <mateusz.polchlopek@intel.com>,
	Paul Menzel <pmenzel@molgen.mpg.de>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.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: <20261112-ice-tx-hang-dump-v4-1-9125f687669b@hydroquebec.com>