From nobody Tue Oct 28 01:50:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516059419204780.4538384390937; Mon, 15 Jan 2018 15:36:59 -0800 (PST) Received: from localhost ([::1]:44178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebEJA-0002XD-Mr for importer@patchew.org; Mon, 15 Jan 2018 18:36:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebEHW-0001ak-Vo for qemu-devel@nongnu.org; Mon, 15 Jan 2018 18:35:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebEHU-0002zc-EB for qemu-devel@nongnu.org; Mon, 15 Jan 2018 18:35:11 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:44783) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebEHU-0002yn-6u for qemu-devel@nongnu.org; Mon, 15 Jan 2018 18:35:08 -0500 Received: by mail-wr0-x242.google.com with SMTP id w50so13387305wrc.11 for ; Mon, 15 Jan 2018 15:35:08 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id u2sm1039193wrb.80.2018.01.15.15.35.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jan 2018 15:35:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=BgLD/S4V0OMjq9qGpaNF5oHGsm45z1pwO7P3xNXv6Bw=; b=nnyhSREbIhXW8MoZEZEqVnNU9LEBq6XKX4fePk6PxlSJvUxjSCjtL0Lmkmd6OdhoDQ mzcTRwFlb2ppfwNdPdlTfxZfSQhsnKxGO6VUr38ogBrJAd0pf6eoS7GOeNCipl6rBenm jXR/T8yFwe0jVeBSiSNC2HXQtMx28jZMoiGxXhbjC2wOFaRWYUh4ipyYtS9TRw2fiEjc aBEhnHWPE9NcE3l5iu4ORuCTZ0zJcCRprNW0FG8Eyiuxy7nhkgdYjDX4SCd48dbOQpMN HOeNtMbClXlVMjepPlHqqpUerI0BtW3CYQeM/7VfAxU6WkPDyM73OWDRofXSD709NRJh 9ZRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=BgLD/S4V0OMjq9qGpaNF5oHGsm45z1pwO7P3xNXv6Bw=; b=a1m9iYzP5Ga2rAvfyNs+YVkBocjH5CYEGNr0mu256yFVqqItM3YDm+phE5XizQo1rf Z8Rf5AO3bPey2OtHRYKgjMxuYuznkDyh7qIZrXNxwW2Y3bvrJ6aNMINXNRiQYTIG51dH 85iM0q0Xmf/G+ryHgTifLL4eSpQOj9PZlG8RdnShwi4/wQ0zMNr+DrcP3+HF60twMz7Z QpDILrROX9xffbLsjqv+m0vkewYqKGiO36flzibCwk7F61tG2hK4BcSQhXurz0OjrB39 s+EzAE4BwAb1yKoxsssu5ubeggLwVNOJajMtGemZf5aEEiETO6ipufXQKZBjzMqnq1ce AeIQ== X-Gm-Message-State: AKwxytd6pXygeMSSRhkt5JYyEnPoWSqGwJJwcHh5M6crB0WLAlrNPB7A TJnTgDH6+SmKmuqXa3kC8uTqnB1a X-Google-Smtp-Source: ACJfBouIpbgubHl58cASYCLkQcFiVf6nIFtj2ljBaH111/ItTc0Lenlm6f1T3xM794EOFyERZmO+KA== X-Received: by 10.223.139.11 with SMTP id n11mr12326297wra.102.1516059306839; Mon, 15 Jan 2018 15:35:06 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 00:35:01 +0100 Message-Id: <1516059302-7169-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516059302-7169-1-git-send-email-pbonzini@redhat.com> References: <1516059302-7169-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 46/53] cpu_physical_memory_sync_dirty_bitmap: Another alignment fix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" This code has an optimised, word aligned version, and a boring unaligned version. My commit f70d345 fixed one alignment issue, but there's another. The optimised version operates on 'longs' dealing with (typically) 64 pages at a time, replacing the whole long by a 0 and counting the bits. If the Ramblock is less than 64bits in length that long can contain bits representing two different RAMBlocks, but the code will update the bmap belinging to the 1st RAMBlock only while having updated the total dirty page count for both. This probably didn't matter prior to 6b6712ef which split the dirty bitmap by RAMBlock, but now they're separate RAMBlocks we end up with a count that doesn't match the state in the bitmaps. Symptom: Migration showing a few dirty pages left to be sent constantly Seen on aarch64 and x86 with x86+ovmf Signed-off-by: Dr. David Alan Gilbert Reported-by: Wei Huang Fixes: 6b6712efccd383b48a909bee0b29e079a57601ec Signed-off-by: Paolo Bonzini --- include/exec/ram_addr.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 6cbc02a..7633ef6 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -391,9 +391,10 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBloc= k *rb, uint64_t num_dirty =3D 0; unsigned long *dest =3D rb->bmap; =20 - /* start address is aligned at the start of a word? */ + /* start address and length is aligned at the start of a word? */ if (((word * BITS_PER_LONG) << TARGET_PAGE_BITS) =3D=3D - (start + rb->offset)) { + (start + rb->offset) && + !(length & ((BITS_PER_LONG << TARGET_PAGE_BITS) - 1))) { int k; int nr =3D BITS_TO_LONGS(length >> TARGET_PAGE_BITS); unsigned long * const *src; --=20 1.8.3.1