From patchwork Tue Dec 5 12:14:20 2023 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: 750376 Delivered-To: patch@linaro.org Received: by 2002:adf:9b9d:0:b0:333:3a04:f257 with SMTP id d29csp1635061wrc; Tue, 5 Dec 2023 04:15:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHahKFOBlO4dkypl6XvkBS7py71KG+nLQWSWS/SErvpK/f40wHZ1ZSkCommtE8Csv09k/jV X-Received: by 2002:a05:620a:f0b:b0:77d:72cf:c47 with SMTP id v11-20020a05620a0f0b00b0077d72cf0c47mr1603081qkl.35.1701778512964; Tue, 05 Dec 2023 04:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701778512; cv=none; d=google.com; s=arc-20160816; b=ww3vsW/TFMrkhEVmQabDKZ3nKwdK19EQjbhf75mUHbhU28820C4BoFlfwOBB27bsVT oaHG5G5HAlrgJTvtkwWGkjCk5cnCClEGJKh7HVFfgiTI9s6sXjIcI+PRtAOEkZJEcYex wUa+TdBvJkwPpZ9IN8fKfVbkvf11Uthv86CN24/rbvPJXCw0d99mptcoEPhyWO5yEE3A aQKQ+xpY+DQqG8xkm/HCWKoK06jx8K9PbaskkGXR+lLUpbrUPbnSLgIuCilO55R51Ag6 0FR8qk2yLgY05J0fvsPXljSffGcQmERTGTeBl2Txp6GKoLr1H+xtq3heeLuCV5dCVoF3 5FVw== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=O2i2l7UTXcwW/1BuKVwvqkiOKtZAZuK4tBGvO7/lqVE=; fh=v8eUbSUNaJKjz9SiTsbhAf2H0lhjbptzvgb2Wnk2470=; b=d50OHvtmH6WFMe0ZjpE7ARVDhzBKRpnZuUMQvyeiokqJl57ipHJl8pYk+//BECVgIb 8vMFA/ygdFuMjJMI45HY5atY+q0G/NYszsPp0bYAruNeLO9lBkrUxynk61itxnbIYONo DUCyk2L0PRwyWpPP5cxV4fwJKtm8G8Ix/EDLf5FFG2sV5HTrjHzeL+WDzvNiUtxNrlZ8 nt1TG4TufHZmfVGYf821EmjMI7X324INbZCdKk3yEZEOkArqEj3qzuLyKGM4MEzb9iqy r39zi2Sl5bEA9C6Kl/lGCnVLMW/IRcgrvcPrI8Bl5ebPSlcr1VWI+f/fSRDaatW168/1 oZaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ogm9QPYB; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w9-20020a05620a444900b007789405e408si12484919qkp.578.2023.12.05.04.15.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Dec 2023 04:15:12 -0800 (PST) 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=ogm9QPYB; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rAUJq-0001Un-VI; Tue, 05 Dec 2023 07:14:31 -0500 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 1rAUJo-0001UA-GN for qemu-devel@nongnu.org; Tue, 05 Dec 2023 07:14:29 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rAUJm-0000H3-54 for qemu-devel@nongnu.org; Tue, 05 Dec 2023 07:14:28 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40c05ce04a8so34084225e9.0 for ; Tue, 05 Dec 2023 04:14:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701778464; x=1702383264; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=O2i2l7UTXcwW/1BuKVwvqkiOKtZAZuK4tBGvO7/lqVE=; b=ogm9QPYBCJKqM9gkyPjMaRufSqIM7kL0/eJ3k6+CLpLWj7nYKA4GqhbDpglMaLxS4R 7oUZIw4n781uQIYEtbzOIdeogIvEIQDBNmYcfPVrOPXgHkZ+j/m6+CIPp6xmDilPOF+9 kweJ5RUGaXpJQABgJmt5nmK725HmL0JeNCtYcq95CrgxsSbQAfvx14eZOPtHskfOwtJA Y6LOsdKXHdSHCuoQDXv6TC/LpR0cdT/2fWy86bbyA9rYXlkDZR/03jxcZob1MKaeg0ZE VZQdBPrtjNWD3AYuxylgJy8JpjQsNgCMvSwXaqep6yDkPhtv5EBhk1j8P8INVbMYlBVd l7cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701778464; x=1702383264; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=O2i2l7UTXcwW/1BuKVwvqkiOKtZAZuK4tBGvO7/lqVE=; b=FNT+D8ayTcQ7XdIQC5LJN0avsR1TbYO/RoHjPV8AeB9rsRVG5zsvEOiHIA0cA1J7hv iE5OtFCrisfS/dcFT1u9NHdrhmNcuiwBKjaAxiPqKSEZ+KIODIK5wwUhgEB8D6IbvxaE 1gJvF67nCbRvQK0NWvfF2YsWZzo5WVPH2RZiz1U1nFYOy7LOfy1vpxUyAaly8GNiON3O AM0WWjwgMU2Yowj87zLwMFQwMFVZsBrc83UPskQ7yUlyA2I0+s6j4uxU6aDeKy0ap7uZ rs/HH1XV29hZB1B9BlrkBbwuwrDHzJtIBbnDqFXxc9uU22w7hpTGA+4LYAZtYAaWOuVb q0+g== X-Gm-Message-State: AOJu0YwAOwhyntGJPM22NL/G3dl/O7Skt+z0Eyxh0GJRE0aDi/SOioUl K+RQNp8saInDR9y09oHWL64zXA== X-Received: by 2002:a1c:7416:0:b0:40c:a15:eee5 with SMTP id p22-20020a1c7416000000b0040c0a15eee5mr914999wmc.50.1701778463867; Tue, 05 Dec 2023 04:14:23 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id u2-20020a05600c138200b00405d9a950a2sm22225347wmf.28.2023.12.05.04.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 04:14:23 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 268815F79A; Tue, 5 Dec 2023 12:14:23 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Pavel Dovgalyuk , Richard Henderson , Paolo Bonzini Subject: [RFC PATCH] replay: stop us hanging in rr_wait_io_event Date: Tue, 5 Dec 2023 12:14:20 +0000 Message-Id: <20231205121420.3287637-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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=ham 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 A lot of the hang I see are when we end up spinning in rr_wait_io_event for an event that will never come in playback. As a new check functions which can see if we are in PLAY mode and kick us us the wait function so the event can be processed. This fixes most of the failures in replay_kernel.py Signed-off-by: Alex Bennée Cc: Pavel Dovgalyuk --- include/sysemu/replay.h | 5 +++++ accel/tcg/tcg-accel-ops-rr.c | 2 +- replay/replay.c | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index 08aae5869f..83995ae4bd 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -70,6 +70,11 @@ int replay_get_instructions(void); /*! Updates instructions counter in replay mode. */ void replay_account_executed_instructions(void); +/** + * replay_can_wait: check if we should pause for wait-io + */ +bool replay_can_wait(void); + /* Processing clocks and other time sources */ /*! Save the specified clock */ diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 611932f3c3..825e35b3dc 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -109,7 +109,7 @@ static void rr_wait_io_event(void) { CPUState *cpu; - while (all_cpu_threads_idle()) { + while (all_cpu_threads_idle() && replay_can_wait()) { rr_stop_kick_timer(); qemu_cond_wait_iothread(first_cpu->halt_cond); } diff --git a/replay/replay.c b/replay/replay.c index 0f7d766efe..e71cdbf819 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -338,6 +338,30 @@ void replay_start(void) replay_enable_events(); } +/* + * For none/record the answer is yes. + */ +bool replay_can_wait(void) +{ + if (replay_mode == REPLAY_MODE_PLAY) { + /* + * For playback we shouldn't ever be at a point we wait. If + * the instruction count has reached zero and we have an + * unconsumed event we should go around again and consume it. + */ + if (replay_state.instruction_count == 0 && replay_state.has_unread_data) { + return false; + } else { + fprintf(stderr, "Error: Invalid replay state\n"); + fprintf(stderr,"instruction_count = %d, has = %d, event_kind = %d\n", + replay_state.instruction_count, replay_state.has_unread_data, replay_state.data_kind); + abort(); + } + } + return true; +} + + void replay_finish(void) { if (replay_mode == REPLAY_MODE_NONE) {