From nobody Mon Feb 9 23:03:23 2026 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668514882; cv=none; d=zohomail.com; s=zohoarc; b=LfW8MncuMBQw6vK108niawxJtUfBrLgcwASu4QP5PG5tPEbQW/+rylLe8byha5cFfnEUJLKDKQpe+YwJGfoszW3A5oY4mjuOI/zvvnsSEOazekvtw4uj2kMTqNr7HtHgAMfhSNrPnUY1O6xClT2kPSK/gtAGSUVqnci/2pqhz4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668514882; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dg3mCFE8uw/wfOpkRNh1WTdMqbNPgtOyxMHit2mecd8=; b=Ug0iMA+ojHyY72dNgmjLr4DKYCYXaJ0mQhM7HSFfscy5Tg/53zvpBxwlBEyYbOZ/+9Dpacc5JiQ5jJHau/lQUWXbnqBb8dIHi98GnOy7qzVrdgHNPVB7y6m4aTPJcJux4CT/jqG5rxo9mcrTmiz8GO1jn5w1AX3fEUiG86qDJpw= 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 1668514882987555.5488417857666; Tue, 15 Nov 2022 04:21:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouuok-0004Yj-ML; Tue, 15 Nov 2022 07:13:30 -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 1ouuoj-0004Tz-75 for qemu-devel@nongnu.org; Tue, 15 Nov 2022 07:13:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouuoh-0004hG-NP for qemu-devel@nongnu.org; Tue, 15 Nov 2022 07:13:28 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-272-nacXecD6ONCsmXJUu7wibQ-1; Tue, 15 Nov 2022 07:13:23 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 868192999B2E; Tue, 15 Nov 2022 12:13:22 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D03D492B05; Tue, 15 Nov 2022 12:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668514407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dg3mCFE8uw/wfOpkRNh1WTdMqbNPgtOyxMHit2mecd8=; b=hPMHpDbU3bCEvHmUtQe8PvuP47ZlC0M5YfPGHqUbqNnJIXUl0y+G6ao2f4ClkRnMUW30Iz xq0O6IXBEndEn8wO5GdNSiDNtstj34hV6zAANKmaMH0zyDoWB6VfsCjsThGq1keWnQXWq9 gy9zmx3eAV1AuTsZmkmPSG/gFBDOlZs= X-MC-Unique: nacXecD6ONCsmXJUu7wibQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , David Hildenbrand , Laurent Vivier , Stefan Hajnoczi , Fam Zheng , qemu-block@nongnu.org, "Dr. David Alan Gilbert" , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-trivial@nongnu.org, Michael Tokarev , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , Juan Quintela Subject: [PATCH 15/30] migration: Take bitmap mutex when completing ram migration Date: Tue, 15 Nov 2022 13:12:11 +0100 Message-Id: <20221115121226.26609-16-quintela@redhat.com> In-Reply-To: <20221115121226.26609-1-quintela@redhat.com> References: <20221115121226.26609-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668514883944100003 Content-Type: text/plain; charset="utf-8" From: Peter Xu Any call to ram_find_and_save_block() needs to take the bitmap mutex. We used to not take it for most of ram_save_complete() because we thought we're the only one left using the bitmap, but it's not true after the preempt full patchset applied, since the return path can be taking it too. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- migration/ram.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 2fcce796d0..96fa521813 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3434,6 +3434,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) /* try transferring iterative blocks of memory */ =20 /* flush all remaining blocks regardless of rate limiting */ + qemu_mutex_lock(&rs->bitmap_mutex); while (true) { int pages; =20 @@ -3447,6 +3448,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) break; } } + qemu_mutex_unlock(&rs->bitmap_mutex); =20 flush_compressed_data(rs); ram_control_after_iterate(f, RAM_CONTROL_FINISH); --=20 2.38.1