From nobody Tue Oct 28 02:12:20 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 1516115897556889.5747855127523; Tue, 16 Jan 2018 07:18:17 -0800 (PST) Received: from localhost ([::1]:40089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebT0C-0002zJ-LN for importer@patchew.org; Tue, 16 Jan 2018 10:18:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebS4f-0003e8-IG for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebS4a-0005Rk-Qp for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:49 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:38888) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebS4a-0005RK-KD for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:44 -0500 Received: by mail-wm0-x241.google.com with SMTP id 141so8907992wme.3 for ; Tue, 16 Jan 2018 06:18:44 -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 u10sm1537758wrg.6.2018.01.16.06.18.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 06:18:42 -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=ISl0i3llq5unHtCr/QLONihZ2KLuyhX/r6ot/KCY+P637pEjitsBpK1Y7qObOj5Oeb 9znvzALoYt7Bd5+AMS2jOSwsNwSR/cIsh7LAGG5iippZ1wvJin+FyIXRVv2TG975U7+N tk5FbPtvSFEiywCmPBtlAnI2DHBjnmfBJPfMJNbkeU6BSOWqvAl6YgrVEaC+BpQQibCa 9br2baFuPnX0x5YZxOYttNsX2F6krusHOtSt2Mf8asrPqS1mJyLHF8LAc1T2dip49JiY L8JA23WULmdL4HiJO5BUwGSMTNYFmjqkAWvzCljMNFVESO29J88l6ubfPLXMFpKXhefx Y5mQ== 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=C6IAlKlb83+4sGBlvMvaAuhxWJQfd5JypU4kMkE3dHdS7MMTbkpy8nEq3cy/jEjppP QCWBvCUpkeGEq+pT+/QWBMzMQw5qLGL/fFuQeCUBao/YL5A6qSjR91i6e92G5zSPvdtV 83tke7ioAr+COMloXXa3ZPDcadI/DWG5b9pWddZH0ItrfpHWrIcXOLDcZgOdlwN9VHMk xMyE85PL4i9DZQa531UIE6Xm9DmzKCagQOEFh87tWMjxjVxVr+7iMlOqQh52C3UD4PwM +VfOEa2jnPj0MIMzl7804KPJLLIUdD45oAQ8CI/CKSdXBKpcpFSvw4T7vA2eCC54+4ui pEZQ== X-Gm-Message-State: AKwxytf9d2WWrvoI5zwmgbq0j+gCV+D734xbVOQEaT8jPFnMzgWxsc2t lXhk3wFo1wpaNbmS+V+iQnjlZg1C X-Google-Smtp-Source: ACJfBosr+gHiYxQMyzMwHr7N0JTiO6v43BG6a/DSVwqS2m7LvS0mQm45iD1jdbHAMA+FEYXNmUPtvw== X-Received: by 10.28.69.212 with SMTP id l81mr13597287wmi.65.1516112323025; Tue, 16 Jan 2018 06:18:43 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 15:17:27 +0100 Message-Id: <1516112253-14480-46-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516112253-14480-1-git-send-email-pbonzini@redhat.com> References: <1516112253-14480-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:c09::241 Subject: [Qemu-devel] [PULL 45/51] 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