From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC63262FED for ; Tue, 2 Dec 2025 15:29:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764689382; cv=none; b=qyBZE5u75+ZU/smdhvxrQPXDxxpnzz0KJL3VDJ4Xn+KxNVuFNmrar6SguSY0nTHsRYTT1OYuuW5WoLrn6+nrci3pcPzLedMdNjYp/n5dfm1aS5N5ci2bWEh6cANS8x8LyN3XNYwtHa2BF7+84Z1lqpN8Gh7Xfs9sgavDGq33S3s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764689382; c=relaxed/simple; bh=BZtIuSYzo4X0vi8zHGDRh1sL+AQ42TCB+JFZn40EQnk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qxON3fBchJ2XhYDTPWAefBAFtoCXJTirDYOGMMHnf6Zz01QQFUWDxAAIHD38wr1JPny0djS1uJHWIXlUAK3lFGgT2IHpBEoM7ojquGW7Ls4bPkS0s2ZKZLF48M3sVx0QriqofiAsnJVUwcnh+VpAqrTWEVzrT5fuprR+QsF4Ies= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=D/DrpocK; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D/DrpocK" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-29558061c68so68275445ad.0 for ; Tue, 02 Dec 2025 07:29:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764689381; x=1765294181; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Pm04M8J4HumgMBH0ZuXZAiRY8Gdv9LOi293f7C71dv8=; b=D/DrpocKM7R3+UI5XzGY+e7wsnIjOBh41K6MGTdDpZuqjUQY52jAWsybQO/XVerCgz fd7lTDHFLLwKvkS0Sg1QUVjiG5wt1XqnF52idr/taYJhPTN2mpzE5V9UMTUh15f5dZJe r4g90Sk8ke+YbfBljPn1WOXi5Cs99c51T/flI6/JcTUBaFJP45zcxkcsQw8LJYkZAq1P djgloHzXZ/U4mqggjKzzUXft7z26Vm89WlcjjG6rHNmYusR7IW6AXcmYIT2AvrEVeabp g/lAF+X9BrsPoSOIRMRrP+DBja/eFZBEBUW0tXuQzLF40fiJ7M/hOvvI8P1RzNOSoFuA Dt4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764689381; x=1765294181; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Pm04M8J4HumgMBH0ZuXZAiRY8Gdv9LOi293f7C71dv8=; b=Qz1EECa0Xb9ul0rFXM3Bp/kwvxAy9uU4BJJYelIk3cr/R3zZvFpsirtqlGLI7zdMxl 7goUbiBaPVAHSSn3xDkPQA/dIlGVSIf7LXNUivkr9RlJcugUND0FMowhMUcx/Zm8g1V9 n2Q1F5iJ3nGFSdQcnG/AqAdGBvr8o9DU84B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SMTP id d9443c01a7336-29b6bf9e98amr470449935ad.54.1764689380670; Tue, 02 Dec 2025 07:29:40 -0800 (PST) Received: from ?IPV6:2001:ee0:4f4c:210:48c5:4372:8d4:ac0b? ([2001:ee0:4f4c:210:48c5:4372:8d4:ac0b]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29bce40ab6bsm157212555ad.21.2025.12.02.07.29.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Dec 2025 07:29:40 -0800 (PST) Message-ID: Date: Tue, 2 Dec 2025 22:29:32 +0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC] virtio_net: gate delayed refill scheduling To: Jason Wang Cc: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, Paolo Abeni , Xuan Zhuo , =?UTF-8?Q?Eugenio_P=C3=A9rez?= , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , virtualization@lists.linux.dev, netdev@vger.kernel.org, bpf@vger.kernel.org References: <40af2b73239850e7bf1a81abb71ee99f1b563b9c.1764226734.git.mst@redhat.com> Content-Language: en-US From: Bui Quang Minh In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/2/25 13:03, Jason Wang wrote: > On Mon, Dec 1, 2025 at 11:04 PM Bui Quang Minh wrote: >> On 11/28/25 09:20, Jason Wang wrote: >>> On Fri, Nov 28, 2025 at 1:47 AM Bui Quang Minh wrote: >>>> I think the the requeue in refill_work is not the problem here. In >>>> virtnet_rx_pause[_all](), we use cancel_work_sync() which is safe to >>>> use "even if the work re-queues itself". AFAICS, cancel_work_sync() >>>> will disable work -> flush work -> enable again. So if the work requeue >>>> itself in flush work, the requeue will fail because the work is already >>>> disabled. >>> Right. >>> >>>> I think what triggers the deadlock here is a bug in >>>> virtnet_rx_resume_all(). virtnet_rx_resume_all() calls to >>>> __virtnet_rx_resume() which calls napi_enable() and may schedule >>>> refill. It schedules the refill work right after napi_enable the first >>>> receive queue. The correct way must be napi_enable all receive queues >>>> before scheduling refill work. >>> So what you meant is that the napi_disable() is called for a queue >>> whose NAPI has been disabled? >>> >>> cpu0] enable_delayed_refill() >>> cpu0] napi_enable(queue0) >>> cpu0] schedule_delayed_work(&vi->refill) >>> cpu1] napi_disable(queue0) >>> cpu1] napi_enable(queue0) >>> cpu1] napi_disable(queue1) >>> >>> In this case cpu1 waits forever while holding the netdev lock. This >>> looks like a bug since the netdev_lock 413f0271f3966 ("net: protect >>> NAPI enablement with netdev_lock()")? >> Yes, I've tried to fix it in 4bc12818b363 ("virtio-net: disable delayed >> refill when pausing rx"), but it has flaws. > I wonder if a simplified version is just restoring the behaviour > before 413f0271f3966 by using napi_enable_locked() but maybe I miss > something. As far as I understand, before 413f0271f3966 ("net: protect NAPI enablement with netdev_lock()"), the napi is protected by the rtnl_lock(). But in the refill_work, we don't acquire the rtnl_lock(), so it seems like we will have race condition before 413f0271f3966 ("net: protect NAPI enablement with netdev_lock()"). Thanks, Quang Minh.