From nobody Tue Dec 24 13:05:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1734691393; cv=none; d=zohomail.com; s=zohoarc; b=Yo/5EMYG37MyKtrCmbvIUSXoHk/NUARA28eff+pnFJ7NhrYxGv0wdp0P2xGeZ85LPT+BNOuJ2pFFXXi3s/pakleQzEUbSOoKWkDvurjxikeH57dnhQXMibLUnWoq91rZ5KOFbx2A3gJj0QaHLIkGIqQ0CJgTYoLig9sXCgH25h0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734691393; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HYauowC6m1dSqSOOvIXZEtWuC27GaY5hc1iCZUJ/IDY=; b=kCCooWr0ECD38nFd0dywcxJdYNFNDCkE/j2m9zxdSK+bkhpW00+fH7l6QFOWvsnIZuMtRgncWWT0imnI06B8O9QccGuAVcy8AMI4ZHYeeeBM/pbzbHOy3KGmvQ2dNTEE208sFB1q8tBuz5KQvYV7x/atiiBM5lPQG9Lei0fwK78= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734691393639168.72563033498545; Fri, 20 Dec 2024 02:43:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOaTI-00020s-Ro; Fri, 20 Dec 2024 05:43:06 -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 1tOaT6-0001s3-JJ; Fri, 20 Dec 2024 05:42:52 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOaT4-0005Cp-5H; Fri, 20 Dec 2024 05:42:51 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2161eb94cceso11761945ad.2; Fri, 20 Dec 2024 02:42:49 -0800 (PST) Received: from wheely.local0.net (14-200-18-130.tpgi.com.au. [14.200.18.130]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ee06dfd3sm5376942a91.32.2024.12.20.02.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 02:42:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734691368; x=1735296168; 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=HYauowC6m1dSqSOOvIXZEtWuC27GaY5hc1iCZUJ/IDY=; b=H30Fdw7dF6wscp97B8ckdyV/pR2uvnEhVarRxbUUD/jrxPWyT5OD0yYrbjiNj2KymO oXMbjnI6sa7GdUsrx0cdwkDO+oXIn2OqRxc9jOI/tuAZ4gBIvg4cfrKA04yyJf1QIzD5 KdrChpf7vVj40X+Xd4Y7nJvIiJ8qLzufbb7bn7+KR1p19C4NzVmhzYnO08/rw6yOLxwV x/7gi8fq1ozAv33fsrnyaUFtSrBl0snTHOVEqOkjRhcql5jSuPg4Qq5fl+4UoEHZzcKX vNGQ/i7qUnJ/4dQTAqe24g1HcZ9zq2Tgw6fUM8rbMOF5bX/uQsA0It+8qOLEEL9Nr6SF 4cTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734691368; x=1735296168; 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=HYauowC6m1dSqSOOvIXZEtWuC27GaY5hc1iCZUJ/IDY=; b=DJ+l+buaVjNQBpe7DXnrJ2ouuHhgAq5rk8W+VMe4MEwKSDB/ZN5CbwA6ThO6SfZHdQ i7n3jnJbvV2tIcoTM+CwACx8UddntKl7iqqtmGXPmrvR3BizDErPap7CLK5K/SopZ6Gt B67WOS0djGvmnGkig4Mibq13uU5axJCweo/7AJYopz16gY7RPNA3LJx1AuE9REJy1npF 2d6aRwPByMG9DjbTPDPJh6Dyy0jYFttUF5P6vKZIEIX784+YNqKHVXmeSfPquH1DVOq8 wJaqxRteb/hRcrV+A6S8IN1oh+ZNI2P7g/hXQ1I7KSMc19j8pLGD/uhGZ3mHb3S+v9rX tQ3Q== X-Forwarded-Encrypted: i=1; AJvYcCVdAGYFpEYg0KexkJfYYtq7SqNk7wfhBG7hUWmQkg/GSHq6hwMtIq7EVq8zIr9whCXuPk8SXIdxjvcm@nongnu.org X-Gm-Message-State: AOJu0Yyd3WN38Z2q0EvD7A48/XA4eDS4V8GQflVBPEaWxB5VOerbDGJC 1Hi8QKuj8gF+vCRFb5p9tEv0e0xY+XG5uHFtzjP46IOCAQUs8PDqSU3qtw== X-Gm-Gg: ASbGncuxzVzNdqK9KQnkelLlS86udb+N1fwgUDHghb0LAv2c5qnlTwaP5OquW9OlxQg C5lzDO1UmOP7cLcQQH/D1KZNIPMUce2YZ5YQrIJRRVIXaTU13D602fIFEkPTWTBm6aF9GJuU8+C qmZjPNLCnrBYngiMwLaF4BN/hMKQr8tVmqL0rqTlawFtYaYaBFlNgoqPZ92S1Pq71vIYeEKJnjX oADUwSBUG9GprQ4vsDD6P+hy374Ot44kKPOdr9LXsaS7AKGvqy2aByTvNSak7UDNfeSR/7jzUMH RwifB7wYow== X-Google-Smtp-Source: AGHT+IG1LubnhyxHCMdczXSH/fXeerTfPXvXsmGZLINQD0+k2LGCX5KTQV6fRZoo9KcSXow1AgaTQw== X-Received: by 2002:a17:90a:c2c8:b0:2ee:ead6:6213 with SMTP id 98e67ed59e1d1-2f452e4c536mr3868057a91.19.1734691368253; Fri, 20 Dec 2024 02:42:48 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kevin Wolf , Hanna Reitz , Pavel Dovgalyuk , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Ronnie Sahlberg , John Snow , "Michael S. Tsirkin" , Jason Wang , Vladimir Sementsov-Ogievskiy , Peter Xu , Fabiano Rosas , "Dr. David Alan Gilbert" , Markus Armbruster , Michael Roth , Wainer dos Santos Moschetta Subject: [PATCH 02/17] replay: Fix migration replay_mutex locking Date: Fri, 20 Dec 2024 20:42:04 +1000 Message-ID: <20241220104220.2007786-3-npiggin@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241220104220.2007786-1-npiggin@gmail.com> References: <20241220104220.2007786-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=npiggin@gmail.com; helo=mail-pl1-x633.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1734691395513116600 Content-Type: text/plain; charset="utf-8" Migration causes a number of events that need to go in the replay trace, such as vm state transitions. The replay_mutex lock needs to be held for these. The simplest approach seems to be just take it up-front when taking the bql. Signed-off-by: Nicholas Piggin --- migration/migration.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 2eb9e50a263..277fca954c1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -24,6 +24,7 @@ #include "socket.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" +#include "sysemu/replay.h" #include "sysemu/cpu-throttle.h" #include "rdma.h" #include "ram.h" @@ -2518,6 +2519,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) } =20 trace_postcopy_start(); + replay_mutex_lock(); bql_lock(); trace_postcopy_start_set_run(); =20 @@ -2629,6 +2631,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) migration_downtime_end(ms); =20 bql_unlock(); + replay_mutex_unlock(); =20 if (migrate_postcopy_ram()) { /* @@ -2670,6 +2673,7 @@ fail: } migration_call_notifiers(ms, MIG_EVENT_PRECOPY_FAILED, NULL); bql_unlock(); + replay_mutex_unlock(); return -1; } =20 @@ -2721,6 +2725,7 @@ static int migration_completion_precopy(MigrationStat= e *s, { int ret; =20 + replay_mutex_lock(); bql_lock(); =20 if (!migrate_mode_is_cpr(s)) { @@ -2746,6 +2751,7 @@ static int migration_completion_precopy(MigrationStat= e *s, s->block_inactive); out_unlock: bql_unlock(); + replay_mutex_unlock(); return ret; } =20 @@ -3633,6 +3639,7 @@ static void *bg_migration_thread(void *opaque) =20 trace_migration_thread_setup_complete(); =20 + replay_mutex_lock(); bql_lock(); =20 if (migration_stop_vm(s, RUN_STATE_PAUSED)) { @@ -3666,6 +3673,7 @@ static void *bg_migration_thread(void *opaque) */ migration_bh_schedule(bg_migration_vm_start_bh, s); bql_unlock(); + replay_mutex_unlock(); =20 while (migration_is_active()) { MigIterateState iter_state =3D bg_migration_iteration_run(s); @@ -3695,6 +3703,7 @@ fail: migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); bql_unlock(); + replay_mutex_unlock(); } =20 fail_setup: --=20 2.45.2