🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23825

Re: [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded

#23825
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 09:30
202 lines
15935 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch moves the early ice_service_task_stop() only in
  ice_remove().
- [High] The patch handles the "last run re-arms the service timer after
  the stop, and the timer fires after the PF is freed" race only in the…
- [Medium] The early ice_service_task_stop() in ice_remove()
  (ice_main.c:5390) does not stop the service work from being queued…

--

ice: stop the service task before the PF is unloaded

This patch moves ice_service_task_stop() and ice_aq_cancel_waiting_tasks()
in ice_remove() back to right after ice_free_vfs(). The service task is then
stopped before the aRFS filters, netdev, LAG and VSIs are freed. The stop
in ice_deinit_dev() is kept so that it deletes a timer re-armed by the last
run.

> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 47c6798c97e8f..6dede87b78944 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -5387,6 +5387,9 @@ static void ice_remove(struct pci_dev *pdev)
>  		ice_free_vfs(pf);
>  	}
>  
> +	ice_service_task_stop(pf);
> +	ice_aq_cancel_waiting_tasks(pf);
> +

[Severity: High]
The same ordering problem seems to remain on the other paths that unload
the PF. ice_devlink_reinit_down() in devlink/devlink.c does:

	ice_unload(pf);
	rtnl_lock();
	ice_vsi_decfg(ice_get_main_vsi(pf));
	rtnl_unlock();
	ice_deinit_pf(pf);
	ice_deinit_hw(&pf->hw);
	ice_deinit_dev(pf);

Nothing sets ICE_SERVICE_DIS before ice_deinit_dev(), so the service timer
keeps queueing serv_task during this whole sequence:

  - ice_unload()->ice_decfg_netdev() calls free_netdev(vsi->netdev).
  - ice_deinit_pf() destroys sw_mutex, tc_mutex and lag_mutex, frees the
    avail_txqs/avail_rxqs bitmaps and frees the misc IRQ.
  - ice_deinit_hw() destroys the control queues.

Can a run of ice_sync_fltr_subtask()->ice_vsi_sync_fltr() that has already
read vsi->netdev keep using netdev->flags and netif_addr_lock_bh(netdev)
after free_netdev()?

A devlink dev reload with action driver_reinit can trigger this while a
filter sync is pending, for example after a promisc or multicast change
through ice_set_rx_mode().

The probe error unwind in ice_probe() looks similar:

unroll_load:
	ice_unload(pf);
unroll_init:
	devl_unlock(priv_to_devlink(pf));
	ice_deinit(pf);
[ ... ]
unroll_hw_init:
	ice_deinit_hw(hw);
	if (need_dev_deinit)
		ice_deinit_dev(pf);

When this unwind runs, ice_init() has already cleared ICE_SERVICE_DIS and
armed serv_tmr. ice_load() has also queued serv_task through
ice_service_task_restart().

ice_deinit() only sets ICE_SERVICE_DIS, which does not wait for a running
work item, and then ice_dealloc_vsis() frees pf->vsi. After that come
ice_adapter_put() and ice_deinit_hw(), and only then the stop in
ice_deinit_dev().

Commit 8a37f9e2ff40, named in the Fixes: tag, is also the commit that moved
ice_deinit_dev() after ice_deinit_hw() in this unwind. Should
ice_devlink_reinit_down() and the probe unwind also stop the service task
before they tear down the PF? Neither path seems to change later in the
series.

[Severity: Medium]
Does a single ice_service_task_stop() here prevent serv_task from being
queued again before ice_remove_arfs(), ice_unload() and ice_deinit() run?

ice_service_task_schedule() tests ICE_SERVICE_DIS without a lock and only
calls queue_work() afterwards:

	if (!test_bit(ICE_SERVICE_DIS, pf->state) &&
	    !test_and_set_bit(ICE_SERVICE_SCHED, pf->state) &&
	    !test_bit(ICE_NEEDS_RESTART, pf->state))
		queue_work(ice_wq, &pf->serv_task);

Also, ice_service_task() does not check ICE_SERVICE_DIS when it starts.

At this point the netdev is still registered and the misc IRQ is still
live. That means ice_set_rx_mode(), ice_rx_flow_steer(), ice_misc_intr()
and the VF fdir handlers can all still reach ice_service_task_schedule().

One possible interleaving:

CPU0 (ice_set_rx_mode)              CPU1 (ice_remove)
set ICE_FLAG_FLTR_SYNC
test_bit(ICE_SERVICE_DIS) == 0
                                    ice_service_task_stop()
                                      test_and_set_bit(ICE_SERVICE_DIS)
                                      timer_delete_sync()
                                      cancel_work_sync() /* idle */
                                      clear_bit(ICE_SERVICE_SCHED)
queue_work(ice_wq, &pf->serv_task)
                                    ice_remove_arfs()
                                    ice_unload()  /* free_netdev() */
                                    ice_deinit()  /* ice_dealloc_vsis() */

The worker would then run ice_sync_fltr_subtask(), ice_sync_arfs_fltrs()
and the other subtasks against the state being freed. The second stop in
ice_deinit_dev() only runs after the VSIs are already gone.

The window is only a few instructions wide. Would a check of
ICE_SERVICE_DIS at the start of ice_service_task(), or quiescing these
scheduling sources first, be needed to close it?

>  	if (!ice_is_safe_mode(pf))
>  		ice_remove_arfs(pf);
>  
> @@ -5407,7 +5410,6 @@ static void ice_remove(struct pci_dev *pdev)
>  	ice_deinit_hw(&pf->hw);
>  
>  	ice_deinit_dev(pf);
> -	ice_aq_cancel_waiting_tasks(pf);
>  	set_bit(ICE_DOWN, pf->state);
>  }

[Severity: High]
The commit message says the stop in ice_deinit_dev() "stays and deletes a
timer armed by the last run". The ordering inside ice_service_task_stop()
has not changed, though:

	ret = test_and_set_bit(ICE_SERVICE_DIS, pf->state);

	if (pf->serv_tmr.function)
		timer_delete_sync(&pf->serv_tmr);
	if (pf->serv_task.func)
		cancel_work_sync(&pf->serv_task);

A work item that is running during the stop can re-arm the timer after
timer_delete_sync():

  - ice_service_task() calls mod_timer(&pf->serv_tmr, jiffies) at its tail
    when a run was long or an *_EVENT_PENDING bit is set.
  - ice_service_task_recovery_mode() always calls
    mod_timer(&pf->serv_tmr, jiffies + msecs_to_jiffies(100)).

Once that happens, ice_service_timer() keeps re-arming itself.

Some paths still stop only once. The first is the recovery-mode branch
of ice_remove():

	if (ice_is_recovery_mode(&pf->hw)) {
		ice_service_task_stop(pf);
		scoped_guard(devl, priv_to_devlink(pf)) {
			ice_deinit_devlink(pf);
		}
		return;
	}

After this, devres frees the PF (the devlink priv), and the recovery-mode
work re-arms every 100ms. Can serv_tmr then fire on freed memory, or, after
rmmod, on unloaded module text?

The probe error unwind also calls ice_deinit_dev() only once before devres
frees the PF.

In ice_devlink_reinit_down(), the single stop in ice_deinit_dev() is
followed by ice_devlink_reinit_up()->ice_init_dev()->
ice_start_service_task(). That calls timer_setup(&pf->serv_tmr, ...) on a
timer that may still be enqueued. Could this corrupt the timer wheel list
once mod_timer() enqueues it again?

Would it be better to fix this inside ice_service_task_stop()? One option
is a second timer_delete_sync() after cancel_work_sync(). Another is to
skip the tail mod_timer() calls when ICE_SERVICE_DIS is set. Either would
avoid relying on a double stop at the call site.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127085714.1207361-1-poros%40redhat.com
Technical Details
Message-ID: <179585820637.3135.16053674648760900756@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373070-linux-kernel-netdev=dewy.ru
References: <20261127085714.1207361-2-poros@redhat.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373070-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded
Date: Sat, 28 Nov 2026 09:30:06 +0000
Organization: Usenet Network
Message-ID: <179585820637.3135.16053674648760900756@kernel.org>
References: <20261127085714.1207361-2-poros@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="922136"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3i4Cx2JVrV/lSdYbPmgv36tgmjQ= sha256:+T1TMKa9o53BQKy7hka6POH0580/s7hqS+RNONe04PA=
	sha1:ppfi8wAVn9RVsEhOUikqdVn2NTY= sha256:YKltUAYiQPb0Kf5yoyXBffXcjLuvma8/5Z/RFR/cSJQ=
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 861FB125F70; Sat, 28 Nov 2026 12:30:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 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,
	URIBL_BLOCKED=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 U7Ozv1nzY_eQ;
	Sat, 28 Nov 2026 12:30:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-373070-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id CAE1A125F71; Sat, 28 Nov 2026 12:30:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 237F96020C9; Sat, 28 Nov 2026 09:30: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=1795858214;
	b=bo1B5DoCLv9fZG8jDVFZSlMgvEw8201UZWwXVochn5Pt+wQnQ4/Kn4Hk+6RrgZTbtkaV
	 Ivxt8QhztZOVCqJE8uyZkCeHjVXLjaTR2P4VqDq21AXCptXNUwkQugaey/DCARd9HnOKr
	 WNCb2m7EysUxDzzC7vH4w7rg9vhxC6EGr1zNDq3qxyYKukOEnhF7Ft/5Ju+8/lURvoj8q
	 uNEpkQrvy/9bDfTjzWeUMN5WAsSHacKMMp3kIf0VylS/jxzAPfdum0XHDCkGLhpiEFSu8
	 z6Dlc0vy/QbTRHt5qPwVGwAyoI8nWTs8ptMpA15tFDsj07DEkYThC8740Cr/jzN7WsQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795858214;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=zgOM8vAhf19+9a0t5JbrihfRnYtAHBHB03GFJ5Sqe8M=;
	b=i+SFpd2XakCZ9ir7jA9nddxwgqOV10YdmXnxFt8GC/yA9KwvX1/PFfOrxn7LEolNn3E6
	 hguE19DmUmTHO/L4K9Dgy7BK9/IGyW9bOShyrm9S/Dwg9IZLM1skUp6UzthbekCfFrZY8
	 bw5yyNkcjGmQY+egNNdVs2CgBusL6mdL1AgePekJ8qYHFoXYN1HhwwOSa2EilxplVJHdM
	 ep7ryiM/f3BTOn21Wl2+j3bn23SwBVeQktbZM07rbf5sRVIMv/iMdIrARXwR/IWRTSdO5
	 tKHg09RJyd1P/vHXyePhas8lixmVnLEhq5lBfP8xMo3O4ZOn2wYpbeuPXD5X3cZwZrA==
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=etxzu4GT;
	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 653A1606A683;
	Sat, 28 Nov 2026 09:30:14 +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=etxzu4GT
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=1795858208;
	b=Ryr8gKaJ2QH8ivjoSNgT4c0DxDar61HF2Zu5Q5TGOU/C+vjvTXO8GGBm1va8CF4GVnuw
	 KQlTEBgF/7HG7pWXikwB5UqNSMpvZlfN2NxnvM/PSd5/EOUBPnvkLSdz7pBVoIyd9/Efx
	 De8T6o/G2osmjxKTrLskXbouBJ+FwAmLnATwGY2psEsxA0sOZOuHT/ZD0Va6ZSYhJt3jG
	 VAGr8wvP924zXYdnXREcUDOTeF/dyo8fwIFbImCK52NB7Db8YGj03OY+ruTxrtneACerL
	 /KUhIF8BTk2dxW8Ccaoozyn5aABVhbY2Cvr4zguGblYz+BIHd40x3x7w9RWOMmC/viA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795858208;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=zgOM8vAhf19+9a0t5JbrihfRnYtAHBHB03GFJ5Sqe8M=;
	b=Aw617Yr5kw1gT5Mf5uEooPGK13ZovaRx+PzJowJznmWplEwj97afNHBdg4QLgOueRQws
	 U+Sg2Dxim+vh6HlwghOHZI0uGQkkpJx3BThrrYZ+r/nrji76yxqc8J3UZtIJxvEcDUwQV
	 RHq37SAIbwthTlhuy8NOKMkLWLqf6Iqu5wKn35/qCS1UKel4UW0Hg/DBc2XavUsId5qQC
	 RimDCWmyE1NWY0VFiu678ylJ0k0Gr3xV4NUaVzRBmIH7oYwTULG5OPzYTng/AF3m2btKf
	 k14J+fCjQU/pifs7E9BnFBkk+mHz959FyVHSoyVwSsaGVLL07nqN/M+z3SrzU44YWXg==
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=etxzu4GT;
	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 85BD7606A31F;
	Sat, 28 Nov 2026 09:30:08 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9F6D1F000C1;
	Sat, 28 Nov 2026 09:30:06 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795858208;
	bh=zgOM8vAhf19+9a0t5JbrihfRnYtAHBHB03GFJ5Sqe8M=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=etxzu4GTQ3UAhayP6IwZ0T6LF9L1qSUo19CaH3iTmZJVZH5ESTqVbkZN1Vz0PxMaS
	 2wBVe5sdp5u2WvEf9kxs8tEk56YVDrE1bHB6B7n08bE1kHEGaXkVcOOfNC3jgQ/5xc
	 yfWMDm82Vg9ytJwKzhgAMEWJAJ9yvfDP0HKRFbwM7NIBnN5AR2F7vjwVMXXKRaLlEv
	 bgDLY941y3JoOtLsHp7FN6R/7AjhTau+ObJnq7euXJXEvjk/IdcVTmWgW5MtLvzOpV
	 qWbKKk6p4XzCq9UtK4o5u9Vg97vYnsBAgEvvFJzjgCKtuc1cNRHKRLPN2UUPSxwih6
	 Ae19c48Z5xojw==
X-Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com,
 przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 aleksandr.loktionov@intel.com, horms@kernel.org,
 michal.swiatkowski@linux.intel.com, grzegorz.nitka@intel.com,
 pmenzel@molgen.mpg.de, wojciech.drewek@intel.com,
 marcin.szycik@linux.intel.com, martyna.szapar-mudlaw@linux.intel.com,
 ivecera@redhat.com, alice.michael@intel.com, jacob.e.keller@intel.com,
 jbrandeb@kernel.org, patryk.holda@intel.com, sx.rinitha@intel.com,
 aaron.ma@canonical.com, intel-wired-lan@lists.osuosl.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261127085714.1207361-2-poros@redhat.com>
X-sashiko-severity: High
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