From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 4DAB413D28F for ; Wed, 14 Aug 2024 08:17:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723623442; cv=none; b=JG8QU7FmZ9XriY08AwT1MephZGYEzE30ezMwJPxY5aruNBdePO58cNWAP3dgoNm3pl/ew783WXTRmEVs+EmeJKLbyzVa7+2GwAdUpwuQpAlQ5NyShZSgiKQy0hVT6UNk9TI4NDS497ei77LoGWo+KRm3spa/I4Cdq9kqPg7dqhg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723623442; c=relaxed/simple; bh=4WZ0OzGPLTIXH39Ubaflx7d0PRdTJVJTTnLk0JUUY2M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ngf9TYyPcXyIxhZGsJJm5T1U8ERLoUw4F6EipdbzCG3pJXoEZ8Yxxky7h/il1BTtphTWPi7IU33QB1dmT/9Ouq07gRHdniKeeqCKgqJniPl6jt8PoGU48YhDtoTHKnRrLqd9Tuq3GZ+5IsY2eHaGXg4ag++39+Qz00JZfIWM6vY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=TdyYPVsC; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="TdyYPVsC" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a7d638a1f27so251074966b.2 for ; Wed, 14 Aug 2024 01:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1723623437; x=1724228237; darn=lists.linux.dev; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=uGKH4VT+6oIZ05Mg/wtc5j5EPbFWisi/zDz8nVxU9W8=; b=TdyYPVsCxcx2qFG9Hz8A/UKtlmn3D2L1I3NHRJVPRtEQGO33+wTP5mNWzJTg31Bo9k RQPnL45dMfGh61lU5GAC5TZH1bkNV9pnhUhqahQalsY7KxPpQxCh31vRdKFzNdTpUIKl qw3rv2omSESVzAZsUueI304jKYLUyAvntd7tjofWZr4O8qSXLBWFcrH68lwKuFl7flIQ s2G4e80UnvO+yZ6IgVCvQuUCc7Z3Tb04NAVFl9E2WkIeDFwK0HiIUyg6aDRWzmXctR4+ B5HThjJ14f0umfn2/WVb2m6l0+ZHKfc4j5yZOM3O9tZjkSRY1oSy1rX5JLTGWyy3OhGQ 7JFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723623437; x=1724228237; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uGKH4VT+6oIZ05Mg/wtc5j5EPbFWisi/zDz8nVxU9W8=; b=WFALoXd3saYBx2B+K50hnjNWNOlDbe+sWlkHZtY6RQ5W+ZWTnF0y+Ichvq6iqx5cO2 LFuv4cOAigrTnjt5E85zTICTgzfZprBNHRrRA4JHg+HrcUFP0A1IYAKNCbBiKM7IDu1N rRVT2UlclWJ8m0izCtIY/fSeovKKG3s9/HiQwX/hzlH9jQ7IOYsjRMxa7Sqykw4aiKyx gjNIKgt71bV3ckhJcVzl0348ttmTc16EwVGqeud/0+HVYCHRrzYod6T0B9Ije/IZBC6o YmMG1dMXU0gWuJW4E5VOImE+5Ivj/ttDr/RYhWdH+gzNM80eyQnoC0XnTBrYpEihj1oW 9jdQ== X-Forwarded-Encrypted: i=1; AJvYcCVxyTQXopP7ugE3FEaARFurrJzjwsTLSbt5O9m7NIGy5WOwTOqKr1vtPq6bKO0iCRnxnGmbk6UCoCTReRrttAD9R3J8NnZA2CpyNgGJrdY= X-Gm-Message-State: AOJu0YykY++9+bbJSheroavfv7RaGZFGz3gzrIepUxQOodi8HY/3Gxii EFE1cxe7oFKDW07oa/T0uD9EEfH23S3fB06aKPs7KBfGa1TVw4du2EbxmbadHcM= X-Google-Smtp-Source: AGHT+IGJUV9VKtFAaK5scsW7KwbH6afPR2cjc8d17/h0tffxEHW4y7gQog39aiaK6j22dbIHpYoXzA== X-Received: by 2002:a05:6402:26c7:b0:5a2:6142:24c1 with SMTP id 4fb4d7f45d1cf-5bea1c6abe2mr2073402a12.5.1723623437150; Wed, 14 Aug 2024 01:17:17 -0700 (PDT) Received: from localhost (37-48-50-18.nat.epc.tmcz.cz. [37.48.50.18]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a80f411bd72sm142852966b.140.2024.08.14.01.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 01:17:16 -0700 (PDT) Date: Wed, 14 Aug 2024 10:17:15 +0200 From: Jiri Pirko To: Marek Szyprowski Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, virtualization@lists.linux.dev, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, dave.taht@gmail.com, kerneljasonxing@gmail.com, hengqi@linux.alibaba.com Subject: Re: [PATCH net-next v3] virtio_net: add support for Byte Queue Limits Message-ID: References: <20240618144456.1688998-1-jiri@resnulli.us> Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Wed, Aug 14, 2024 at 09:49:57AM CEST, jiri@resnulli.us wrote: >Mon, Aug 12, 2024 at 06:55:26PM CEST, m.szyprowski@samsung.com wrote: >>On 12.08.2024 18:47, Jiri Pirko wrote: >>> Mon, Aug 12, 2024 at 04:57:24PM CEST, m.szyprowski@samsung.com wrote: >>>> On 18.06.2024 16:44, Jiri Pirko wrote: >>>>> From: Jiri Pirko >>>>> >>>>> Add support for Byte Queue Limits (BQL). >>>>> >>>>> Tested on qemu emulated virtio_net device with 1, 2 and 4 queues. >>>>> Tested with fq_codel and pfifo_fast. Super netperf with 50 threads is >>>>> running in background. Netperf TCP_RR results: >>>>> >>>>> NOBQL FQC 1q: 159.56 159.33 158.50 154.31 agv: 157.925 >>>>> NOBQL FQC 2q: 184.64 184.96 174.73 174.15 agv: 179.62 >>>>> NOBQL FQC 4q: 994.46 441.96 416.50 499.56 agv: 588.12 >>>>> NOBQL PFF 1q: 148.68 148.92 145.95 149.48 agv: 148.2575 >>>>> NOBQL PFF 2q: 171.86 171.20 170.42 169.42 agv: 170.725 >>>>> NOBQL PFF 4q: 1505.23 1137.23 2488.70 3507.99 agv: 2159.7875 >>>>> BQL FQC 1q: 1332.80 1297.97 1351.41 1147.57 agv: 1282.4375 >>>>> BQL FQC 2q: 768.30 817.72 864.43 974.40 agv: 856.2125 >>>>> BQL FQC 4q: 945.66 942.68 878.51 822.82 agv: 897.4175 >>>>> BQL PFF 1q: 149.69 151.49 149.40 147.47 agv: 149.5125 >>>>> BQL PFF 2q: 2059.32 798.74 1844.12 381.80 agv: 1270.995 >>>>> BQL PFF 4q: 1871.98 4420.02 4916.59 13268.16 agv: 6119.1875 >>>>> >>>>> Signed-off-by: Jiri Pirko >>>>> --- >>>>> v2->v3: >>>>> - fixed the switch from/to orphan mode while skbs are yet to be >>>>> completed by using the second least significant bit in virtqueue >>>>> token pointer to indicate skb is orphan. Don't account orphan >>>>> skbs in completion. >>>>> - reorganized parallel skb/xdp free stats accounting to napi/others. >>>>> - fixed kick condition check in orphan mode >>>>> v1->v2: >>>>> - moved netdev_tx_completed_queue() call into __free_old_xmit(), >>>>> propagate use_napi flag to __free_old_xmit() and only call >>>>> netdev_tx_completed_queue() in case it is true >>>>> - added forgotten call to netdev_tx_reset_queue() >>>>> - fixed stats for xdp packets >>>>> - fixed bql accounting when __free_old_xmit() is called from xdp path >>>>> - handle the !use_napi case in start_xmit() kick section >>>>> --- >>>>> drivers/net/virtio_net.c | 81 ++++++++++++++++++++++++++++------------ >>>>> 1 file changed, 57 insertions(+), 24 deletions(-) >>>> I've recently found an issue with virtio-net driver and system >>>> suspend/resume. Bisecting pointed to the c8bd1f7f3e61 ("virtio_net: add >>>> support for Byte Queue Limits") commit and this patch. Once it got >>>> merged to linux-next and then Linus trees, the driver occasionally >>>> crashes with the following log (captured on QEMU's ARM 32bit 'virt' >>>> machine): >>>> >>>> root@target:~# time rtcwake -s10 -mmem >>>> rtcwake: wakeup from "mem" using /dev/rtc0 at Sat Aug 10 12:40:26 2024 >>>> PM: suspend entry (s2idle) >>>> Filesystems sync: 0.000 seconds >>>> Freezing user space processes >>>> Freezing user space processes completed (elapsed 0.006 seconds) >>>> OOM killer disabled. >>>> Freezing remaining freezable tasks >>>> Freezing remaining freezable tasks completed (elapsed 0.001 seconds) >>>> ------------[ cut here ]------------ >>>> kernel BUG at lib/dynamic_queue_limits.c:99! >>>> Internal error: Oops - BUG: 0 [#1] SMP ARM >>>> Modules linked in: bluetooth ecdh_generic ecc libaes >>>> CPU: 1 PID: 1282 Comm: rtcwake Not tainted >>>> 6.10.0-rc3-00732-gc8bd1f7f3e61 #15240 >>>> Hardware name: Generic DT based system >>>> PC is at dql_completed+0x270/0x2cc >>>> LR is at __free_old_xmit+0x120/0x198 >>>> pc : []    lr : []    psr: 80000013 >>>> ... >>>> Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none >>>> Control: 10c5387d  Table: 43a4406a  DAC: 00000051 >>>> ... >>>> Process rtcwake (pid: 1282, stack limit = 0xfbc21278) >>>> Stack: (0xe0805e80 to 0xe0806000) >>>> ... >>>> Call trace: >>>>  dql_completed from __free_old_xmit+0x120/0x198 >>>>  __free_old_xmit from free_old_xmit+0x44/0xe4 >>>>  free_old_xmit from virtnet_poll_tx+0x88/0x1b4 >>>>  virtnet_poll_tx from __napi_poll+0x2c/0x1d4 >>>>  __napi_poll from net_rx_action+0x140/0x2b4 >>>>  net_rx_action from handle_softirqs+0x11c/0x350 >>>>  handle_softirqs from call_with_stack+0x18/0x20 >>>>  call_with_stack from do_softirq+0x48/0x50 >>>>  do_softirq from __local_bh_enable_ip+0xa0/0xa4 >>>>  __local_bh_enable_ip from virtnet_open+0xd4/0x21c >>>>  virtnet_open from virtnet_restore+0x94/0x120 >>>>  virtnet_restore from virtio_device_restore+0x110/0x1f4 >>>>  virtio_device_restore from dpm_run_callback+0x3c/0x100 >>>>  dpm_run_callback from device_resume+0x12c/0x2a8 >>>>  device_resume from dpm_resume+0x12c/0x1e0 >>>>  dpm_resume from dpm_resume_end+0xc/0x18 >>>>  dpm_resume_end from suspend_devices_and_enter+0x1f0/0x72c >>>>  suspend_devices_and_enter from pm_suspend+0x270/0x2a0 >>>>  pm_suspend from state_store+0x68/0xc8 >>>>  state_store from kernfs_fop_write_iter+0x10c/0x1cc >>>>  kernfs_fop_write_iter from vfs_write+0x2b0/0x3dc >>>>  vfs_write from ksys_write+0x5c/0xd4 >>>>  ksys_write from ret_fast_syscall+0x0/0x54 >>>> Exception stack(0xe8bf1fa8 to 0xe8bf1ff0) >>>> ... >>>> ---[ end trace 0000000000000000 ]--- >>>> Kernel panic - not syncing: Fatal exception in interrupt >>>> ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]--- >>>> >>>> I have fully reproducible setup for this issue. Reverting it together >>>> with f8321fa75102 ("virtio_net: Fix napi_skb_cache_put warning") (due to >>>> some code dependencies) fixes this issue on top of Linux v6.11-rc1 and >>>> recent linux-next releases. Let me know if I can help debugging this >>>> issue further and help fixing. >>> Will fix this tomorrow. In the meantime, could you provide full >>> reproduce steps? >> >>Well, it is easy to reproduce it simply by calling >> >># time rtcwake -s10 -mmem >> >>a few times and sooner or later it will cause a kernel panic. > >I found the problem. Following patch will help: > > >diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c >index 3f10c72743e9..c6af18948092 100644 >--- a/drivers/net/virtio_net.c >+++ b/drivers/net/virtio_net.c >@@ -2867,8 +2867,8 @@ static int virtnet_enable_queue_pair(struct virtnet_info *vi, int qp_index) > if (err < 0) > goto err_xdp_reg_mem_model; > >- virtnet_napi_enable(vi->rq[qp_index].vq, &vi->rq[qp_index].napi); > netdev_tx_reset_queue(netdev_get_tx_queue(vi->dev, qp_index)); >+ virtnet_napi_enable(vi->rq[qp_index].vq, &vi->rq[qp_index].napi); > virtnet_napi_tx_enable(vi, vi->sq[qp_index].vq, &vi->sq[qp_index].napi); Hmm, I have to look at this a bit more. I think this might be accidental fix. The thing is, napi can be triggered even if it is disabled: ->__local_bh_enable_ip() -> net_rx_action() -> __napi_poll() Here __napi_poll() calls napi_is_scheduled() and calls virtnet_poll_tx() in case napi is scheduled. napi_is_scheduled() checks NAPI_STATE_SCHED bit in napi state. However, this bit is set previously by netif_napi_add_weight(). > > > ... > >Best regards >-- >Marek Szyprowski, PhD >Samsung R&D Institute Poland > > > return 0; > > >Will submit the patch in a jiff. Thanks! > > > >> >>Best regards >>-- >>Marek Szyprowski, PhD >>Samsung R&D Institute Poland >>