From patchwork Tue Aug 13 20:23:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 818861 Delivered-To: patch@linaro.org Received: by 2002:adf:cd01:0:b0:367:895a:4699 with SMTP id w1csp431121wrm; Tue, 13 Aug 2024 13:28:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWnluPUGRCZhBwwTh0BSV3T2TFBdW02151mw8E5OPDiKHgzKeqITgkylmCjsb4H6I2NMqWPYglO2KawKMIPsXzU X-Google-Smtp-Source: AGHT+IHA0qQncgDErnTiHnVWhaY4+ui1NbpzzcA3zxlLbxyqylGhDZObMqZ19PPqLw0g926VrC75 X-Received: by 2002:a05:620a:2996:b0:79c:fbf:6381 with SMTP id af79cd13be357-7a4ee405e41mr64686085a.70.1723580887612; Tue, 13 Aug 2024 13:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723580887; cv=none; d=google.com; s=arc-20160816; b=Tguiioujd99pbVuEo24rlgyMd1ETKz8Dr0mboiL2DfpxxO7ruFGslRMNE7aiYZ+HdD 6Pw7b3Tnd7JiuBlvfq6w9zHHfgDf7tkio87Ymi3nsXiVLyA5wKUMBaYjxh0TMsdJI01z AHvgOKIw9hEUgXys3AGoIqggMFXAOXr2j4TQJ27nEqKfSUJB1PndkY4F2Q9JDC1jDGPc BWQWdtYZOmz631SfPFywvtG9BReROm42FIEIhkvA03Sy4RG9V5icPBI40rE+KJWBwFRm i3BvPKKXxsPYMdbNeKt2RLdf/qnxgcZHqk07oD/geJRxEsauWB29KfWv8EAPI2BFq+R6 e9Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4m5IfYOaf6fUwMZhOlNmGn0JNN4Zc0W9g3hkgpxxQnw=; fh=CA3M1ELZq0B3Vsyopbo2wbvGRMyzgjLkXtCvvSx9Tl4=; b=XEspbHzMWnH4Mh8PfQafP9QqXitqk4I7uA6xRaORWDdh/3+49qcMdl4HA9wYF/9ncR ovvO/h4/8zbcuZHkoDGeducRfjY11zN7yZrWns2IMfAyjdX+2N/LLuAp6K0eonEtabIV NCABhwPQSzjw7DnnSYDaN2P2UHnS4d/TndkGCVNXzxTiNhJZbGkW6vcvWQqt2T9vVsW6 4jE0gQCUtsNIMTNAL3Gt2gGENNjVUdDKRiV5VQN0bjZaO3TAqtdZVqxtlKlcPZZZZ+be h5PbJk14VH3Auljo1AneFUPGyNcBM1Vyf5h3uCcvuKWoXPrc5vDjjUTNBgF9BgFsUOZD Xn5A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rbBn8TsC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a4c7e1363fsi959369885a.543.2024.08.13.13.28.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2024 13:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rbBn8TsC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdy47-0007Dd-Pv; Tue, 13 Aug 2024 16:24:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sdy3w-0006JE-RY for qemu-devel@nongnu.org; Tue, 13 Aug 2024 16:24:12 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sdy3U-0006IZ-Oo for qemu-devel@nongnu.org; Tue, 13 Aug 2024 16:24:11 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-368440b073bso165556f8f.0 for ; Tue, 13 Aug 2024 13:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723580623; x=1724185423; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4m5IfYOaf6fUwMZhOlNmGn0JNN4Zc0W9g3hkgpxxQnw=; b=rbBn8TsCWI73DftEyi9j7mkitjdh4YlY8ptF/LlEyzPMXPg/HASSNLV/CBxhLqnh46 J+DCSrr72dyUNjRlj1Uu57ZQdm7YSpJXYBsbIUZuxkdKTRvRKmqGuFjQmUQTEAMHi+B6 IrlZGjIS+pTj1HA3H6Bc16lGs8SR9kbK2uXrb0aCIS4lPUymabrFL8fiUsX7hJsn5THW B3yRUSrKiPnmakfwy1ZHFgTzHuVVrU7jmS4ZZUl5JItvQuu3sGWPOFofw6EA5bOEix32 mSuL7yVzChd3HIBkDWWZcrLUgIUBDMlslwPBdqxvpyDlkOt5mrJ27RSGP39qmoMFeR5V DBgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723580623; x=1724185423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4m5IfYOaf6fUwMZhOlNmGn0JNN4Zc0W9g3hkgpxxQnw=; b=qZPc3wqCQmAfvCXKfGOIy+3LGZrr2+tU6E4pl3FfNqVZxCdv29++NDaOCT5AHDYJJ+ Awcwajz3S+pI2NW2/x7av0ABjJfsTEnFLrx1Vfl3Foz1yIzcYCrMTZ4P1mB6K6L0veSF WMDejaCNtvf0aCY2R4AZrvnliimrAxs0pmi8jYMdMPJkZYN3lJPO297kWUTCv3e493Hi mvsz5A0/BltD4Zbcd9Xu7Ik4QQBSzI1XDmgH6KCbF6+nLzHLQXrbV771VDU73lf+soEC ABUFYquqLDE0oDeKBzmmmBrVxE9bS9ZKXTV7/LQAzy7Gb3mUU/XbJkiWlCHLsrZBoNUh 4AJA== X-Gm-Message-State: AOJu0Yxfq4EwZmzN46Dv+/H//4JQCcCeXUV5bo7PTt7/d/QpNDm2g3Kz X02vUnQ/PyU6x8cLNpG4KBgUf2J3JDFg0IOe38Rdulabx2UUphP5lny6/eTRgQM= X-Received: by 2002:adf:fe46:0:b0:36b:b08f:64b3 with SMTP id ffacd0b85a97d-3716e4807cfmr2865828f8f.20.1723580622467; Tue, 13 Aug 2024 13:23:42 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429deb51794sm849865e9.22.2024.08.13.13.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 13:23:38 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id EC265601E0; Tue, 13 Aug 2024 21:23:30 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Alistair Francis , Michael Roth , Palmer Dabbelt , Mahmoud Mandour , Pavel Dovgalyuk , Yoshinori Sato , Weiwei Li , Eduardo Habkost , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Markus Armbruster , David Hildenbrand , Beraldo Leal , Liu Zhiwei , Eric Auger , Song Gao , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Peter Xu , Jiri Pirko , Eric Blake , Fabiano Rosas , qemu-s390x@nongnu.org, Peter Maydell , "Michael S. Tsirkin" , Daniel Henrique Barboza , John Snow , Alexandre Iooss , Konstantin Kostiuk , Pierrick Bouvier , Cleber Rosa , Ilya Leoshkevich , qemu-riscv@nongnu.org, Thomas Huth , Paolo Bonzini , Richard Henderson , Jason Wang , Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Nicholas Piggin , Pavel Dovgalyuk Subject: [PATCH v2 16/21] virtio-net: Use replay_schedule_bh_event for bhs that affect machine state Date: Tue, 13 Aug 2024 21:23:24 +0100 Message-Id: <20240813202329.1237572-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240813202329.1237572-1-alex.bennee@linaro.org> References: <20240813202329.1237572-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Nicholas Piggin The regular qemu_bh_schedule() calls result in non-deterministic execution of the bh in record-replay mode, which causes replay failure. Reviewed-by: Alex Bennée Reviewed-by: Pavel Dovgalyuk Signed-off-by: Nicholas Piggin Message-Id: <20240813050638.446172-9-npiggin@gmail.com> Signed-off-by: Alex Bennée --- hw/net/virtio-net.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 08aa0b65e3..10ebaae5e2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -40,6 +40,7 @@ #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" #include "sysemu/sysemu.h" +#include "sysemu/replay.h" #include "trace.h" #include "monitor/qdev.h" #include "monitor/monitor.h" @@ -417,7 +418,7 @@ static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status) timer_mod(q->tx_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + n->tx_timeout); } else { - qemu_bh_schedule(q->tx_bh); + replay_bh_schedule_event(q->tx_bh); } } else { if (q->tx_timer) { @@ -2672,7 +2673,7 @@ static void virtio_net_tx_complete(NetClientState *nc, ssize_t len) */ virtio_queue_set_notification(q->tx_vq, 0); if (q->tx_bh) { - qemu_bh_schedule(q->tx_bh); + replay_bh_schedule_event(q->tx_bh); } else { timer_mod(q->tx_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + n->tx_timeout); @@ -2838,7 +2839,7 @@ static void virtio_net_handle_tx_bh(VirtIODevice *vdev, VirtQueue *vq) return; } virtio_queue_set_notification(vq, 0); - qemu_bh_schedule(q->tx_bh); + replay_bh_schedule_event(q->tx_bh); } static void virtio_net_tx_timer(void *opaque) @@ -2921,7 +2922,7 @@ static void virtio_net_tx_bh(void *opaque) /* If we flush a full burst of packets, assume there are * more coming and immediately reschedule */ if (ret >= n->tx_burst) { - qemu_bh_schedule(q->tx_bh); + replay_bh_schedule_event(q->tx_bh); q->tx_waiting = 1; return; } @@ -2935,7 +2936,7 @@ static void virtio_net_tx_bh(void *opaque) return; } else if (ret > 0) { virtio_queue_set_notification(q->tx_vq, 0); - qemu_bh_schedule(q->tx_bh); + replay_bh_schedule_event(q->tx_bh); q->tx_waiting = 1; } }