From patchwork Tue Dec 5 20:41:04 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: 750390 Delivered-To: patch@linaro.org Received: by 2002:adf:9b9d:0:b0:333:3a04:f257 with SMTP id d29csp1896956wrc; Tue, 5 Dec 2023 12:42:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkwmr5qbSRAj88PPToLM0wrupZHvkeYNacCUUPylZmKGDpWows4ydioRo60kUSHXbU3NDM X-Received: by 2002:a0c:d844:0:b0:67a:5457:77c9 with SMTP id i4-20020a0cd844000000b0067a545777c9mr2068969qvj.11.1701808963267; Tue, 05 Dec 2023 12:42:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701808963; cv=none; d=google.com; s=arc-20160816; b=eKHAWIuYc31RNiTtVex2Q9YUw21LwGTifxg9r1UNXYs9imS3c585FZX93bVZmPSTi+ jj1bTGlR93/pbFrCAfa88jZxhDwtNI2bot9qbnz5q21F5uDasuJnu9IWghRHBk6gQPm7 gJ5urczoOhtMdcd2W6qovpvRdkV5m7h1A/+6kpDeiqNupbwhEyC6Hln6cvfUp3XvhZGn SLWFhewpMIo4TwQ7ypGfS61Ka3p14PEglXCjmrz/s5t77wTPEMPtf9aTZp5W20pOhrZh jfGDDU+aMhT7f6cKqgNGVmXOgx0/xRL8hz9vc9ox5hbbNQDbvmvW6MbABJkPtPhIV1sD Reyg== 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=d4GcixrJLz9YAIgU+u8MRbzGUgAv+ZLjiVh41JlVLC0=; fh=WQskExECjOtS2oBrq9x2ue7OeVr6ye1r4N0aDOSz0G8=; b=Douj4Rdh9xOYvhW7OVduBk5tZ+16vpI+TrkMrxUbmE17rs8pzN4yrgFX+aHUEDkqy7 HY8fVpwF/HYhqJkrzNXazXdZ/FltA+rcmnGoPyP5wZIuoxASp6KnHj3zKKmJPJAEYroA +dMQcFHvSt1YaBJyVOM+vW70gObEzmIGqA4+MIUPCj/KgEkqG/rjcRiG55sEbs9ts64z UJAzDX3ns2Unvye3a5RYvM8xe0jT0UA7jwCWgA7qRAJNJWIgsrrBEmbnDlRuhfLpeOv1 M4h/iWRZAnOG2Bdx5MvoLI/6W5lyiX5+gH8zDcfuzwyjSBnC4H5bNqSECCmeQf0SprD0 l4dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ArJAr8Cm; 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 l9-20020ad44d09000000b0067aa9c6c7d8si8090723qvl.424.2023.12.05.12.42.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Dec 2023 12:42:43 -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=ArJAr8Cm; 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 1rAcEI-0007RK-Os; Tue, 05 Dec 2023 15:41:18 -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 1rAcEF-0007QO-Mq for qemu-devel@nongnu.org; Tue, 05 Dec 2023 15:41:15 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rAcED-0002FY-TH for qemu-devel@nongnu.org; Tue, 05 Dec 2023 15:41:15 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3316c6e299eso75934f8f.1 for ; Tue, 05 Dec 2023 12:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701808872; x=1702413672; 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=d4GcixrJLz9YAIgU+u8MRbzGUgAv+ZLjiVh41JlVLC0=; b=ArJAr8CmoGO6mRxH+TVptMJo8H9OPnmrFIB2WlVJN3fr6sESS2yliRHpjHxDRiW2lm lyICFBSJSMPhkHZySZxqUfuvG0D+Dm4i6t129CQ2Ad7mPs25CNr6W4MQhZh5hpI65Ebk jApWmAf0Ws7ybIG/Jc+QrxkH/T2SCZRB1T5Pp3IekMQoQiwm3/1+L5eh3MdSWYdh6OLa 5gnQkl9MLpTwm7lLbLzt1yw1cXLr/v+ShrtDoQ3O5yZlLbzgLRAitB6sd3KkMtHzz3cG XXqD5xSbgq33xTI2UshxywHzlUvEUxZ/wYm4bSrEE83rKqVYmDcGvl8aulspTQi9UCiR 7Emw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701808872; x=1702413672; 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=d4GcixrJLz9YAIgU+u8MRbzGUgAv+ZLjiVh41JlVLC0=; b=t4TXet0xhSevsEr/Lx2KKAexPnax4EY6Qi4PETyjZLNpI6OKcztUL0kH8biLJ8758y 57JPZ4jpg0ldkR5gZQuNcSBmhVljOrhq04z1XX1sG/5AghJihHuMqTxt3RnG9npl0Sn7 qvUZCjL404Be5y13Qfl1RyA7Lap1do9ZTH0mkyCZFIs49JcEhAKW6dxKaGoeXbDs4Lgp 62x0QH8Z2FwR91ndcNGXnkH9ialilK/TIUjyS8nUUgbXTWfs+1HDozgYJYlkOOWN2dPt SRPtDgIyk0mArgsJ31lZmYa0BBqZOgYrKy1M6ANUPpeLg+mBAU7Cg4GAdWR2kcnkqN80 PwjA== X-Gm-Message-State: AOJu0Yz+gBpDqa6uiQYwrEVwfMLIdLySYxqZQWeiiU6eBiw0hTI1VEgn NEPZCZ30MysbzNy/AY0V/DnrpA== X-Received: by 2002:a5d:480f:0:b0:333:2fd2:3c02 with SMTP id l15-20020a5d480f000000b003332fd23c02mr3241851wrq.187.1701808872500; Tue, 05 Dec 2023 12:41:12 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id j6-20020a5d6046000000b0033326e90496sm14426972wrt.18.2023.12.05.12.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 12:41:09 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C12755FBB6; Tue, 5 Dec 2023 20:41:06 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Cleber Rosa , Beraldo Leal , Eduardo Habkost , Richard Henderson , Wainer dos Santos Moschetta , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , Pavel Dovgalyuk , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 09/11] replay: stop us hanging in rr_wait_io_event Date: Tue, 5 Dec 2023 20:41:04 +0000 Message-Id: <20231205204106.95531-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231205204106.95531-1-alex.bennee@linaro.org> References: <20231205204106.95531-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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 Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2013 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 e83c01285c..042a6a9636 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -347,6 +347,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) {